Code2HTML
Code2HTML copied to clipboard
Subpatterns
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.
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>(?<=@param)\s+\b(?:\w+)\b</pattern>
<style>
<entry key="color" value="rgb(0, 50, 60)" />
</style>
</rule>
</subrules>
</rule>
...
</language>
Output looks like:
Having a "recursive" flag would be nice for subrules. Esp for xml styled languages.