@@ -21,32 +21,39 @@ function one(node: Nodes, opts: Options) {
2121 if ( 'tagName' in node ) {
2222 if ( STRIP_TAGS . includes ( node . tagName ) ) return '' ;
2323
24- if ( node . tagName === 'html-block' ) {
25- if ( ! node . properties . html ) return '' ;
26- return all ( hast ( node . properties . html . toString ( ) ) , opts ) ;
27- }
28-
29- if ( node . tagName === 'rdme-callout' ) {
30- const { icon, title } = node . properties ;
31-
32- const children = node ?. children ?. slice ( title ? 1 : 0 ) ;
33- const body = children ? all ( { type : 'root' , children } , opts ) : '' ;
34-
35- return [ icon , ' ' , title , title && body && ': ' , body ] . filter ( Boolean ) . join ( '' ) ;
36- }
37-
38- if ( node . tagName === 'readme-glossary-item' ) {
39- return node . properties . term ;
40- }
41-
42- if ( node . tagName === 'readme-variable' ) {
43- const key = node . properties . variable . toString ( ) ;
44- const val = opts . variables [ key ] ;
45- return val || `<<${ key } >>` ;
46- }
47-
48- if ( node . tagName === 'img' ) {
49- return node . properties ?. title || '' ;
24+ switch ( node . tagName ) {
25+ case 'html-block' : {
26+ if ( ! node . properties . html ) return '' ;
27+ return all ( hast ( node . properties . html . toString ( ) ) , opts ) ;
28+ }
29+ case 'rdme-callout' : {
30+ const { icon, title } = node . properties ;
31+
32+ const children = node ?. children ?. slice ( title ? 1 : 0 ) ;
33+ const body = children ? all ( { type : 'root' , children } , opts ) : '' ;
34+
35+ return [ icon , ' ' , title , title && body && ': ' , body ] . filter ( Boolean ) . join ( '' ) ;
36+ }
37+ case 'readme-glossary-item' : {
38+ return node . properties . term ;
39+ }
40+ case 'readme-variable' : {
41+ const key = node . properties . variable . toString ( ) ;
42+ const val = opts . variables [ key ] ;
43+ return val || `<<${ key } >>` ;
44+ }
45+ case 'img' : {
46+ return node . properties ?. title || '' ;
47+ }
48+ case 'Accordion' :
49+ case 'Card' :
50+ case 'Tab' : {
51+ const title = node . properties ?. title || '' ;
52+ const children = node ?. children ;
53+ const body = children ? all ( { type : 'root' , children } , opts ) : '' ;
54+
55+ return [ title , body ] . filter ( Boolean ) . join ( ' ' ) ;
56+ }
5057 }
5158 }
5259
0 commit comments