Skip to content

Conversation

@abitrolly
Copy link
Contributor

Also use plain include directive

Also use plain `include` directive
Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this improves editor support?

@abitrolly
Copy link
Contributor Author

And also clears the confusion that such diagrams are possible with pure markdown. )

@joerick
Copy link
Contributor

joerick commented Dec 13, 2023

Aah, i think i remember why i didn't do this. HTML is valid in markdown, but HTML blocks in markdown files can't have multiple newlines or the markdown parser starts to fiddle with it and insert <p> blocks or similar. So it has to be a single contiguous block without extra space in it. So we can't really think of it as regular HTML. Additionally, regardless of the file extension, the code is run through the markdown parser, as it's inserted verbatim into a markdown file, so the markdown quirks do apply in this file.

@abitrolly
Copy link
Contributor Author

I am not sure included files are additionally processed, asked here - mondeja/mkdocs-include-markdown-plugin#187

It is not clear if the include is done before markdown is parsed and converted, or after.

@joerick
Copy link
Contributor

joerick commented Dec 13, 2023

The plugin works on the markdown before it's parsed by mkdocs.

@abitrolly
Copy link
Contributor Author

@joerick mondeja/mkdocs-include-markdown-plugin#187 (comment) the answer is that no processing is done.

@joerick
Copy link
Contributor

joerick commented Dec 19, 2023

i'm pretty sure that he is saying that the plugin doesn't do any processing. But the plugin is working at the markdown level, mkdocs will still process it into HTML later.

@abitrolly
Copy link
Contributor Author

Asked for additional clarification.

@mondeja
Copy link
Contributor

mondeja commented Dec 20, 2023

The change makes sense to me, see this explanation: mondeja/mkdocs-include-markdown-plugin#187 (reply in thread)

@joerick
Copy link
Contributor

joerick commented Dec 20, 2023

Ah, I think I get it. I had the idea that multiple newlines broke markdown's parsing of HTML blocks, but I think this is where markdown parsers vary. In my editor, HTML blocks in markdown files have to be continuous, otherwise they don't preview/format correctly:

code breaks

But I just tested it and it seems that mkdoc's markdown parser doesn't have the same limitation (agreeing with @mondeja's analysis).

(I suppose from a purity point of view, a pure HTML include directive would be cool, but it might also be a can of worms and including HTML-in-md seems to be working fine here.)

@joerick joerick merged commit 6e2f4c0 into pypa:main Dec 20, 2023
@abitrolly abitrolly deleted the diagram-html branch December 20, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants