-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
docs(markdown): parse :::note's text as MD elements #32510
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
5acc78d
to
cdd5bd5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cdd5bd5
to
3bbd7de
Compare
This comment has been minimized.
This comment has been minimized.
6d335ea
to
85b9b49
Compare
85b9b49
to
0d97fc4
Compare
This comment has been minimized.
This comment has been minimized.
result.push(wrapText(node.text, options, indent)); | ||
const children = node.children || []; | ||
for (const child of children) | ||
innerRenderMdNode(indent, child, children[children.length - 1], result, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at other calls of innerRenderMdNode
, I think that lastNode
actually means previousNode
, so you should pass the previous node from the children
array.
@@ -802,12 +802,12 @@ function generateSourceCodeComment(spec) { | |||
node.codeLang = parseCodeLang(node.codeLang).highlighter; | |||
if (node.type === 'note') { | |||
// @ts-ignore | |||
node.type = 'text'; | |||
node.text = '**NOTE** ' + node.text; | |||
node.type = 'text' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no semicolons?
node.type = 'text'; | ||
node.text = '**NOTE** ' + node.text; | ||
node.type = 'text' | ||
node.text = `**NOTE** ` + (node.children || []).map(child => md.render([child], { flattenText: false, omitLastCR: true })).join('↵') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend adding a new rendering option renderNoteAs: '**NOTE** '
instead, and remove special handling of notes in this method entirely.
Test results for "tests 1"1 failed 35407 passed, 660 skipped Merge workflow run. |
Two ways of fixing it, either:
a) Pass
flattenText: falase
towrapText
's options, but it seems to come from high up and overriding it only for:::note
seems not great.b) Parse the
:::note
's children as real MarkdownNotes and render them as real notesI did b) in this case, which seems more reasonable.
Fixes #32505
Preview of the rolled docs: microsoft/playwright.dev#1503