-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong parsing of emphasis and strong emphasis formatting #82
Comments
ProseMirror does not allow marks of the same type to be nested like this. I guess the markdown parser could be a bit more graceful about this (just ignoring the inner opening and closing strong tokens). |
Well one could workaround this as ProseMirror supports multiple marks of the same type if they have different attributes. Meaning you have to set e.g. something like this: function nesting(...types) {
const fn = (node) => {
let el = (node as HTMLElement).parentElement
let nesting = 0
while(el !== null) {
if ([...arguments].includes(el.tagName)) nesting++
el = el.parentElement
}
return {nesting: nesting}
}
return fn
}
// ... inside the schema:
marks: {
em: {
attrs: {
nesting: {
default: null
}
},
parseDOM: [
{tag: "i", getAttrs: nesting("EM", "I")},
{tag: "em", getAttrs: nesting("EM", "I")},
],
toDOM() { return ["em"] },
excludes: ''
},
strong: {
excludes: '',
attrs: {
nesting: {
default: null
}
},
parseDOM: [
{tag: "b", getAttrs: nesting("STRONG", "B")},
{tag: "strong", getAttrs: nesting("STRONG", "B")},
],
toDOM() { return ["strong"] }
},
} |
As two different markdown strings can be semantically the same, we can test if the resulting rendered HTML are syntactically equal. Currently about hundred test cases fail because of a known limitation of `prosemirror-markdown` not able to serialize nested marks correctly, see ProseMirror/prosemirror-markdown#82 Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
As two different markdown strings can be semantically the same, we can test if the resulting rendered HTML are syntactically equal. Currently about hundred test cases fail because of a known limitation of `prosemirror-markdown` not able to serialize nested marks correctly, see ProseMirror/prosemirror-markdown#82 Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
As two different markdown strings can be semantically the same, we can test if the resulting rendered HTML are syntactically equal. Currently about hundred test cases fail because of a known limitation of `prosemirror-markdown` not able to serialize nested marks correctly, see ProseMirror/prosemirror-markdown#82 Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
From CommonMark example 431:
should be parsed as:
Using just
markdown-it
this works as expected but thedefaultMarkdownParser
creates this incorrect representation:The text was updated successfully, but these errors were encountered: