Open mgraham opened 8 years ago
I can convert to html with:
xsltproc -o xml/brownies.html xml/brownies.xml
Is that the best method?
If you want a final HTML file as output, using xlstproc would be a good method. I normally directly host the XML files, all modern browsers also do the conversion (if they can find the xslt file) since I wanted the XML files as the exchange format.
Regarding Latex: I know I put the note into the description, but everytime I do something with the code I forget to finally include the Latex template, I hope I'll have some time this weekend, then I'll push the Latex template stuff.
Interesting - I couldn't get my browser to render the XML properly. I'll fiddle with that.
Don't worry about LaTeX support on my account. My main end goal was to view the recipes on my Kindle. I'm using xlstproc to convert to HTML, and wkhtmltopdf to convert to PDF, and that works for me for now.
Now I need to hack together a more kindle-friendly template, but that's a different issue :)
@mgraham I also didn't see my browser rendering XML properly until I copied recipe2html.xslt
into the same directory as the XML being rendered -- that is to say:
recipe-markdown$ cp recipe2html.xslt xml/
But maybe you already did this, as without the XSLT in the right place, I get a warning running your xsltproc
command.
You're right - I did copy recipe2html.xslt over to the xml directory.
I tried again. It turns out that the XML recipe file renders properly in Firefox, but doesn't in Chrome or other Chrome-based browsers (qutebrowser, vivaldi). I think that's why I thought it wasn't working.
In any event, I did want the generated HTML for converting to other formats, so it was a worthwhile exercise for me to figure that out. Maybe a paragraph could be added to the documentation to indicate how to convert to other formats?
@mgraham Thanks for the hint, I'll add a paragraph to the docs for those that want finished html files. For your usecase: I anyhow used a template engine for some of the output, so your might as well directly generate your HTML files using that, and not do the step to XSLT at all, might be much easier. An HTML serializer would be pretty simple to write (just a call to jinja, as done for the index) and much less complex than having to deal with e.g. counting in XSLT.
I'll also add a note to the docs that the XSLT file needs to be copied over.
Interesting btw. that Chrome does not do the XSLT processing as Firefox, IE and Opera do. It should not work when using a filesystem path as the source of the XSLT (blocked due to security reasons), but it should if the XSLT & XML are served through the same webserver. I'll have to install Chrome and give it a try.
Btw. when you finish your Kindle template it would be great to see a sample, we have a Kindle and it might be quite a nice platform for recipes...
Ah - that might be what was going on! I wasn't accessing the files through a webserver - just on the local filesystem.
I've got a sample recipe in markdown format, and I've run
reprocess-all.py
to generate the XML.Now how do I get HTML or Latex out of the XML file?