@@ -81,20 +81,20 @@ const SANITIZE = (string) =>
8181 * http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
8282 */
8383function addAttributeInElement ( node , elementTarget , separator ) {
84- const mardownClassesInElementsRegex = new RegExp ( separator , "mg" ) ;
85- const mardownClassRegex = new RegExp (
84+ const markdownClassesInElementsRegex = new RegExp ( separator , "mg" ) ;
85+ const markdownClassRegex = new RegExp (
8686 '([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])' ,
8787 "mg" ,
8888 ) ;
8989 let nodeValue = node . nodeValue ;
9090 let matches ,
9191 matchesClass ;
92- if ( ( matches = mardownClassesInElementsRegex . exec ( nodeValue ) ) !== null ) {
92+ if ( ( matches = markdownClassesInElementsRegex . exec ( nodeValue ) ) !== null ) {
9393 const classes = matches [ 1 ] ;
9494 nodeValue = nodeValue . substring ( 0 , matches . index ) +
95- nodeValue . substring ( mardownClassesInElementsRegex . lastIndex ) ;
95+ nodeValue . substring ( markdownClassesInElementsRegex . lastIndex ) ;
9696 node . nodeValue = nodeValue ;
97- while ( ( matchesClass = mardownClassRegex . exec ( classes ) ) !== null ) {
97+ while ( ( matchesClass = markdownClassRegex . exec ( classes ) ) !== null ) {
9898 if ( matchesClass [ 2 ] ) {
9999 elementTarget . setAttribute ( matchesClass [ 1 ] , matchesClass [ 2 ] ) ;
100100 } else {
@@ -158,15 +158,7 @@ function addAttributes(
158158 }
159159 }
160160 if ( element . nodeType == Node . COMMENT_NODE ) {
161- if (
162- addAttributeInElement (
163- element ,
164- previousElement ,
165- separatorElementAttributes ,
166- ) == false
167- ) {
168- addAttributeInElement ( element , section , separatorSectionAttributes ) ;
169- }
161+ addAttributeInElement ( element , section , separatorSectionAttributes ) ;
170162 }
171163}
172164
@@ -204,9 +196,9 @@ export function buildMarkedConfiguration(markedOptions) {
204196 // TODO: apply img src also to data-preview-image
205197 const img_src_regex =
206198 / ( ( < i m g [ ^ > ] * ? s r c = " ) ( [ ^ " ] * ?) ( " [ ^ > ] * ?> ) | ( < i m g [ ^ > ] * ? s r c = ' ) ( [ ^ ' ] + ?) ( ' [ ^ > ] * ?> ) ) / gi;
207- // const isUrl = /^https?:\/\//
208- // const isAbsolute = /^\//
209- // const isLocal = /^#/
199+ const isUrl = / ^ h t t p s ? : \/ \/ / ;
200+ const isAbsolute = / ^ \/ / ;
201+ const isLocal = / ^ # / ;
210202 const isRelative = / ^ ( \. \. \/ | \. \/ ) / ;
211203 const markedConfig = {
212204 ...markedOptions ,
@@ -224,8 +216,9 @@ export function buildMarkedConfiguration(markedOptions) {
224216 const matchOffset = match [ 2 ] ? 0 : 3 ;
225217 text . push ( token . text . substring ( last_index , match . index ) ) ;
226218 const ref = match [ 3 + matchOffset ] ;
227- // const needsRebase = !(isUrl.test(ref) || isAbsolute.test(ref) || isLocal.test(ref))
228- const needsRebase = isRelative . test ( ref ) ;
219+ const needsRebase =
220+ ! ( isUrl . test ( ref ) || isAbsolute . test ( ref ) || isLocal . test ( ref ) ) ;
221+ // const needsRebase = isRelative.test(ref);
229222 if ( needsRebase ) {
230223 text . push (
231224 `${ match [ 2 + matchOffset ] } ${ base_url } ${ match [ 3 + matchOffset ] } ${
@@ -292,10 +285,6 @@ function codeHandler(code, language) {
292285 return `<div data-mermaid-id="mermaid-${ DIAGRAM_COUNTER } " data-mermaid="${
293286 btoa ( code )
294287 } "></div>`;
295- } else if ( language === "apexchart" ) {
296- return `<div style="width: clamp(100px, 100%, 100vw); height: clamp(100px, 100%, 100vh);" data-apexchart=${
297- btoa ( code )
298- } ></div>`;
299288 } else if ( language === "echarts" ) {
300289 return `<div style="width: 100px; height: 100px; width: clamp(100px, 100%, 100vw); height: clamp(100px, 100%, 100vh);" data-echarts=${
301290 btoa ( code )
0 commit comments