File tree Expand file tree Collapse file tree 5 files changed +29
-22
lines changed
src/utils/markdown/plugins Expand file tree Collapse file tree 5 files changed +29
-22
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ export function rehypeCollectHeadings(initialHeadings?: MarkdownHeading[]) {
1919 return
2020 }
2121
22- const id = typeof node . properties ?. id === 'string' ? node . properties . id : ''
22+ const id =
23+ typeof node . properties ?. id === 'string' ? node . properties . id : ''
2324 if ( ! id ) {
2425 return
2526 }
Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ export function parseDescriptor(descriptor: string) {
3232export const isCommentNode = ( value : unknown ) : value is { value : string } =>
3333 Boolean (
3434 value &&
35- typeof value === 'object' &&
36- 'type' in value &&
37- value . type === 'comment' ,
35+ typeof value === 'object' &&
36+ 'type' in value &&
37+ value . type === 'comment' ,
3838 )
3939
4040export const slugify = ( value : string , fallback : string ) => {
Original file line number Diff line number Diff line change 11export { rehypeParseCommentComponents } from './parseCommentComponents'
22export { rehypeTransformCommentComponents } from './transformCommentComponents'
33export { transformTabsComponent } from './transformTabsComponent'
4- export {
5- type MarkdownHeading ,
6- rehypeCollectHeadings ,
7- } from './collectHeadings'
4+ export { type MarkdownHeading , rehypeCollectHeadings } from './collectHeadings'
85export { rehypeShikiHighlight } from './syntaxHighlight'
Original file line number Diff line number Diff line change @@ -60,7 +60,11 @@ export const rehypeShikiHighlight = () => {
6060 visit ( tree , 'element' , ( node : Element ) => {
6161 if ( node . tagName !== 'pre' ) return
6262 const codeNode = node . children ?. [ 0 ]
63- if ( ! codeNode || codeNode . type !== 'element' || codeNode . tagName !== 'code' ) {
63+ if (
64+ ! codeNode ||
65+ codeNode . type !== 'element' ||
66+ codeNode . tagName !== 'code'
67+ ) {
6468 return
6569 }
6670
@@ -80,7 +84,8 @@ export const rehypeShikiHighlight = () => {
8084 highlightTasks . push (
8185 ( async ( ) => {
8286 const normalizedLang = LANG_ALIASES [ langRaw ] ?? ( langRaw as Lang )
83- const effectiveLang = normalizedLang === 'mermaid' ? 'plaintext' : normalizedLang
87+ const effectiveLang =
88+ normalizedLang === 'mermaid' ? 'plaintext' : normalizedLang
8489
8590 if (
8691 ! highlighter
@@ -127,11 +132,13 @@ export const rehypeShikiHighlight = () => {
127132 ) ,
128133 )
129134
130- const fragmentTrees = htmlFragments . map ( ( fragment ) =>
131- fragmentParser . parse ( fragment ) as Root ,
135+ const fragmentTrees = htmlFragments . map (
136+ ( fragment ) => fragmentParser . parse ( fragment ) as Root ,
132137 )
133138
134- node . children = fragmentTrees . flatMap ( ( fragmentTree ) => fragmentTree . children )
139+ node . children = fragmentTrees . flatMap (
140+ ( fragmentTree ) => fragmentTree . children ,
141+ )
135142 } ) ( ) ,
136143 )
137144 } )
Original file line number Diff line number Diff line change @@ -94,15 +94,17 @@ export function transformTabsComponent(node: Element) {
9494 return
9595 }
9696
97- const panelElements : Element [ ] = result . panels . map ( ( panelChildren , index ) => ( {
98- type : 'element' ,
99- tagName : 'md-tab-panel' ,
100- properties : {
101- 'data-tab-slug' : result . tabs [ index ] ?. slug ?? `tab-${ index + 1 } ` ,
102- 'data-tab-index' : String ( index ) ,
103- } ,
104- children : panelChildren ,
105- } ) )
97+ const panelElements : Element [ ] = result . panels . map (
98+ ( panelChildren , index ) => ( {
99+ type : 'element' ,
100+ tagName : 'md-tab-panel' ,
101+ properties : {
102+ 'data-tab-slug' : result . tabs [ index ] ?. slug ?? `tab-${ index + 1 } ` ,
103+ 'data-tab-index' : String ( index ) ,
104+ } ,
105+ children : panelChildren ,
106+ } ) ,
107+ )
106108
107109 node . properties = {
108110 ...node . properties ,
You can’t perform that action at this time.
0 commit comments