Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert to HTML or Latex? #9

Open
mgraham opened this issue Apr 12, 2016 · 7 comments
Open

How to convert to HTML or Latex? #9

mgraham opened this issue Apr 12, 2016 · 7 comments
Assignees

Comments

@mgraham
Copy link

mgraham commented Apr 12, 2016

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?

@mgraham
Copy link
Author

mgraham commented Apr 12, 2016

I can convert to html with:

xsltproc -o xml/brownies.html xml/brownies.xml

Is that the best method?

@andreasWallner
Copy link
Owner

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.

@mgraham
Copy link
Author

mgraham commented Apr 16, 2016

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 :)

@IamJeffG
Copy link
Contributor

@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.

@mgraham
Copy link
Author

mgraham commented Apr 18, 2016

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?

@andreasWallner
Copy link
Owner

andreasWallner commented Apr 25, 2016

@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...

@mgraham
Copy link
Author

mgraham commented Apr 25, 2016

Ah - that might be what was going on! I wasn't accessing the files through a webserver - just on the local filesystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants