mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 14:22:25 +03:00
Fix: "`` format" &
~~~` not counted as code block
This commit is contained in:
parent
118fa72ea9
commit
3f4c078bf2
1 changed files with 4 additions and 4 deletions
|
@ -11,13 +11,13 @@ export const HeadingRule: BlockMDRule = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const CODEBLOCK_MD_1 = '```';
|
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 = {
|
export const CodeBlockRule: BlockMDRule = {
|
||||||
match: (text) => text.match(CODEBLOCK_REG_1),
|
match: (text) => text.match(CODEBLOCK_REG_1),
|
||||||
html: (match) => {
|
html: (match) => {
|
||||||
const [, g1, g2] = match;
|
const [ , fence, lang, code ] = match;
|
||||||
const classNameAtt = g1 ? ` class="language-${g1}"` : '';
|
const classNameAtt = lang ? ` class="language-${lang}"` : '';
|
||||||
return `<pre data-md="${CODEBLOCK_MD_1}"><code${classNameAtt}>${g2}</code></pre>`;
|
return `<pre data-md="${fence}"><code${classNameAtt}>${code}</code></pre>`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue