#849 comments in dtx files handled wrong

None
open
nobody
2
2015-03-30
2012-05-30
No

With dtx files I found the following problems with the svn version.

1. % ist not a comment char anymore. This is handled correct in the highlighting, but the
syntax parsing in txs is still disabled completely. But for dtx files any code after a single % must be treated as normal tex code.

Discussion

• Tim Hoffmann
2012-06-03

1) I enabled general syntax parsing in dtx files (rev. 2927). This can be seen e,g. in the format of environment names. However parsing after comments requires some modifications of the underlying latex parser, which may take some time to be implemented.

2) Is fixed (rev. 2926). Please try the latest SVN version.
- Should the whole line be highlighted as comment or only the "^^A"?
- I also saw ^^x with x=J,K,L,M. Do they need any other special highlighting?

• no feedback

• status: open --> closed
• milestone: -->

• Tim Hoffmann
2012-11-09

• status: closed --> open

Feature request is to support correct dtx highlighting.

Currently only the qnfa-parser based highlighting works (which is 90% if the highlighting). The internal parser for sections and environment does not work (see attachment).
This requires a modification of the internal parser.

Not saying that this will be implemented any time soon, if ever. But it should stay open.

Last edit: Tim Hoffmann 2012-11-09
• ^^A for the dtx file in general works.
However for the code section belonging to the resulting .sty file the comment char is obviously still %.

So if the surrounding section is
% \begin{macrocode}
code in .sty file
% \end{macrocode}
then the comment char must be %

Adding large section to the doc part still requires to insert a "% " in the beginning of each file. Can this be handled as well by a different key ?

• I also saw ^^x with x=J,K,L,M. Do they need any other special highlighting?
I have no idea.

• Tim Hoffmann
2012-11-25

obviously :)

Using the same char with different semantics depending on context... Well, LaTeX and its associated formats is a real nightmare in terms of formal language specifications. I'll check later if we can do anything about this.

• Tim Hoffmann
2012-11-25

Adding large section to the doc part still requires to insert a "% " in the beginning of > each file. Can this be handled as well by a different key ?

You mean each line?

Two possible workarounds without altering the TXS code:
- Use a block cursor (Ctrl+Alt+Up/DownArrow or Ctrl+Alt+MouseLeft+Drag) to create and type "% "
- write a script that inserts this string at the beginning of each line. Something like this should do:

%SCRIPT
start = cursor.lineNumber()
end = cursor.anchorLineNumber()
if (end < start) {
h = start
start = end
end = h
}
editCursor = editor.document().cursor(start)
editCursor.beginEditBlock()
while (editCursor.lineNumber() <= end) {
editCursor.insertText("% ")
editCursor.movePosition(1, cursorEnums.NextLine)
}
editCursor.endEditBlock()


By the way, do you know what the meaning of inner "%" is in a dtx file is? Say

% Text % more


Likely the second one should not be highlighted, at least not as guard.

• Ticket moved from /p/texstudio/bugs/547/