Closed kdheepak closed 12 months ago
Good suggestion, I'm currently kinda busy, but I'll take a look ASAP, it will be free until then! :heart:
No worries! Take your time!
btw, feel free to ignore the comment if you are busy. I'm just curious.
I see you've added a "good first issue" label. I'm fairly new to mdbook
so I don't know how you might go about handling this. But if you were to give me some direction, I'm happy to submit a PR.
I assumed you would have to pull in a dependency like pulldown_mark
to figure out whether you are in a codeblock or not, and decide whether to parse based on that. Do you have a simpler approach in mind?
We can use the pulldown_cmark
crate (preferably the same version that mdbook
uses) but that would slow down generation. An additional regex could be added for detecting pairs of codefences (```), and checking if the current match character position is in between one of those pairs would be pretty easy. It would also check that the type is "markdown" or "md". If you're experienced with Rust, it should be kinda easy.
If you don't feel comfortable trying this out, always feel free to say so! Solving this issue isn't a compromise :sweat_smile: and I'm always willing to help here.
I’m fairly comfortable in Rust! So I wouldn’t mind giving it a shot. I did go through the code and figured I could easily do it by splitting the content on triple backticks that start at the beginning of a line, and only splitting the logic to every alternate chunk.
I think there are some corner cases though. If someone has a quadruple back tick that wouldn’t work.
I guess I can special case for that and call it good enough? What do you think?
Yeah it's probably good enough, we can use some regex syntax to account for four or more backticks. Even then, it's a very uncommon case so I think it's good enough :+1:
I made a PR for this. It handles code blocks correctly imo, but does not handle admonish
codeblocks. I added a test showing what it does for admonish blocks (i.e. the same as normal codeblocks).
Thanks for making this plugin!
I would like to add the following section to a developer guide in a
mdbook
generated documentation:will render as the following:
I love cats :cat: and dogs :dog:, I have two, one's gray, like a raccoon :raccoon:, and the other one is black, like the night :night_with_stars:.