Markup: Include file-content as part of markdown.

Created on 16 Aug 2014  路  139Comments  路  Source: github/markup

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

Most helpful comment

+1

All 139 comments

How would this work if the contents of the file changed? For example, if code/example.java no longer existed on master?

Thanks for the suggestion. See https://github.com/github/markup/issues/172#issuecomment-33241601.

This would be a very useful feature...

+1

Would be great for boilerplate or site/sub-section wide announcements or sections.

+1

+1

+1

+1

+1

+100000

+1

+1

+1

+1

+1
(and it would be great to select language for syntax highlighting for the contents as well)

+1

+1

+1

+1

+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

+1

+1

+1

+1

+1

+1

+1

+1

+1

For what it's worth I was giving this some consideration the other day and I think the only realistic way to implement such a thing is probably to have the resources be fetched as CLIENT SIDE includes.

The server would not pre-parse these 'extensions'. A page could opt into resolving them if it was in their best interest as a 'feature' with a small client side javascript.

For security this could be limited either strictly to same origins or with CORS/CSP outside of the libraries control.

+1

+1

I'd love any feedback on my proposal for a client-side extensions lib that would provide this

I have a simple use case. I have a file version.txt which contains the current version of my project. I want to be able to pull that version number into my markdown eg. so I can reference a particular version of my code in GitHub by its label in my README.md.

Thanks for your feedback - every bit will hopefully push this agenda along a bit!

+1 I would love to pull in my .env.example file

+1

+1

+1

+1

+1

+1

+1

+1

Bump

+1

+1

+1

+1

+1

To me the main benefit of not having WYSIWYG is being able to call in external files easily. I think if more markdown flavors included this it would be super helpful.

+1

+1

+1

+1

+1

+1

+1
it will be usefull

+1

+42

This is clearly something they never intend to address or even provide response to - it's just a ghost thread headed to nowhere.

CHOO CHOO ALL ABOARD THE GHOST TRAIN

/unsubscribe

It seems noone is paying attention to this thread so I have opened a new issue referencing this one:
https://github.com/github/markup/issues/1159

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1 :p

+1

+1

+1

+1

+1

+1

+1

+1

Would be nice. And this thread again makes me think why there's no user-voice-like "+1" voting system :man_shrugging:
Anyway: +1

+1

+1

+1

Surprised this isn't already a feature for Github Markdown.

+1

+1

+1

Would fix the exact problem I am having today.

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

As this issue is closed, I raised a while back this one which is still open so perhaps has slightly more chance of being noticed by GitHub: https://github.com/github/markup/issues/1159

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+100

+1

+1

An empty comment of "+1" adds nothing to any Github conversation.

If you would like to express gratitude for a comment, please use the 馃憤 feature created to avoid this exact issue.

<3 you all

I think the +1 is merely a way to spam the email of the maintainers to attract attention to a popular github feature request issue. If you just thumbs up someone's comment the maintainers do not receive a notification :) If the maintainers do not wish to pursue the request they can always lock the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieljabailey picture danieljabailey  路  4Comments

HI
madikhan1 picture madikhan1  路  3Comments

Alhadis picture Alhadis  路  6Comments

woodruffw picture woodruffw  路  6Comments

atomoton picture atomoton  路  7Comments