Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subpatterns #5

Open
Col-E opened this issue Apr 19, 2019 · 2 comments
Open

Subpatterns #5

Col-E opened this issue Apr 19, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@Col-E
Copy link
Owner

Col-E commented Apr 19, 2019

Lets say I have the following text:

<span class="code">pom.xml</span>

I can make a rule that registers <span class="code"> and </span> as HTML tags (<[\s\w="\/;'.,:?-]+>), but I then want to look inside the matched region and match keywords like class and strings. I can't do this with single-level patterns. This will need sub-patterns to accomplish.

@Col-E Col-E added enhancement New feature or request help wanted Extra attention is needed labels Apr 19, 2019
@Col-E
Copy link
Owner Author

Col-E commented Nov 27, 2022

Been a while, but getting around to this with a large refactor of the project.

Having distinct <themes> declaring style independent from the <rule> items in a <language> was neat and all, letting there be multiple themes... but its also a bit of a pain to maintain the two separate blocks.

A sample of the new Java language XML looking specifically at the javadoc-comment rule.

<language name="Java">
 ...
  <rule name="javadoc-comment">
    <pattern>/[*]{2}(?:.|\n)+?\*/</pattern>
    <style>
        <entry key="color" value="rgb(0, 100, 114)" />
              <entry key="font-style" value="italic" />
    </style>
    <subrules>
        <rule name="field">
          <pattern>\B(?:@[\w]+)\b</pattern>
          <style>
              <entry key="font-weight" value="bold" />
          </style>
        </rule>
        <rule name="param-name">
           <pattern>(?&lt;=@param)\s+\b(?:\w+)\b</pattern>
           <style>
                <entry key="color" value="rgb(0, 50, 60)" />
           </style>
        </rule>
    </subrules>
  </rule>
...
</language>

Output looks like:
image

@Col-E Col-E removed the help wanted Extra attention is needed label Nov 27, 2022
@Col-E
Copy link
Owner Author

Col-E commented Nov 27, 2022

Having a "recursive" flag would be nice for subrules. Esp for xml styled languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant