Hello there, I was working on a sublime concealer for LaTeX in my free time, and the prototype works fairly well. See the dropbox link for a demo. Preview is disabled because of ubuntu’s default screencast format.
In short, here’s how the concealer works:
- Takes in everything inside the $ $ delimiters, converts it to utf-8.
- Folds the tex code
- Replaces it with a phantom containing the utf as html
The only feature that I would like to add now is to be able to do the following two things happen in real time:
pointis in line N, then the phantoms in line N disappear.
- When you leave line N, the plugin auto-adds phantoms in line N.
I am currently using a ViewEventListener, but I see a couple of issues.
- If I update phantoms from the beginning of the file after every keystroke, sublime will crash.
- There does not seem to be adequate API methods to erase phantoms (say, by line number).
Does anyone have any suggestions on how best to go about doing this? Otherwise I might create a key binding that conceals everything in a selected region (EDIT: did this, the gif above is proof). That won’t be ideal for obvious reasons ;-;
TLDR. Trying to use phantoms to replicate vim’s conceal feature.
EDIT 2: Here’s some code without much explanation: https://github.com/rah4927/LaTeX-Concealer-sublime-text-3 (P.S: TeXconceal.py requires a key-binding to work).
EDIT: I had a thought after posting this. Perhaps I could use
add_phantoms() and use
key = line number. Then I can use
erase_phantoms(key). There is only one issue, the line number can and will change Perhaps there could be some way of making the key a function of the line number, but that requires changing how phantoms work themselves(?)