Giter VIP home page Giter VIP logo

Comments (4)

nathanlesage avatar nathanlesage commented on May 18, 2024 1

I see where you get to but this is rather monkey patching-like. I'm not sure that's the best way. In the past months when I was developing Zettlr, I always resorted to monkey-patching. This way I could cramp into the app many features as quickly as possible, and now I'm stuck with a lot of code refactoring. Besides, a simple document.replace wouldn't suffice, as CodeMirror internally does a lot of stuff to the text before it is actually rendered. I guess we're stuck with two options:

  1. Manually adapt the gfm-mode to divide between the escaping character and the literal (which I would prefer)
  2. Add an option to either grey out both, or none of the characters.

As the gfm-mode itself is just a superset of the markdown-mode, maybe there's a way to override this behaviour manually. If so, I'll stick with this, but this requires some more research.

from zettlr.

nathanlesage avatar nathanlesage commented on May 18, 2024

Yep, this is a problem in the underlying Markdown parser from Codemirror, which does not differentiate between the escaping backlash and the literal character. It has annoyed me for some time myself. The problem would be that, if I manually alter the Markdown parser code then I won't be able to integrate CodeMirror updates so easily in the future, which is why I'm rather hesitant in doing this. I'll look into the chances of doing so!

from zettlr.

Jaifroid avatar Jaifroid commented on May 18, 2024

I see that the class cm-formatting-escape is applied to the whole text \[, so pure CSS wouldn't work.

But a combination of a regex like:

document = document.replace(/\\([[\]@])/ig, '\\<span class="nogrey">$1</span>');

together with a custom CSS rule for the nogrey class could work? Tested on Regex101: https://regex101.com/r/Jq7xVr/3

EDIT: Added @ to the regex (so it recognizes \@ as well as \[ and \]) and removed redundant backslash

from zettlr.

nathanlesage avatar nathanlesage commented on May 18, 2024

Tada!

from zettlr.

Related Issues (20)

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.