Code Monkey home page Code Monkey logo

Comments (7)

blyxyas avatar blyxyas commented on May 29, 2024 1

Good suggestion, I'm currently kinda busy, but I'll take a look ASAP, it will be free until then! ❤️

from mdbook-emojicodes.

kdheepak avatar kdheepak commented on May 29, 2024

No worries! Take your time!

from mdbook-emojicodes.

kdheepak avatar kdheepak commented on May 29, 2024

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?

from mdbook-emojicodes.

blyxyas avatar blyxyas commented on May 29, 2024

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 😅 and I'm always willing to help here.

from mdbook-emojicodes.

kdheepak avatar kdheepak commented on May 29, 2024

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?

from mdbook-emojicodes.

blyxyas avatar blyxyas commented on May 29, 2024

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 👍

from mdbook-emojicodes.

kdheepak avatar kdheepak commented on May 29, 2024

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

from mdbook-emojicodes.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.