From ab8413fa90e02554fb6bf856d12bdf3dc0fe3306 Mon Sep 17 00:00:00 2001 From: Kia King Ishii Date: Fri, 27 May 2022 23:37:03 +0900 Subject: [PATCH] style: format --- src/node/markdown/plugins/component.ts | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/node/markdown/plugins/component.ts b/src/node/markdown/plugins/component.ts index 666177ee..6ca6b463 100644 --- a/src/node/markdown/plugins/component.ts +++ b/src/node/markdown/plugins/component.ts @@ -20,17 +20,17 @@ const vueReservedTags = [ /** * According to markdown spec, all non-block html tags are treated as "inline" - * tags (wrapped with

), including those "unknown" tags + * tags (wrapped with

), including those "unknown" tags. * - * Therefore, markdown-it processes "inline" tags and "unknown" tags in the same - * way, and does not care if a tag is "inline" or "unknown" + * Therefore, markdown-it processes "inline" tags and "unknown" tags in the + * same way, and does not care if a tag is "inline" or "unknown". * * As we want to take those "unknown" tags as custom components, we should - * treat them as "block" tags + * treat them as "block" tags. * - * So we have to distinguish between "inline" and "unknown" tags ourselves + * So we have to distinguish between "inline" and "unknown" tags ourselves. * - * The inline tags list comes from MDN + * The inline tags list comes from MDN. * * @see https://spec.commonmark.org/0.29/#raw-html * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements @@ -56,7 +56,7 @@ const inlineTags = [ 'em', 'embed', 'i', - /* iframe is treated as HTML blocks in markdown spec */ + // iframe is treated as HTML blocks in markdown spec // 'iframe', 'img', 'input', @@ -94,10 +94,10 @@ const inlineTags = [ 'wbr' ] -// Replacing the default htmlBlock rule to allow using custom components at +// replacing the default htmlBlock rule to allow using custom components at // root level - -// An array of opening and corresponding closing sequences for html tags, +// +// an array of opening and corresponding closing sequences for html tags, // last argument defines whether it can terminate a paragraph or not const HTML_SEQUENCES: [RegExp, RegExp, boolean][] = [ [/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true], @@ -105,13 +105,16 @@ const HTML_SEQUENCES: [RegExp, RegExp, boolean][] = [ [/^<\?/, /\?>/, true], [/^/, true], [/^/, true], - // MODIFIED HERE: Treat vue reserved tags as block tags + + // MODIFIED HERE: treat vue reserved tags as block tags [ new RegExp('^|$))', 'i'), /^$/, true ], - // MODIFIED HERE: Treat unknown tags as block tags (custom components), excluding known inline tags + + // MODIFIED HERE: treat unknown tags as block tags (custom components), + // excluding known inline tags [ new RegExp( '^]' @@ -119,6 +122,7 @@ const HTML_SEQUENCES: [RegExp, RegExp, boolean][] = [ /^$/, true ], + [ new RegExp('^|$))', 'i'), /^$/, @@ -168,8 +172,7 @@ const htmlBlock: RuleBlock = (state, startLine, endLine, silent): boolean => { nextLine = startLine + 1 - // If we are here - we detected HTML block. - // Let's roll down till block end. + // if we are here - we detected HTML block. let's roll down till block end if (!HTML_SEQUENCES[i][1].test(lineText)) { for (; nextLine < endLine; nextLine++) { if (state.sCount[nextLine] < state.blkIndent) {