Files
note2any/src/markdown/empty-line.ts
2025-10-08 09:18:20 +08:00

29 lines
767 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 文件markdown/empty-line.ts — 解析与处理空行样式的 markdown 规则。 */
import { Tokens, MarkedExtension } from "marked";
import { Extension } from "./extension";
export class EmptyLineRenderer extends Extension {
markedExtension(): MarkedExtension {
return {
extensions: [{
name: 'emptyline',
level: 'block',
tokenizer(src: string) {
const match = /^\n\n+/.exec(src);
if (match) {
console.log('mathced src: ', src)
return {
type: "emptyline",
raw: match[0],
};
}
},
renderer: (token: Tokens.Generic) => {
return '<p><br></p>'.repeat(token.raw.length - 1);
},
}]
}
}
}