Item9389: Improve TML syntax highlighting
Priority: Enhancement
Current State: Closed
Released In: 1.1.0
Target Release: minor
It is great having syntax highlighting for TML, but there is room for improvement.
- Before this change:
- The first take at addressing this task:
%INCLUDE{"doc:Foswiki::IncludeHandlers::doc" pattern="(Foswiki .*?protocol)" warn="magic $topic foo"}%
%FOO{"bar" baz='qu"ux' pox="\"eeuw\"" spim="moo"}%
%JQPLUGINS{"chili"
format="
Homepage: $homepage <br />
Author(s): $author <br />
Version: $version
"
extra="foo"
}%
%SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" type="regex" nonoise="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%
%SEARCH{ "\*Back to:\* FrequentlyAskedQuestions" scope="text" type="regex" header="FAQs:" format=" * $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" footer="Found $ntopics FAQ topics" nonoise="on" }%
%SEARCH{ "culture" format=" * $topic ref'd by --> $n * $percentSEARCH{ \"$topic\" format=\"$dollartopic\" separator=\", \" }$nop%" nonoise="on" }%
α zzz > zzz ε
--
MichaelTempest - 25 Jul 2010
Xcellent. Now here's some nested macro that doesnt hilite correctly. Maybe you have an idea how to fix it.
You type:
%MACRO{
attr="
blabla
%MACRO{attr="blabla"}%
blabla
"
}%
You get:
If that's not doable easily, I actually prefer the version with less highlightning. Maybe I just need to get used to it.
--
MichaelDaum - 26 Jul 2010
Good point - and when it doesn't work, I prefer the version without the background shading, too.
More generally:
%MACRO{
attr="
blabla
%MACRO{attr="blabla"
nother="bla%MAC%EN%RO{"foo"}%bla"}%
blabla
"
}%
I will see what I can do
--
MichaelTempest - 26 Jul 2010
Michael - How does it look now?
More examples:
<img href="%ATTACHURL%/image.gif" />
<!--[if IE]><style type="text/css" media="screen">
pre {
height:1%;
overflow-x:auto;
}
</style>
<![endif]-->
<font color="red">red text</font>
<!-- hello -->
<script foo="bar">
var f = function ( apple)
{
alert("hello" + apple);
}
f('raisin');
</script>
... and here is an example from
GluePlugin:
%~~ SEARCH{
#~~ #################################
#~~ # this is the search expression
~~~ "..."
~~~
~~~ type="query"
~~~
#~~ #################################
#~~ # this is the header of the result table
~~~
~~~ header="
~~~ <table
~~~ width='100%'
~~~ border=\"5px\"
~~~ >
~~~ <thead>
~~~ <tr>
~~~ <th>Name</th>
~~~ <th>Description</th>
~~~ <th>Date</th>
~~~ </tr>
~~~ </thead>"
#~~ #################################
#~~ # every row will be formatted like this
~~~
~~~ format="
~~~ <tr>
~~~ <th>$formfield(Name)</th>
~~~ <th>$summary</th>
~~~ <th>$createdate</th>
~~~ </tr>"
#~~ #################################
#~~ # and finally we close this html table
~~~
~~~ footer="</table>"
~~~ }%
--
MichaelTempest - 30 Jul 2010
This looks marvelous. Strangely, some parameter names don't get green:
--
MichaelDaum - 30 Jul 2010
Those parameter names are not green because they are not recognised as parameter names. The pattern matches name="value", but it can only do that if it knows which is the closing ". That is a problem with nested macros that are
intended to be evaluated inside out.
I see only one way to get it right, and that is to parse the macros and attributes in the same way that Foswiki does. I cannot figure out how to do it with regexes.
--
MichaelTempest - 30 Jul 2010
Okay then leave it as it is. Gr8.
--
MichaelDaum - 31 Jul 2010
While it was interesting the first time to use the :hover pseudoclass to hilite parameter arguments, I find this effect too flickering and more confusing than helpful, i.e. as matching the correct quote isn't working out 100% without reimplementing parsing macros and arguments in javascript. Let's please remove this for the sake of simplicity.
--
MichaelDaum - 09 Aug 2010
Okay - I removed that :hover shading.
--
MichaelTempest - 14 Aug 2010