markup icon indicating copy to clipboard operation
markup copied to clipboard

Include file-content as part of markdown.

Open kanuku opened this issue 12 years ago • 139 comments

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. }

kanuku avatar Aug 16 '14 09:08 kanuku

+1

fab2s avatar May 06 '17 12:05 fab2s

+1

mpires avatar May 08 '17 13:05 mpires

+1

zanderwar avatar May 12 '17 05:05 zanderwar

+1

irusri avatar May 13 '17 18:05 irusri

+1

Sixdd6 avatar Jun 02 '17 21:06 Sixdd6

+1

angeloocana avatar Jun 19 '17 20:06 angeloocana

+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.

bitelxux avatar Jun 28 '17 14:06 bitelxux

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)

elektronikworkshop avatar Jul 09 '17 15:07 elektronikworkshop

+1

ronenhamias avatar Jul 22 '17 11:07 ronenhamias

👍

cphoover avatar Jul 27 '17 21:07 cphoover

Any update on whether or not this is being considered?

ranguli avatar Jul 28 '17 12:07 ranguli

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

jayvdb avatar Jul 28 '17 12:07 jayvdb

+1

stopsopa avatar Aug 01 '17 21:08 stopsopa

+1

SimonDesautels avatar Aug 03 '17 17:08 SimonDesautels

+1

k0nze avatar Aug 05 '17 18:08 k0nze

+1

cederom avatar Aug 06 '17 20:08 cederom

+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

rigelrozanski avatar Aug 07 '17 05:08 rigelrozanski

+1

doughgle avatar Aug 18 '17 06:08 doughgle

+1

gabsn avatar Aug 18 '17 15:08 gabsn

+1

memoryhole avatar Aug 26 '17 08:08 memoryhole