chirun-ncl / chirun

A Python package providing the command line interface for building flexible and accessible content with Chirun.
https://chirun.org.uk/
Other
29 stars 4 forks source link

Markdown - HTML image doesn't load #234

Open prowlett opened 2 months ago

prowlett commented 2 months ago

Say I have a Markdown page with an image.

![image](image.png)

I think the HTML version displays the image at the width of the image or width: 100% if this does not fit.

Say I would like to display it smaller (say because I'd like to fit more than one on a line). I can't specify the width in Markdown, the advice seems to be to give Markdown the HTML that will do this.

<img src="image.png" style="width: 50%;">

The Markdown preview in VSCodium renders this how I would expect:

image

In chirun's HTML output, this happens:

image

The good news is, it's half the width. But it's looking for a local file image.png which doesn't exist. chirun output "127.0.0.1 - - [10/Apr/2024 15:02:21] code 404, message File not found".

I think this might be pretty hard to deal with (lots of edge cases) but since it's a standard piece of advice when hitting a Markdown limitation I thought I'd mention it. I have no particular need for this to be fixed urgently, since I dealt with my need a different way.

christianp commented 2 months ago

We should definitely resolve this.

Looking at the code, it seems that the image processor is implemented as a markdown extension, so only runs on images with the ![...](...) syntax. I think that it should move to the HTML processing step, so any <img> tag, whether it was hardcoded or produced by markdown, would be processed.