-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Open
Description
Feature request
It seems like the "Embed code fragments" feature only works for code, but it would be nice to generalize it to include rendered Markdown.
What problem does this feature solve?
I would like to generate a single file with a bunch of snippets like:
/// [chunk1]
<p>Chunk 1</p>
/// [chunk1]
/// [chunk2]
<p>Chunk 2</p>
/// [chunk2]
And then in the relevant page, be able to do
[chunk](./chunks.md ':include :fragment=chunk1')
What does the proposed API look like?
See above
How should this be implemented in your opinion?
Break out this block into a function resolveFragment(token, text: string) => string
docsify/src/core/render/embed.js
Lines 49 to 55 in c49c39a
if (token.embed.fragment) { | |
const fragment = token.embed.fragment; | |
const pattern = new RegExp( | |
`(?:###|\\/\\/\\/)\\s*\\[${fragment}\\]([\\s\\S]*)(?:###|\\/\\/\\/)\\s*\\[${fragment}\\]` | |
); | |
text = stripIndent((text.match(pattern) || [])[1] || '').trim(); | |
} |
Call the function in every conditional block immediately before passing text
to embedToken
Are you willing to work on this yourself?
Sure
Metadata
Metadata
Assignees
Labels
No labels