Re: Relative links in github vs firefox extension
Posted by
mojavelinux on
URL: https://discuss.asciidoctor.org/Relative-links-in-github-vs-firefox-extension-tp3011p3077.html
Welcome Xavier!
In my firefox extension, this works nicely
[source, json]
----
include::adapters/.jshintrc[]
----
but the problem is in github.
This is a known issue. It's also known that the link shows in source form instead a listing block since substitutions are not processed. I tried to fix this issue, but it turns out to be a bit more complex than expected since the include directive isn't aware of the context (it doesn't know it's inside a listing block).
One solution to the problem is to use a conditional directive to hide content on GitHub and perhaps do something different:
----
ifdef::env-github[]
do something on GitHub
endif::[]
ifndef::env-github[]
do something when not on GitHub
endif::[]
----
But a better solution to the problem--one I've been contemplating for some time--is to have two documents...one is the raw source and one the expanded source. You can use a build (like Rake or Gradle) to expand the raw source (essentially processing includes) automatically and push the result to GitHub whenever a change is made to the raw source.
In short, you'd be doing a publishing step, except you are publishing the expanded AsciiDoc source instead of the HTML. It's not super elegant, but it might allow you to use includes while still using GitHub. The end users would never know ;)
Cheers,
-Dan