Rendering of README.md inline with inner tree view dirs
Andy Green
andy at warmcat.com
Mon Jun 18 04:22:01 CEST 2018
On 06/17/2018 01:35 AM, John Keeping wrote:
> On Sat, Jun 16, 2018 at 03:12:09PM +0100, John Keeping wrote:
>> However, I'm not sure how to handle relative links: do we need to pass
>> additional parameters for this? Or can we rely on a render filter doing
>> the right thing?
>
> Modifying md2html to use the extension API is reasonably
> straightforward. Below is a modified version which remaps the "src"
> attribute on <img> elements according to a second command line argument,
> you can try it out with:
>
> md2html <README.md README.md /path/to/plain/directory/
>
> The trailing "/" is important.
>
> The differences are the AssetMapping classes at the top and the
> extension setup at the bottom; the rest is unchanged from the version in
> CGit's source tree.
>
> -- >8 --
> #!/usr/bin/env python3
> import markdown
> import sys
Thanks a lot for that... I patchified it under your name / email and
added your signed-off-by on it.
It works, but it's missing a trick, cgit URLs may have a postfix like
?h=branch which controls the context shown.
I added a patch-on-top of the python and another on the C to generate
and use prefix and postfix args.
Now it can show completely relative markdown assets in the correct
context seamlessly, served from git... so you can see easily the picture
in the v3.0-stable branch git
https://libwebsockets.org/git/libwebsockets/tree/README.md?h=v3.0-stable
has been updated in master
https://libwebsockets.org/git/libwebsockets/tree/README.md
...even though in both cases the markdown is
![lws-overview](./doc-assets/lws-overview.png)
...ie, is not contaminated with any virtual path, versioning or url
info... this is pretty nice!
-Andy
More information about the CGit
mailing list