@@ -9,6 +9,7 @@ export function MarkdownItTabs(md: MarkdownIt, opts: Options) {
99 unescapeAll = md . utils . unescapeAll ,
1010 simple = / t a b = ( [ ^ \s ] * ) / ,
1111 quote = / t a b = " ( [ ^ " ] * ) / ,
12+ style = / s t y l e = ( [ ^ \s ] * ) / ,
1213 counter = 0
1314
1415 function getInfo ( token : Token ) {
@@ -46,6 +47,16 @@ export function MarkdownItTabs(md: MarkdownIt, opts: Options) {
4647 return ! ! getTabName ( token )
4748 }
4849
50+ function getStyle ( token : Token ) {
51+ var info = getInfo ( token )
52+
53+ const r = style . exec ( info )
54+ if ( r && r . length > 1 ) {
55+ return r . slice ( 1 ) [ 0 ]
56+ }
57+ return 'default'
58+ }
59+
4960 function fenceGroup ( tokens : Token [ ] , idx : number , options : Options , env : any , slf : Renderer ) : string {
5061 const token = tokens [ idx ]
5162 if ( ! token || token . hidden ) return ''
@@ -60,32 +71,42 @@ export function MarkdownItTabs(md: MarkdownIt, opts: Options) {
6071 const tabId = `tab-${ counter } -${ tabName } ` . replace ( ' ' , '-' )
6172 const tabPanelId = `tabPanel-${ counter } -${ tabName } ` . replace ( ' ' , '-' )
6273
63- return `
64- <div class="code">
65- <div class="nav code-tabs" role="tablist">
66- <button class="active"
67- id="${ tabId } "
68- data-bs-toggle="tab"
69- data-bs-target="#${ tabPanelId } "
70- type="button"
71- role="tab"
72- aria-selected="true">
73- ${ tabName }
74- </button>
75- <button type="button" class="btn btn-link control" title="Copy content" aria-label="Copy content" data-copy>
76- <span class="bi bi-copy"></span>
77- </button>
78- <div class="tabs-border"></div>
79- </div>
80- <div class="tab-content code">
81- <div class="tab-pane fade show active"
82- id="${ tabPanelId } "
83- role="tabpanel"
84- aria-labelledby="${ tabId } ">
85- ${ defaultRender ( tokens , idx , options , env , slf ) }
74+ const style = getStyle ( token )
75+
76+ if ( style === 'default' ) {
77+ return `
78+ <div class="code">
79+ <div class="nav code-tabs" role="tablist">
80+ <button class="active"
81+ id="${ tabId } "
82+ data-bs-toggle="tab"
83+ data-bs-target="#${ tabPanelId } "
84+ type="button"
85+ role="tab"
86+ aria-selected="true">
87+ ${ tabName }
88+ </button>
89+ <button type="button" class="btn btn-link control" title="Copy content" aria-label="Copy content" data-copy>
90+ <span class="bi bi-copy"></span>
91+ </button>
92+ <div class="tabs-border"></div>
8693 </div>
87- </div>
88- </div>`
94+ <div class="tab-content code">
95+ <div class="tab-pane fade show active"
96+ id="${ tabPanelId } "
97+ role="tabpanel"
98+ aria-labelledby="${ tabId } ">
99+ ${ defaultRender ( tokens , idx , options , env , slf ) }
100+ </div>
101+ </div>
102+ </div>`
103+ }
104+
105+ if ( style === 'simple' ) {
106+ return `
107+ <pre class="simple" data-label="${ lang } "><code class="hljs">${ token . content } </code></pre>
108+ `
109+ }
89110 }
90111
91112
0 commit comments