This commit is contained in:
dedfaf 2025-09-13 08:17:03 +05:30 committed by GitHub
commit c3e0a48b64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,13 +11,13 @@ export const HeadingRule: BlockMDRule = {
};
const CODEBLOCK_MD_1 = '```';
const CODEBLOCK_REG_1 = /^`{3}(\S*)\n((?:.*\n)+?)`{3} *(?!.)\n?/m;
const CODEBLOCK_REG_1 = /^(`{3,}|~{3,})(?:[ \t]*(\S+))?\n([\s\S]*?)\1 *(?!.)\n?/m;
export const CodeBlockRule: BlockMDRule = {
match: (text) => text.match(CODEBLOCK_REG_1),
html: (match) => {
const [, g1, g2] = match;
const classNameAtt = g1 ? ` class="language-${g1}"` : '';
return `<pre data-md="${CODEBLOCK_MD_1}"><code${classNameAtt}>${g2}</code></pre>`;
const [ , fence, lang, code ] = match;
const classNameAtt = lang ? ` class="language-${lang}"` : '';
return `<pre data-md="${fence}"><code${classNameAtt}>${code}</code></pre>`;
},
};
@ -44,11 +44,11 @@ export const BlockQuoteRule: BlockMDRule = {
};
const ORDERED_LIST_MD_1 = '-';
const O_LIST_ITEM_PREFIX = /^(-|[\da-zA-Z]\.) */;
const O_LIST_ITEM_PREFIX = /^([\da-zA-Z]\.) */;
const O_LIST_START = /^([\d])\./;
const O_LIST_TYPE = /^([aAiI])\./;
const O_LIST_TRAILING_NEWLINE = /\n$/;
const ORDERED_LIST_REG_1 = /(^(?:-|[\da-zA-Z]\.) +.+\n?)+/m;
const ORDERED_LIST_REG_1 = /(^(?:[\da-zA-Z]\.) +.+\n?)+/m;
export const OrderedListRule: BlockMDRule = {
match: (text) => text.match(ORDERED_LIST_REG_1),
html: (match, parseInline) => {
@ -74,9 +74,9 @@ export const OrderedListRule: BlockMDRule = {
};
const UNORDERED_LIST_MD_1 = '*';
const U_LIST_ITEM_PREFIX = /^\* */;
const U_LIST_ITEM_PREFIX = /^([-*+]) */;
const U_LIST_TRAILING_NEWLINE = /\n$/;
const UNORDERED_LIST_REG_1 = /(^\* +.+\n?)+/m;
const UNORDERED_LIST_REG_1 = /(^([-*+]) +.+\n?)+/m;
export const UnorderedListRule: BlockMDRule = {
match: (text) => text.match(UNORDERED_LIST_REG_1),
html: (match, parseInline) => {