Repository navigation
Conversation
|
Looks like a good start. One thing that concerns me is that the Markdown is rendered to HTML too soon. If/when a plugin API is added, I anticipate a hook being provided prior to each page being built which means the HTML should not be rendered until build time. I realize that it is rendered early because that is how you are getting the meta-data for each page. And yes, that info should already be available before the pre-build hook. Of course, those two things are in direct opposition to each other. However, I recommend that the Python-Markdown's Meta-Data Extension not be used. Instead extract the meta-data early (perhaps using docdata), and save the meta-data and the markdown source (with the meta-date removed) as two separate attributes in the Page instance. The way, the Markdown source can be used later to render the HTML just before building the page, but after the pre-build hook. If you don't want to add another dependency, I give permission to include the relevant parts of docdata directly in MkdDocs. Or you are welcome to use some other implementation of your choice or creation. An interesting side-affect will be that the code which calls Markdown will still be in |
+1 to this. Personally, I have never found the meta extension to be all that useful as I want the meta data before I parse. Usually, by time I've parsed is too late for me to use the meta for what I want. |
|
Great, I'm glad you both said this because I was struggling with it too. It did indeed feel a bit strange to render the Markdown so early.
@waylan Great - thanks! I am a bit hesitant to include another dependency, just because of the effort recently we had to do to remove two (six and ghp-import). So I might take this approach, initially I'll try a prototype with the dependency and see how that goes. |
1fb2bfe to
a303fd1
Compare
|
Updated. I think this generally does make much more sense. Unfortunately, most of the tests still break as they are broken due to how I changed the internal pages structure. This PR changes it so that we convert from string paths to page objects as soon as possible. The previous was was quite delayed and the tests took advantage of this to easily define a set of pages as a list of strings. |
|
... and because we load the pages when we do now, it verifies they all exist. A bunch of tests have fake paths to markdown files because they never tested the build process. /me sighs |
There was a problem hiding this comment.
Within the template I would expect the html_content, toc, and meta to all be attributes of the page object. I realize that may involve so template refactoring and this is prototyping right now, but I think that is we're this needs to go.
There was a problem hiding this comment.
Yeah, I agree. In my previous version I had added it to the template, but left it available via the old names too to avoid updating all the templates at the same time.
56b1fb6 to
1bd9aa7
Compare
1bd9aa7 to
d9c5a7f
Compare
There was a problem hiding this comment.
This needs to be implemented 😄 Given Markdown as a string, it should return the first Header (h1/#). Thoughts about a reasonable approach?
d9c5a7f to
544d736
Compare
|
@tkirill Yup, this re-factoring would enable #316 (it actually almost includes the implementation) and a number of other things we want to do. @waylan is correct that the above comments and check list in the description here are the outstanding tasks. If you want to try any of them, I'd suggest making pull requests against my fork and then they can be merged in and included here. Stick to one per commit to make things easier to review if you can. |
This change updates the Markdown loading to load all the documents at startup. This gives us much more flexibility when we want to reference other Markdown files or use the metadata from a Markdown file earlier in the build.
Remaining tasks:
Original text below the line.
This needs a bunch of works and it breaks loads of the tests, but it works quite well. It gets the page title from the Markdown if it isn't provided in the mkdocs.yml.
Feedback very welcome, it is a bit rough at the moment tho'
See #316