Pustelto / Bracketeer

VS Code extension for easy and quick manipulation with brackets and quotes.
https://marketplace.visualstudio.com/items?itemName=pustelto.bracketeer
MIT License
35 stars 9 forks source link

LaTeX support #47

Open Dixilea opened 3 years ago

Dixilea commented 3 years ago

Dear @Pustelto,

I've tried this extension with a LaTeX file (.tex) but unfortunately this does not appear to be supported (yet). I've tried adding a new definition to the language-definitions.json file, but this does not appear to work. Admittedly, I have never modified extensions so it's probably me being inexperienced; on the other hand, it may be the parser.

The brackets { } in this simple formula can be changed: $a^{b}$ The inner round brackets ( ) in the following formula can not be changed. Bracketeer will only change the outer brackets { }: $a^{(b)}$ The round brackets ( ) of the next formula will also not be changed by Bracketeer: $e = (u,v)$ Anything more complex and Bracketeer will give unexpected behavior (from the user's viewpoint).

If I have Bracketeer select the content of $a^{(b)}$ via Ctrl+Alt+Shift+H, then it selects (b) in its entirety while one may want b or (b) depending on whether they're looking to change ( ) or { }, respectively. Hence there may be an underlying issue with the parser. Bracket nesting is very common in LaTeX code. Asking Bracketeer to select the contents of $e = (u,v)$, results in nothing selected whereas I would have expected u,v to be selected.

There is perhaps another challenge with matching brackets in LaTeX. Many of the brackets used are asymmetrical. For example, these matching brackets: ( ), { }, [ ], < >, | | Can all be enhanced with the commands: \bigl \bigr, \Bigl \Bigr, \left \right For example, one may want to change: \bigl{ \bigr} into \Bigl[ \Bigr]

The ability to quickly change matching brackets in mathematical documents would be amazing from a productivity standpoint! The hundreds of formulae in some documents contain quite literally thousands of matching brackets. I'm happy to help where I can.

In any case, thanks for the extension :)!

Dixilea

Pustelto commented 3 years ago

Hi, seems like prism.js supports LaTeX (package I use to parse the code) so it should be possible. Will have to look into this, but not sure how easy it will be to include the prefixes like \Bigl etc.

Also I have very limited time at the moment. So don't expect this to be ready soon.