lite-xl / lite-xl-plugins

Plugins for the Lite XL editor
MIT License
343 stars 91 forks source link

add sectioning commands for ConTeXt #439

Closed ousia closed 1 month ago

PerilousBooklet commented 1 month ago

You can use a non-capturing group to avoid repeating the subsub... strings, like this image So instead you would do \\(?:sub)+ject and \\(?:sub)+section.

ousia commented 1 month ago

Of course, already done @PerilousBooklet.

I wonder whether \\(?:sub)*section would be also an option (also \\(?:sub)*paragraph.

PerilousBooklet commented 1 month ago

Yes I didn't notice, you can do \\(?:sub)*section, but for the paragraph \\(?:sub)?paragraph is better (if there are only paragraph and subparagraph).

If there are more sub paragraphs you can use, for example, \\(?:sub){0,2}paragraph, where the 2 is the max number of sub occurrences.

ousia commented 1 month ago

Yes I didn't notice, you can do \\(?:sub)*section, but for the paragraph \\(?:sub)?paragraph is better (if there are only paragraph and subparagraph).

Ok, I will submit a new PR, since this would have three commits instead of one.

If there are more sub paragraphs you can use, for example, \\(?:sub){0,2}paragraph, where the 2 is the max number of sub occurrences.

I know, but unless this saves noticeable computing, I think that * (or + when a single occurrence at least is required) is also more readable.

Many thanks for your help.

PerilousBooklet commented 1 month ago

Wait why a new PR? It's fine if it has a couple commits.

ousia commented 1 month ago

Sorry, too fast on my side.

ousia commented 1 month ago

Sorry, testing the changes on my computer, no regex works in commands.

Do I need an addon or special plugin?

PerilousBooklet commented 1 month ago

I use this to test regex: https://regex101.com/ . Also, what do you mean by "no regex work in commands" ?

ousia commented 1 month ago

By no regex works in commands I mean that I get \part highlighted different from \whatever, but \subsection is colored as \whatever (not as \part).

ousia commented 1 month ago

I was in the way to have something like \\use(package|module).

I tested everything \subject and it didn’t have special highlighting (as keyword).

PerilousBooklet commented 1 month ago

By the way, if you use regex you must use regex instead of pattern. pattern is for lua patterns, not regex patterns.