Include file-content as part of markdown.
It would be great if we could include certain lines from another file to be showed inside a mardown file.
For example something like:
{5:12}(code/example.java)
Would result in including the specified java file, lines 5 to 12
05.
06. public static void main(String[] args) {
07.
08. system.out.println("Hello World!");
09.
10.
11.
12. }
+1
+1
+1
+1
+1
+1
+1
Instead of using from-line to-line, this could be inspired on how RestructuredText addresses it:
In RestructuredText you can do something like:
.. code-block:: python :startinline: true :linenos: true :linenos_offset: true :include: somesourcefile.py :start-after: # begining-regular-expression :end-before: # ending-regular-expression
Where :start-after: and :end-before: take a regular expression. That makes the snipet resiliant to changes in the code. Same approach could be used here.
Instead of defining the range in the markdown document you could mark a section in the code and refer to it via a reference. This way code changes won't affect the markdown (create invalid links, wrong line numbers etc)
+1
👍
Any update on whether or not this is being considered?
Note sphinx has a prolog and epilog http://www.sphinx-doc.org/en/stable/config.html#confval-rst_epilog This is starting to get implemented in other tools such as linters https://github.com/twolfson/restructuredtext-lint/issues/39
+1
+1
+1
+1
+1 Similarly, it would be awesome to reference the contents of a section from another markdown file. This would allow to easy cross reference any overlapping documentation (without needing to duplicate contents) from different markdown files within the same repo
+1
+1
+1