Closed rayhagimoto closed 3 years ago
I managed to fix the problem! It looks like it was an issue with regex consuming matches so that both rules couldn't be enforced at the same time.
Here is the fix: (I also added a rule for \bra{[something]}
Without conceal:
With conceal:
The code:
{ "ugly": "(?:\\\\ket{)", "pretty": "|", "style": {"color": "#E5C07B"}},
{ "ugly": "(?<=\\\\ket{[^}]+)}", "pretty": "⟩", "style": {"color": "#E5C07B"}},
{ "ugly": "(?:\\\\bra{)", "pretty": "⟨", "style": {"color": "#E5C07B"}},
{ "ugly": "(?<=\\\\bra{[^}]+)}", "pretty": "|", "style": {"color": "#E5C07B"}}
the colour was chosen to match the theme I'm using akamud.vscode-theme-onedark
I found this forum post useful, although I had to translate the regex from vim's syntax to JS.
I have been trying to configure my conceal settings so that I can conceal something like
\ket{\psi}
to display as|𝜓⟩
. (I already have a rule for replacing characters such as \psi.) Another example would be to display\ket{abc}
as|abc⟩
.I thought this might be possible by instructing all instances of
\ket{
to be replaced with|
and to contextually replace}
with the context"pre" : "\\\\ket{.*"
. In full:{ "ugly": "\\\\ket\\{", "pretty": "|"}, { "ugly": "}", "pretty": "⟩", "pre": "\\\\ket\\{.*"}
Each half seems to work independently: Both off: First on/second off: First off/second on:
But when I use both together only one of the conceals is performed:
Both on:
It seems like one conceal is affecting the context of the other. I have tried a bunch of other attempts to fix this issue and can't figure it out.