Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the include directive on GitHub #1088

Closed
mojavelinux opened this issue Sep 13, 2014 · 11 comments
Closed

Support the include directive on GitHub #1088

mojavelinux opened this issue Sep 13, 2014 · 11 comments
Labels

Comments

@mojavelinux
Copy link
Member

We'd like to find a way to support includes on GitHub in a way that works within the boundaries of the security requirements. This issue is intended to plan for and track the progress on this upstream request.

@mojavelinux mojavelinux changed the title Support include on GitHub Support the include directive on GitHub Sep 23, 2014
@ciarand
Copy link

ciarand commented Mar 22, 2015

Is there any way to preprocess include directives?

i.e. a project with these files:

// foo.adoc
foo
// bar.adoc
bar
// README.pre.adoc
include::foo.adoc
include::bar.adoc

And running something like this:

$ asciidoctor <some magic flag> README.pre.adoc -o README.adoc

Will generate a file named README.adoc that looks like this:

foo
bar

Is this a thing that exists?

@mojavelinux
Copy link
Member Author

Indeed. I wrote a coalescer script and put it in the extensions-lab repository.

See https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/scripts/asciidoc-coalescer.rb

Does that suit your needs? This might be nice to have either as an cli in Asciidoctor or as a separate project.

@ciarand
Copy link

ciarand commented Mar 30, 2015

This is fantastic, thanks @mojavelinux.

@MarkCallow
Copy link

What are the issues with the way the include directive currently works and GitHub's security requirements? It is hard to make any useful suggestions in the absence of that background.

My use is for including fragments of some of my source files (.c, .cpp, .frag, .vert, etc.) in docs such as tutorials that are describing the code. I would really like to not have to manually regenerate documents anytime the code changes.

Could the coalescer script be run in a push hook on GitHub or would that violate their security requirements too?

@miltador
Copy link

Any updates on this?
Lacking support of includes on GitHub limits asciidoctor usage and maintaining a lot of documentation is harder than it could be 😫 . Wonder if I can help with this.

@mojavelinux
Copy link
Member Author

mojavelinux commented Jul 18, 2017

While I absolutely agree that not having the include directive on GitHub is a huge pain, there is at least one approach that makes it somewhat workable.

What you do is have a CI job come through an run a script that expands include directives so you get something like this in the file afterwards:

ifndef::env-github[]
include::file-to-include.ext[]
endif::[]
ifdef::env-github[]
contents of include file get added here
endif::[]

The part inside of ifdef::env-github[] would be auto-generated and not something the author would ever touch.

(Once the 1.5.6 upgrade happens, you can reduce the ifndef clause to a single line).

Again, this is far from ideal, but at least it would allow you to leverage the include directive and still have it display properly on GitHub. But you would need to set up an automated task that expands the include files in place.

@mojavelinux
Copy link
Member Author

Could the coalescer script be run in a push hook on GitHub or would that violate their security requirements too?

That's definitely allowed and exactly what I had in mind.

@miltador
Copy link

miltador commented Aug 21, 2017

What if to implement a limited include::s mode which will allow to only include other asciidoc files with aggressive bounds to the current working directory so user cannot do infinite ../.. or / to other directories? And maybe some other rules, so it can be considered to be turned on in safe mode?

I know that including any file can be a security problem, but including other asciidoc files that are rendered the same way should not be a problem. Github is rendering any single asciidoc file anyway, why not to render asciidoc inside asciidoc?🤔

@mojavelinux
Copy link
Member Author

mojavelinux commented Aug 21, 2017

The custom include processor enables us to do that exactly. The problem we're currently dealing with is that GitHub has not yet shown a willingness to discuss this. I am ready for that conversation any day.

@datainvestor
Copy link

Any change this might be implemented in near future?

@mojavelinux
Copy link
Member Author

This is not something we have any control over. It's up to GitHub to enable it. We've given them the code. Now it's on them to enable it. See github/markup#1095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants