mystmd
mystmd copied to clipboard
Support including only part of a file with the `{include}` directive
Currently, you can use {literalinclude} to include only a subset of a file for inclusion. For example, based on line number of text match.
It would be useful if the same were possible for {include}. This allows you to re-use subsets of content via {include}, which is particularly useful if you'd like a markdown file to be readable outside of MyST (like in GitHub) but also used within MyST as well.
Here's a PR where we're trying to use this to have CONTRIBUTING.md be re-usable for MyST:
- https://github.com/executablebooks/mystmd/pull/1095
Here's a testimonial from one user that mentions how this is useful:
From @LecrisUT:
In order to better display these links, I suggest to use reference-style link, i.e.
[Text to display][link-id] [Link-id]: /path/to/objectCombined with
includewithstart-afterend-before, you can use html comments like<!-- MYST-START -->to separate the text part from the actual link and haveinv:style links in the html document and actual links in the Github rendered view.Hope such design works in
mystmdas well. Might depend on the order of markdown renderingExample: https://github.com/LecrisUT/CMake-Template/blob/main/README.md?plain=1