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

This commit is contained in:
Dmitry Gozman 2021-09-13 18:48:16 -07:00 committed by GitHub
parent 1925c85dfb
commit 6722d95a7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -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)');

View File

@ -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);