coq-community / vsc-conceal

Prettify Symbols Mode for Visual Studio Code [maintainer=@rtetley]
MIT License
53 stars 6 forks source link

some bugs about display and regular expressions using #10

Open yfzhao20 opened 3 years ago

yfzhao20 commented 3 years ago
  1. After I change the setting.json to have a better pattern, my file usually changes into messy code. I have to restart my VSCode and everything works.

like that: image

and after I restart my VSCode, it goes: image

every time I change my setting.json, I have to restart that😂

  1. I want to use regular expressions to change some ugly pattern to pretty pattern, such as change \frac{xxx}{yyy} to (xxx)/(yyy). That means I have to use regular expression to capture xxx and yyy.

However when I use () to capture that and save, my file changes into messy code. and when I use $1 to extract the string I captured, It appears that nothing had happened.

so what should I do to achieve that? Or is this the bug of the extension?

rayhagimoto commented 3 years ago

I think I came up with a quick solution to your second question. Here is a preview of the unconcealed code and the concealed code: Unconcealed image Concealed image

Here's something you can copy and paste. (Note: I used the return carriage metacharacter \r as a null character even though it's not really a null character. In my testing so far it seems to be okay and basically just replaces the ugly text with 'nothing')

        { "ugly": "(?:\\\\frac{)",     "pretty": "("}, 
        { "ugly": "(?<=\\\\frac{[^}]+)}",     "pretty": "\r"},
        { "ugly": "(?<=\\\\frac{[^}]+}){",     "pretty": ") / ("}, 
        { "ugly": "(?<=\\\\frac{[^}]+}{[^}]+)}",     "pretty": ")"}, 

Updated version: fraction (no parentheses) e.g. \frac{x}{y} --> x / y

        { "ugly": "(?:\\\\frac{)(?=[^} ]+})",     "pretty": "\r"}, 
        { "ugly": "(?<=\\\\frac{[^} ]+)}",     "pretty": "/"}, 
        { "ugly": "(?<=\\\\frac{[^}]+}){(?=[^ }]+})",     "pretty": "\r"}, 
        { "ugly": "(?<=\\\\frac{[^}]+}{[^} ]+)}",     "pretty": "\r"}, 

fraction (with parentheses) e.g. \frac{x + y}{w + z} --> (x + y) / (w + z)

        { "ugly": "(?:\\\\frac{)(?=[^}]+})",     "pretty": "("}, 
        { "ugly": "(?<=\\\\frac{[^}]+)}",     "pretty": ") /"}, 
        { "ugly": "(?<=\\\\frac{[^}]+}){(?=[^}]+})",     "pretty": " ("}, 
        { "ugly": "(?<=\\\\frac{[^}]+}{[^}]+)}",     "pretty": ")"} 

e.g. image becomes image

yfzhao20 commented 3 years ago

WOW, it works! Thank you so much😃