Build markdown documents to HTML in the CI workflow#13432
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Thanks, this is the kind of thing we need. I wonder if we have a dependency on any particular flavor of markdown. I don't know what the current server uses, but it'd be good to check if that's the same as what's proposed here or not. Another consideration is that quite a few of our markdown files start their life as documents served by GitHub, and might be using various features of GitHub flavored markdown (which may or may not be preserved by the current server). If so, and if we want to support that, maybe using a tool like https://github.com/joeyespo/grip could help. |
Add a build step that converts .md files in spec directories (explainers, transition documents, proposals, etc.) to HTML so they're served from GitHub Pages. The legacy draft server that previously handled this conversion is struggling with ~60% uptime. Relates to #12054
0f2533a to
0ba88f8
Compare
|
@frivoal Short answer: I think what’s set up here now — using Python-Markdown — is the best choice and does everything y’all need, as far as supporting all markdown features in the sources here. So that’s what I’d recommend. Longer answer:
I think there are some markdown tables in some of the sources, and we need to fenced-code syntax-highlighting stuff. So for those, we need GitHub-flavored-markdown support. But the good news is: Python-Markdown supports those. See the bit of the change at https://github.com/w3c/csswg-drafts/pull/13432/files#diff-eeeae3642da5cedb2d38612b2e6193054b2171632b614a104842144be1b5f74eR31:
I think the only other tool to possibly consider is For Python-Markdown in contrast, we don’t need to do that. But anyway, as far as I can see, the only additional GFM feature that switching to But none of the existing markdown sources here are using those admonitions. Yet. So there’d be no reason in choosing That said, it would not be a big deal at all at some point later to update the build here to switch over to using Otherwise, all that said, as far as I can see, the choice really is just between Python-Markdown and |
|
I think we're fine. GH-flavored markdown's only real innovation is the NOTE/etc blocks, and those are done via an existing markup pattern that looks reasonable enough when rendered by a vanilla markdown renderer. |
|
Not to beat this into the ground, but for the record here: After looking into So there’d be zero point in using But there is one thing that does handle those GFM “alerts”: The GH API So, if at some point later y’all do find a need to use GFM features that Python-Markdown doesn’t support, then you could switch the build to using that GH API markdown endpoint. The main downside would be the obvious one: That it would requiring having network connection / being online. There’s also the fact that the API is rate limited, and the fact that the API requests are limited to the source markdown files needing to be 400KB or less. The rate limit and size limit would not be problems here in practice. But I reckon the requirement to have to be online could be a PITA. And it seems like there’d be no point in introducing an extra PITA for no real additional benefit. So yeah, I’d imagine all y’all and your contributors would agree that relying on Python-Markdown seems fine. |
I am more concerned about incompatibilities. Conpare the rendering of this file: I don't think I'm using any unique feature, but the way things get escaped, new lines get processed, etc, is different, and running the GH file through python is just broken. I could probably fix by adjusting the file, but if this explainer is broken, it may not be the only one… |
|
The legacy server used CommonMark |
Yipes yeah that’s awful
OK see #13448. https://github.com/readthedocs/commonmark.py appears to be archived and no longer maintained. So, switching the GitHub-supported CommonMark successor would seem to be the best choice. |
|
#13448 made things looks good now. Thanks. |
The legacy draft server converts
.mdfiles in spec directories (explainers, transition documents, proposals, etc.) to HTML. This adds that conversion to the GitHub Actions workflow so the files are served from GitHub Pages.A new
bin/build-markdown.pyscript finds all.mdfiles one level deep in spec directories and converts them to HTML using Python-Markdown, with a minimal stylesheet for readability. The workflow installs themarkdownpackage and runs the script after building specs.Relates to #12054