[texworks] Highlighting for LaTeX3 and LuaTeX

Arno Trautmann Arno.Trautmann at gmx.de
Tue Aug 9 14:00:09 CEST 2011


Hi all,

after LuaTeX and LuaLaTeX have been accepted as engines, I wonder if it 
is possible to also add the necessary highlighting support for them. 
However, I have some more requests regarding highlighting, so this mail 
will be a bit lengthy, sorry:

First the request for LaTeX3 source highlighting:
The normal (La)TeX highlighting does not cover this, as LaTeX3 control 
sequence names can have _ as well as : in their names, like:

\cs_new:Npn

Everything left of the : is the command (or function, in l3 terms) name, 
and the right-hand part specifies the arguments, in this case 3 
arguments are needed. Long story short, it should be sufficient to add _ 
and : to the list of allowed characters for a control sequence. Is this 
possible?

Now the Lua part: First, there should be a “Lua documents” choice in the 
“Files of type: …” drop-down menu, as most of the LuaTeX code is stored 
in external Lua files. In such files, basic highlighting for Lua should 
be offered. A bit more complicated is the use of \directlua, \latelua or 
the luacode environment, as then we have Lua code inside a .tex file … 
In a perfect world, TeXworks would recognize these structures and apply 
the correct highlighting.
The most complicated case, however, are .dtx files, at least in the way 
I like to use them. Consider the following piece of a package:

——

\cs_new:Npn\unuppercasecolor 
{\directlua{luatexbase.remove_from_callback("post_linebreak_filter","uppercasecolor")}}
%    \end{macrocode}
% Now the setup for the |\text|-versions. We utilize Lua\TeX s
% attributes to mark all nodes that should be manipulated. The macros
% should be |\long| to allow arbitrary input.
%\iffalse
%</package>
%<*lua>
%\fi
%    \begin{macrocode}
Hhead = node.id("hhead")
RULE = node.id("rule")

——

Here we have:
• (La)TeX(3) code (\cs_new:Npn …) that should go to the final .tex file 
and thus is not commented, needs normal (l3) highlighting, but 
containing Lua code in a \directlua statement.
• Commented code that should go to the documentation; for the editor, 
everything is just a comment and is not highlighted at all. Here, 
TeXworks should recognize that it is a .dtx file, and not handle 
everything after a single % as a comment.
• Tags for the driver file that are neither TeX nor Lua style. <tags> 
should be quite easily highlightable?
• plain Lua code that goes to the final Lua helper file.

Now, my feature request is: Implement correct highlighting so that I can 
write my package using TeXworks.

ok, just joking … but how much of the highlighting do you think could be 
done? How much should be done, considering that not too many users of 
TeXworks will hack LaTeX3 syntax into a dtx to create LuaTeX code?

Thanks for your time,
cheers
Arno


More information about the texworks mailing list