Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Sep 9, 2024

Two ways of fixing it, either:

a) Pass flattenText: falase to wrapText'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 notes

I did b) in this case, which seems more reasonable.

Fixes #32505
Preview of the rolled docs: microsoft/playwright.dev#1503

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the fix-markdown-notes branch 2 times, most recently from 5acc78d to cdd5bd5 Compare September 9, 2024 08:37

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the fix-markdown-notes branch 3 times, most recently from 6d335ea to 85b9b49 Compare September 11, 2024 12:16

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);
Copy link
Contributor

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'
Copy link
Contributor

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('↵')
Copy link
Contributor

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.

Copy link
Contributor

Test results for "tests 1"

1 failed
❌ [playwright-test] › babel.spec.ts:135:5 › should not transform external

35407 passed, 660 skipped
✔️✔️✔️

Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs]: NOTE in the Introduction / Clock page
2 participants