Code Monkey home page Code Monkey logo

Comments (15)

iamrecursion avatar iamrecursion commented on June 20, 2024 4

I have a PR open #1263 that fixes this.

While there was some work to fix the dynamic loading and unloading of the highlighter, the basic issue came from the fact that 1.5.x changed the priority for the default hypermd highlighter, and hence the extension here was getting loaded below it. Bumping the priority was all that was needed in this case.

from templater.

I-Pch avatar I-Pch commented on June 20, 2024 4

I just really need to say this 😄 :

Thank you so so so very much to the both of you @iamrecursion and @Zachatoo for fixing this 🙌 🥳 !!!

It works perfectly on Desktop (Obsidian 1.5+) and Mobile (Obsidian 1.4.16) 🎉 !!!

from templater.

Zachatoo avatar Zachatoo commented on June 20, 2024 3

Can reproduce, will investigate. Thanks!

from templater.

Zachatoo avatar Zachatoo commented on June 20, 2024 3

Released in 2.0.0 of Templater! Thank you so much @iamrecursion !

Note: Syntax highlighting will not work on mobile if you sync your vault between desktop and mobile and are therefore able to install the latest version of Templater on your mobile device. I do not think this is a concern. If you're syncing between desktop and mobile, you can manage your templates on desktop if you want syntax highlighting until mobile reaches Obsidian 1.5.x feature parity.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024 2

According to some discussions I've had internally, the removal of CM5 has resulted in cm.setOption used here no longer working. Templater uses it to toggle the highlight mode on and off.

Strangely enough, this should never have worked on mobile, but I cannot see where else in the codebase the mode would be handled for mobile specifically.

The syntax is created here as an overlay on HyperMD, and is defined correctly using StreamParser as best I can tell. One thing that isn't clear to me is whether StreamParser is sufficient as an Extension itself in CM6 terms. Perhaps it needs to be wrapped in a ViewPlugin.define.

from templater.

mProjectsCode avatar mProjectsCode commented on June 20, 2024 2

It might be worthwhile to port the syntax highlighting to a CM6 View Plugin that creates mark decorations. That approach should be a lot simpler, more powerful and future-proof. I am using such an approach in Meta Bind.

I would consider writing a PR for this.

from templater.

Zachatoo avatar Zachatoo commented on June 20, 2024 1

Update: This will be tricky for me to fix. Looks like with the deprecation of CodeMirror 5 in Obsidian 1.5.0, the previous way of adding syntax highlighting will no longer work and will have to be rewritten. I am not very experienced in CodeMirror, so migrating the code to CodeMirror 6 will take some time. When it is fixed, it may not be exactly the same as it was before.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024 1

Given that highlighting still works on mobile, which is CM6, you can likely just unify the both of those now.

The highlighter is a StreamParser, which is the CM6 API to CM5-style highlighters. It hasn't, to my knowledge, been removed or deprecated.

from templater.

Zachatoo avatar Zachatoo commented on June 20, 2024 1

I don't think it's the deprecation of CM5 itself that broke it, rather some side effect of that change broke it.

I've tried a few things trying to get the token function for the templater mode to run at all, but it's never being called. The token function for the hypermd mode is being called. The templater mode is being registered as an editor extension, though I don't know if it's being done correctly since it isn't being called.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024 1

It might be necessary to work out what's changed between the APIs. I'll let you know if I find anything.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024

Possibly mixed language parsing might be helpful.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024

@Zachatoo Are you sure about the mobile thing? I have plugin sync on and it was working on mobile during my testing! Mobile has always used CM6, and the new way of doing things should be compatible.

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024

Yeah, can confirm it's still working on mobile even in the full 2.0.0 release.

from templater.

Zachatoo avatar Zachatoo commented on June 20, 2024

I had to restart Obsidian, now syntax highlighting is working for me on mobile on 2.0.0. That's my bad!

from templater.

iamrecursion avatar iamrecursion commented on June 20, 2024

Phew! Was worried I'd broken something strange for a moment there!

from templater.

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.