@@ -83,28 +83,46 @@ function visitDFS(root: Node, type: string, visitors: { pre?: Visitor; post?: Vi
83
83
84
84
function stringifyTabs ( root : Node ) {
85
85
const post = ( node : Node ) => {
86
- if ( isElementWithProperties ( node ) && isTabs ( node . properties ) ) {
87
- const tabStackDepth = getTabsDepth ( node . properties )
88
- const indentation = '' . padStart ( tabStackDepth , ' ' )
86
+ if ( isElementWithProperties ( node ) ) {
87
+ if ( isTabs ( node . properties ) ) {
88
+ const tabStackDepth = getTabsDepth ( node . properties )
89
+ const indentation = '' . padStart ( tabStackDepth , ' ' )
89
90
90
- node [ 'value' ] = indentAll (
91
- node . children . map ( tab => {
92
- const tabTitle = getTabTitle ( tab )
91
+ node [ 'value' ] = indentAll (
92
+ node . children . map ( tab => {
93
+ const tabTitle = getTabTitle ( tab )
93
94
94
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
95
- const tabContent = indent ( toMarkdownString ( tab ) , ' ' )
95
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
96
+ const tabContent = indent ( toMarkdownString ( tab ) )
96
97
97
- return `=== "${ tabTitle } "
98
+ return `=== "${ tabTitle } "
98
99
99
100
${ tabContent }
100
101
`
101
- } ) ,
102
- indentation
103
- )
102
+ } ) ,
103
+ indentation
104
+ )
104
105
105
- delete node . tagName
106
- delete node . children
107
- delete node . properties
106
+ delete node . tagName
107
+ delete node . children
108
+ delete node . properties
109
+ } else if ( node . tagName === 'tip' ) {
110
+ const { className, title, open } = node . properties
111
+
112
+ const tipContent = node . children
113
+ . map ( toMarkdownString ) // eslint-disable-line @typescript-eslint/no-use-before-define
114
+ . map ( _ => indent ( _ ) )
115
+ . join ( '\n' )
116
+
117
+ node [ 'value' ] = `!!!${ open ? '+' : '' } ${ className } "${ title } "
118
+
119
+ ${ tipContent }
120
+ `
121
+
122
+ delete node . tagName
123
+ delete node . children
124
+ delete node . properties
125
+ }
108
126
}
109
127
}
110
128
0 commit comments