diff --git a/docs/embed-files.md b/docs/embed-files.md index dab2efe4e..e9c5c545a 100644 --- a/docs/embed-files.md +++ b/docs/embed-files.md @@ -47,7 +47,7 @@ Sometimes you don't want to embed a whole file. Maybe because you need just a fe ``` In your code file you need to surround the fragment between `/// [demo]` lines (before and after the fragment). -Alternatively you can use `### [demo]`. +Alternatively you can use `### [demo]` or ``. Example: diff --git a/src/core/render/embed.js b/src/core/render/embed.js index 083fb7f97..89b37b18c 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -40,9 +40,8 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) { } else if (token.embed.type === 'code') { if (token.embed.fragment) { const fragment = token.embed.fragment; - const pattern = new RegExp( - `(?:###|\\/\\/\\/)\\s*\\[${fragment}\\]([\\s\\S]*)(?:###|\\/\\/\\/)\\s*\\[${fragment}\\]` - ); + const marker = `(?:(?:(?:###|\\/\\/\\/)\\s*\\[${fragment}\\])|(?:))`; + const pattern = new RegExp(`${marker}([\\s\\S]*)${marker}`); text = stripIndent((text.match(pattern) || [])[1] || '').trim(); }