Include specific lines of code from a source file in Docusaurus
Asked Answered
A

0

6

I'm currently deciding whether to migrate my developer docs from Sphinx to Docusaurus. The one thing that's holding me back is that Docusaurus (and in fact Markdown in general) doesn't support pulling specific lines of text from other files.

Sphinx (reStructuredText) allows you to include text between a start-after and end-before marker on another file - so really useful for pulling in code snips from fully functioning scripts:

.. include:: ./scripts/matts_script.py
   :start-after: # marker_1
   :end-before: # marker_2

So is there a way of doing this in Docusaurus? Has anyone done it? I'm thinking maybe levaraging MDX and JSX but that's really just a guess.

Allsopp answered 15/8, 2022 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.