Comments (2)
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).
from prosemirror-markdown.
ProseMirror does not allow marks of the same type to be nested like this.
Well one could workaround this as ProseMirror supports multiple marks of the same type if they have different attributes. Meaning you have to set excludes: ''
for the marks em
and strong
and add a nesting attribute to them.
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"] }
},
}
from prosemirror-markdown.
Related Issues (20)
- Allow list items to start with other nodes than paragraphs HOT 2
- Unnecessary escape for the period (.) character HOT 3
- Inline code with `<` characters does not parse correctly (html inside inline code) HOT 2
- Unnecessary escape for `#` character HOT 2
- expelEnclosingWhitespace not working with inner links HOT 1
- What is the recommended method to update the src/schema.ts configuration in a project? HOT 1
- Mark's aren't serialized if root node isn't a block container HOT 2
- Markdown-It is not ESM HOT 4
- Punycode is now a hard-dependency? HOT 4
- Numbers in headers HOT 1
- Don' escape `+++` at the start of a line when serializing HOT 1
- Markdown parser combines two or more same autolink into a single anchor element HOT 3
- How to use with Tables? HOT 1
- Export default parser/serializer options HOT 2
- symbol | in table cells HOT 2
- Support passing in markdown-it `env` HOT 5
- Fenced code blocks does not check for backticks
- Handling of `softbreak` is weird HOT 4
- HTML entity unescaping on parse can lead to unexpected results on serialize HOT 5
- Add support for passing an extra env dictionary to the `MarkdownSerializer` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prosemirror-markdown.