Closed encukou closed 5 years ago
And from there:
If we would like to convert all the links, it would probably be easier to do it once we have the resulting HTML, regardless of how it was generated. I.e. put it to (the end of) Page.render_html().
I'm warming up to the idea, as we might want to parse the HTML anyway for security (tag whitelisting).
I believe @mikicz is doing something like that.
In a previous version of my thesis implementation that was true, I was parsing all the rendered HTML to get URLs that should be frozen. However, since we last talked, I scratched that and I'm only parsing the HTML that's returned from forks to check for allowed/disallowed elements and styles. (I figured out a way to get relative URLs while also getting them registered in the freezer and how to implement the url_for
logger in forks to get all the generated URLs in forks)
Naucse now forbids relative links – content "doesn't know" how it's displayed; all URLs are generated in naucse.
Instead, content can use the naucse://
URL scheme. (Docs are lacking, ask for details if interested.)
Making links like ../../category/lesson/
work as in GitHub preview is for naucse_render
, which has a rewrite_relative_url function. It's far from perfect, but I don't think perfecting it is important enough to track here.
My current thinking is that, as far as possible, Markdown relative links should work in GitHub preview, but use
url_for
when rendered.[...](../../category/lesson/)
should link tolesson_url('category/lesson')