-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Support nested code blocks and blockquotes in lists #40
Comments
What you want is not possible, and it is not needed. Lists have list items. On GH too. You cannot remove the list items. And you do not need to. The block quote is inside the item. On GH too. import {fromMarkdown} from 'mdast-util-from-markdown'
import {removePosition} from 'unist-util-remove-position'
const document = `1. milk
> banana
2. cheese`
const tree = fromMarkdown(document)
removePosition(tree, {force: true})
console.dir(tree, {depth: null}) {
type: 'root',
children: [
{
type: 'list',
ordered: true,
start: 1,
spread: false,
children: [
{
type: 'listItem',
spread: false,
checked: null,
children: [
{
type: 'paragraph',
children: [ { type: 'text', value: 'milk' } ]
},
{
type: 'blockquote',
children: [
{
type: 'paragraph',
children: [ { type: 'text', value: 'banana' } ]
}
]
}
]
},
{
type: 'listItem',
spread: false,
checked: null,
children: [
{
type: 'paragraph',
children: [ { type: 'text', value: 'cheese' } ]
}
]
}
]
}
]
} |
This comment has been minimized.
This comment has been minimized.
Thanks you @wooorm , that construction you got works for me! const tree: Parent = fromMarkdown(text, {
extensions: [gfmStrikethrough(), gfmTable(), gfmTaskListItem()],
mdastExtensions: [gfmTableFromMarkdown(), gfmStrikethroughFromMarkdown(), gfmTaskListItemFromMarkdown()],
}) as Parent; But got the tree different from yours: tree {
type: 'root',
children: [
{
type: 'list',
ordered: true,
start: 1,
spread: false,
children: [Array],
position: [Object]
},
{ type: 'blockquote', children: [Array], position: [Object] },
{
type: 'list',
ordered: true,
start: 2,
spread: false,
children: [Array],
position: [Object]
}
],
position: {
start: { line: 1, column: 1, offset: 0 },
end: { line: 4, column: 1, offset: 29 }
}
} Do you know how this happened? Huge thanks! |
Can you show the actual code and versions? I am quite sure |
And make your reproduction smaller: remove everything that is not needed. Remove every extension that’s not needed. |
weird, If I pass in the string you used directly, I can get the same result as yours. If I read the markdown from another md file, I will get the incorrect result. |
It’s not weird, it’s well specified! ;) It’s the difference between 2 spaces and a tab. In markdown, that tab there is worth 4 spaces. You do not use enough spaces. 1. milk
> banana Same with this, 1 is not enough: 1. milk
> banana Same, 2 is not enough: 1. milk
> banana Because 1. milk
> banana |
Thank you very much! It works now:) |
Initial checklist
Problem
Hi team,
Is it possible to support such structural conversion?
Expect
Actual
The markdown works fine in GitHub
Solution
None
Alternatives
None
The text was updated successfully, but these errors were encountered: