docs: fix markdown parser swallowing lines after code snippets (#8904)
This commit is contained in:
parent
1925c85dfb
commit
6722d95a7a
|
|
@ -144,7 +144,7 @@ methods accept [`param: selector`] as their first argument.
|
||||||
```csharp
|
```csharp
|
||||||
await page.ClickAsync(".login-button:visible");
|
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
|
- Pick n-th match
|
||||||
```js
|
```js
|
||||||
await page.click(':nth-match(:text("Buy"), 3)');
|
await page.click(':nth-match(:text("Buy"), 3)');
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ function flattenWrappedLines(content) {
|
||||||
let outLineTokens = [];
|
let outLineTokens = [];
|
||||||
for (const line of inLines) {
|
for (const line of inLines) {
|
||||||
const trimmedLine = line.trim();
|
const trimmedLine = line.trim();
|
||||||
let singleLineExpression = line.startsWith('#');
|
const singleLineExpression = line.startsWith('#');
|
||||||
|
const codeBlockBoundary = trimmedLine.startsWith('```') || trimmedLine.startsWith('---') || trimmedLine.startsWith(':::');
|
||||||
let flushLastParagraph = !trimmedLine
|
let flushLastParagraph = !trimmedLine
|
||||||
|| trimmedLine.startsWith('1.')
|
|| trimmedLine.startsWith('1.')
|
||||||
|| trimmedLine.startsWith('<')
|
|| trimmedLine.startsWith('<')
|
||||||
|
|
@ -43,7 +44,7 @@ function flattenWrappedLines(content) {
|
||||||
|| trimmedLine.startsWith('*')
|
|| trimmedLine.startsWith('*')
|
||||||
|| line.match(/\[[^\]]+\]:.*/)
|
|| line.match(/\[[^\]]+\]:.*/)
|
||||||
|| singleLineExpression;
|
|| singleLineExpression;
|
||||||
if (trimmedLine.startsWith('```') || trimmedLine.startsWith('---') || trimmedLine.startsWith(':::')) {
|
if (codeBlockBoundary) {
|
||||||
inCodeBlock = !inCodeBlock;
|
inCodeBlock = !inCodeBlock;
|
||||||
flushLastParagraph = true;
|
flushLastParagraph = true;
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +52,7 @@ function flattenWrappedLines(content) {
|
||||||
outLines.push(outLineTokens.join(' '));
|
outLines.push(outLineTokens.join(' '));
|
||||||
outLineTokens = [];
|
outLineTokens = [];
|
||||||
}
|
}
|
||||||
if (inCodeBlock || singleLineExpression)
|
if (inCodeBlock || singleLineExpression || codeBlockBoundary)
|
||||||
outLines.push(line);
|
outLines.push(line);
|
||||||
else if (trimmedLine)
|
else if (trimmedLine)
|
||||||
outLineTokens.push(outLineTokens.length ? line.trim() : line);
|
outLineTokens.push(outLineTokens.length ? line.trim() : line);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue