Fossil Forum

jan 4 days, 18 hours ago

Post: Include snippets in markdown

In mdBook, there's an extension to markdown to allow insertion of code, using the {{#include ..}} syntax. I use this frequently when I want to insert a code example, but I don't want to duplicate the code:



{{#include ../examples/some_config.toml}}

Is there anything similar in fossil's markdown, that can include files from within the repository itself? If not, how controversial would such a feature be? (I'm only asking about the feature, not the syntax).

stephan 4 days, 15 hours ago

Is there anything similar in fossil's markdown that can include files from within the repository itself?

Nope.

If not, how controversial would such a feature be? (I'm only asking about the feature, not the syntax).

From within the repository, the controversial part would probably be finding a syntax which won't break existing downstream markdown-format docs. (That's why the recent "hashtag" support was removed: downstream docs use hashtag-like constructs in ways which that feature broke.)

Importing files from outside the repo would be a non-starter, on security grounds at a minimum.

spindrift 4 days, 12 hours ago

Don't do this. But if you wanted to make your life miserable, you could try combining eg

<div><object data="src:docs/file.txt"></object></div>

With

https://fossil-scm.org/home/help/safe-html

But... just don't.

droleary 4 days, 11 hours ago

I had the same need recently (the repos discussed in this forum post share content), and I found the best approach for my needs was to dust off m4. It allows me to write mostly stock Markdown, and then easily process it to the "full" static .md my site otherwise uses. If you really needed something dynamic, I'm sure you could leverage the CGI handling of Fossil to do that live. Anyway, here's how your example might translate if done as an .m4 file:


changequote(`{{', `}}')dnl


include({{../examples/some_config.toml}})dnl

There are plenty of other similar approaches to be sure. In general, I'm not really a big fan of "ad hoc"-ing features into informal standards, though. If there's a true Fossil-native solution to be had, it probably involves something based on TH1.

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button