-
Notifications
You must be signed in to change notification settings - Fork 83
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
dtx file support? #248
Comments
Take a look at the replacement switch, you should be able to remove leading space in front of comment symbols after indenting. Let me know how it goes. |
Thanks for your quick reply, it works, though not perfectly. defaultIndent: " "
replacements:
- substitution: s/^ +%/%/gm
when: after then latexindent -l -r demo.dtx | diff demo.dtx - would be ok. The regex is simple, but also trims the leading space of comments inside macro code % ^^A demo2.dtx
% \begin{macrocode}
\def\somecommand{
% comment inside macrocode
do something
% \end{macrocode}
% Some notes for the rest fragment
% \begin{macrocode}
do another thing
}
% \end{macrocode} 4c4
< % comment inside macrocode
---
> % comment inside macrocode In most cases, the dtx doc code would be comment lines between It would be better if it can handle doc code separately, as if there is no leading |
Your original post and your response seem to contradict each other. |
You missed my point. I do not want to trim the leading space of all comment lines, just those between |
So, just to be completely clear, your desired result is % ^^A demo2.dtx
% \begin{macrocode}
\def\somecommand{
% comment inside macrocode
do something
% \end{macrocode}
% Some notes for the rest fragment
% \begin{macrocode}
do another thing
}
% \end{macrocode} If not, please provide your desired output as text, not a screenshot. |
Yes it is. (The screenshot was intended for showing line numbers 👀) |
I don't have a way to do this in a single call, but it can be done in two calls. Starting with your original code, if you run
with defaultIndent: " "
replacements:
-
when: after
substitution: |-
s/\h*(\%\h*\\end\{macrocode\})
(.*?)
\h*(\%\h*\\begin\{macrocode\})/
my $begin = $1;
my $body = $2;
my $end = $3;
$body =~ s|^\h*\%|%|mg;
$begin.$body.$end;/smgxe then the output is % ^^A demo2.dtx
% \begin{macrocode}
\def\somecommand{
% comment inside macrocode
do something
% \end{macrocode}
% Some notes for the rest fragment
% more comments
% \begin{macrocode}
do another thing
}
% \end{macrocode} The reason that two calls to I hope this helps. For reference, there's also https://tex.stackexchange.com/a/528732/6621. Let me know. |
I'll close this for the moment, but let me know if you have any other questions. |
I'd love to use this for formatting my
.dtx
file, but it cannot handle the comment indent properly. And I could not find any docs about the comment indent nor the dtx support.Suppose I have a
demo.dtx
file with contentAfter I run
It gives
But I don't want the doc comment to be indented. So I wonder if there is an option to ignore comment indent for
.dtx
file?The text was updated successfully, but these errors were encountered: