mirror of https://github.com/usememos/memos
fix(web): disable setext header syntax (#5314)
Add custom remark plugin to prevent setext headers (headers using === or --- underlines) from being recognized by the markdown parser. The plugin disables the setextUnderline construct at the micromark parser level. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>pull/5332/head
parent
1cf047707b
commit
48ce4ccc26
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Remark plugin to disable setext header syntax.
|
||||
*
|
||||
* Setext headers use underlines (=== or ---) to create headings:
|
||||
* Heading 1
|
||||
* =========
|
||||
*
|
||||
* Heading 2
|
||||
* ---------
|
||||
*
|
||||
* This plugin disables the setext heading construct at the micromark parser level,
|
||||
* preventing these patterns from being recognized as headers.
|
||||
*/
|
||||
export function remarkDisableSetext(this: any) {
|
||||
const data = this.data();
|
||||
|
||||
add("micromarkExtensions", {
|
||||
disable: {
|
||||
null: ["setextUnderline"],
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a micromark extension to the parser configuration.
|
||||
*/
|
||||
function add(field: string, value: any) {
|
||||
const list = data[field] ? data[field] : (data[field] = []);
|
||||
list.push(value);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue