leahneukirchen / trivium

Trivium, my minimalist blogging engine
http://chneukirchen.org/trivium/
39 stars 6 forks source link

Relative URL for image without defining xml:base #1

Open skn opened 3 years ago

skn commented 3 years ago

Bluecloth does not add absolute path to the img src when parsing markdown (I guess it can't to it in a generic manner without some sort of extra wrapper support) for the content.

This means that xml:base need to be explicitly stated in the atom feed template at the highest level or per entry.

As per RFC: Any element defined by this specification MAY have an xml:base attribute [W3C.REC-xmlbase-20010627]. When xml:base is used in an Atom Document, it serves the function described in section 5.1.1 of [RFC3986], establishing the base URI (or IRI) for resolving any relative references found within the effective scope of the xml:base attribute.
skn commented 3 years ago

If xml:base is added, another thing to keep in mind as per the feed validator is to handle Self Document Reference https://validator.w3.org/feed/docs/warning/SameDocumentReference.html

skn commented 3 years ago

Even after the proposed changes though, it is only one part of the solution. The other part on the side of rss readers is a pain sometimes https://community.tt-rss.org/t/xml-base-not-honored-when-resolving-relative-uris-in-atom-entrys-content/4664

Any elegant way to force bluecloth to insert absolute path for inline images (line: 1087 bluecloth.rb) than to hardcode the base URL?

leahneukirchen commented 3 years ago

Yes, xml:base is ignored by many RSS readers. I don't have a solution for trivium, you can maybe reuse this ancient code from 2004: https://leahneukirchen.org/repos/nukumi2/_darcs/current/lib/nukumi2/rewritelinks.rb