Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: fix markdown parser swallowing lines after code snippets (#8904)

Dmitry Gozman6722d95a7a3a
diff --git a/docs/src/selectors.md b/docs/src/selectors.md
index c76f13d544..af5e66bee9 100644
--- a/docs/src/selectors.md
+++ b/docs/src/selectors.md
@@ -144,7 +144,7 @@ methods accept [`param: selector`] as their first argument.
```csharp
await page.ClickAsync(".login-button:visible");
```
- Learn more about [`:visible` pseudo-class](#selecting-visible-elements).
+ Learn more about [selecting visible elements](#selecting-visible-elements).
- Pick n-th match
```js
await page.click(':nth-match(:text("Buy"), 3)');
diff --git a/utils/markdown.js b/utils/markdown.js
index 936e586921..1054ea699c 100644
--- a/utils/markdown.js
+++ b/utils/markdown.js
@@ -33,7 +33,8 @@ function flattenWrappedLines(content) {
let outLineTokens = [];
for (const line of inLines) {
const trimmedLine = line.trim();
- let singleLineExpression = line.startsWith('#');
+ const singleLineExpression = line.startsWith('#');
+ const codeBlockBoundary = trimmedLine.startsWith('```') || trimmedLine.startsWith('---') || trimmedLine.startsWith(':::');
let flushLastParagraph = !trimmedLine
|| trimmedLine.startsWith('1.')
|| trimmedLine.startsWith('<')
@@ -43,7 +44,7 @@ function flattenWrappedLines(content) {
|| trimmedLine.startsWith('*')
|| line.match(/\[[^\]]+\]:.*/)
|| singleLineExpression;
- if (trimmedLine.startsWith('```') || trimmedLine.startsWith('---') || trimmedLine.startsWith(':::')) {
+ if (codeBlockBoundary) {
inCodeBlock = !inCodeBlock;
flushLastParagraph = true;
}
@@ -51,7 +52,7 @@ function flattenWrappedLines(content) {
outLines.push(outLineTokens.join(' '));
outLineTokens = [];
}
- if (inCodeBlock || singleLineExpression)
+ if (inCodeBlock || singleLineExpression || codeBlockBoundary)
outLines.push(line);
else if (trimmedLine)
outLineTokens.push(outLineTokens.length ? line.trim() : line);