Closed phillord closed 4 years ago
That would be terrific.
So, this was implemented with https://github.com/owickstrom/pandoc-include-code/pull/36 and merged recently. You can have a look at the documentation at https://github.com/owickstrom/pandoc-include-code#adding-direct-links and https://github.com/owickstrom/pandoc-include-code#adding-base-url-for-all-codeblock-links but let me add a quick example below.
Let's assume you have
code/hello_world.py
: print("Hello World")
in.md
---
title: A simple test
---
```{include=python/hello_world.py .includeLink}
then
```{.bash}
pandoc --filter pandoc-include-code in.md -o out.html
will give you
You can tweak the base of the link (cf. the documentation I've linked before) and tweak the style for html output. For instance, if you have a style.css
file:
a.includeCodeLink{text-align: right; display:block; font-style: italic}
a.includeCodeLink::after, a.includeCodeLink::before{display:inline-block; color:black; text-decoration:none;}
a.includeCodeLink::after{content:")"}
a.includeCodeLink::before{content: "(From:\00A0"}
then
pandoc -s --css style.css --filter pandoc-include-code -M base=http://localhost:8000/ in.md -o out.html
(assuming I also want to change the base) would give
A feature request! I'd like to be able to hyperlink to the original source in linkable formats (HTML and PDF specifically). So the output would be
Which would output something that looks like:
print("Hello World") (from hello_world.py)
To make this work portably, there would probably need to be some way of saying where the base link is -- otherwise, links in standalone formats (PDF or standalone HTML) would break.
Just a thought!