Comments (15)
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 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.
Can reproduce, will investigate. Thanks!
from templater.
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.
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.
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.
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.
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.
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.
It might be necessary to work out what's changed between the APIs. I'll let you know if I find anything.
from templater.
Possibly mixed language parsing might be helpful.
from templater.
@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.
Yeah, can confirm it's still working on mobile even in the full 2.0.0 release.
from templater.
I had to restart Obsidian, now syntax highlighting is working for me on mobile on 2.0.0. That's my bad!
from templater.
Phew! Was worried I'd broken something strange for a moment there!
from templater.
Related Issues (20)
- Execution of the tp.file.selection() function erase the selection in the note HOT 2
- Add note about modified date to the FAQs / docs
- front matter formating number as a string HOT 1
- main.js missing HOT 3
- Date not rendered as link HOT 1
- 2.3.2 broke my frontmatter processing template HOT 6
- Auto jump to cursor is triggered twice on new file creation HOT 4
- invalid reference date format, try specifying one with reference format HOT 4
- bug: app.workspace.getLeaf().openFile() replaces content in a note if called without "await"
- app.fileManager.processFrontMatter doesn't work HOT 1
- Templater should parse, merge and write out frontmatter gracefully HOT 6
- Applying Text Color in Obsidian Without Unwanted New Lines HOT 2
- Templater no longer works with console error "Plugin failure: templater-obsidian TypeError: c is not a constructor" HOT 2
- The recent upgrade of this plug-in has broken "Trigger Templater on new file creation" HOT 6
- {{date}} fail to work after updating to 2.3.3 HOT 1
- Target file gets overwritten by processFrontMatter() HOT 1
- Note Creation with Core Plugin "Note Composer" Breaks Templater HOT 1
- Option to add ignored files to Templater settings HOT 2
- Copy existing file with templater HOT 1
- Ability to use {{date}} in Folder Templates HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templater.