texlive[72952] trunk: easydtx (24nov24)
commits+karl at tug.org
commits+karl at tug.org
Sun Nov 24 21:51:58 CET 2024
Revision: 72952
https://tug.org/svn/texlive?view=revision&revision=72952
Author: karl
Date: 2024-11-24 21:51:58 +0100 (Sun, 24 Nov 2024)
Log Message:
-----------
easydtx (24nov24)
Modified Paths:
--------------
trunk/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl
trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.1
trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.man1.pdf
trunk/Master/texmf-dist/doc/support/easydtx/FILES
trunk/Master/texmf-dist/doc/support/easydtx/README.md
trunk/Master/texmf-dist/doc/support/easydtx/easydoctex-mode.el
trunk/Master/texmf-dist/scripts/easydtx/edtx2dtx.pl
Added Paths:
-----------
trunk/Master/texmf-dist/doc/support/easydtx/CHANGELOG.md
trunk/Master/texmf-dist/doc/support/easydtx/edtx2dtx.1.md
Modified: trunk/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl 2024-11-24 20:51:58 UTC (rev 72952)
@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
-# The files belonging to this work and covered by LPPL are listed in
+# The files belonging to this program and covered by GPL are listed in
# <texmf>/doc/support/easydtx/FILES.
use strict;
@@ -26,12 +26,28 @@
my $usage = <<END;
EasyDTX: convert .edtx into .dtx
-Usage: edtx2dtx filename.edtx > filename.dtx
+Usage: edtx2dtx [options] filename.edtx > filename.dtx
+Options: TODO
END
-my $VERSION = '0.1.0';
+my $VERSION = '0.2.0';
my ($help, $print_version);
+
+my $comment = '%';
+my $begin_macrocode = '^% \\\\begin{macrocode}';
+my $end_macrocode = '% \\\\end{macrocode}';
+my $Begin_macrocode = '';
+my $End_macrocode = '';
+my $strip = '';
+
+Getopt::Long::Configure (qw/bundling no_ignore_case/);
GetOptions(
+ "comment|c=s" => \$comment,
+ "begin-macrocode|b=s" => \$begin_macrocode,
+ "end-macrocode|e=s" => \$end_macrocode,
+ "Begin-macrocode|B=s" => \$Begin_macrocode,
+ "End-macrocode|E=s" => \$End_macrocode,
+ "strip-empty|s" => \$strip,
"help|h|?" => \$help,
"version|V" => \$print_version,
) or die $usage;
@@ -39,42 +55,76 @@
if ($print_version) { print("edtx2dtx $VERSION\n"); exit 0 }
die $usage unless @ARGV == 1;
+my $keep_begin_macrocode = '';
+my $keep_end_macrocode = '';
+if ($Begin_macrocode) {
+ $begin_macrocode = $Begin_macrocode;
+ $keep_begin_macrocode = 1;
+}
+if ($End_macrocode) {
+ $end_macrocode = $End_macrocode;
+ $keep_end_macrocode = 1;
+}
+
sub begin_macrocode { print("% \\begin{macrocode}\n"); }
sub end_macrocode { print("% \\end{macrocode}\n"); }
+# doc: replace initial in-comments with out-comments
+sub convert_comments { s/^\Q$comment\E+// && print('%' x length($&)); }
+
+my $indoc;
sub process_edtx {
- my $indoc = 1;
+ my $done;
+ my $empty;
while (<>) {
- if (/^% \\end{macrocode}/) { # trailer starts here
- end_macrocode unless ($indoc);
- last;
- } elsif (/^% \\begin{macrocode}/) {
- die "Nested \\begin{macrocode}";
- } elsif (/^ *(%%+)/) { # code: multiple comments
- begin_macrocode if ($indoc);
+ if (/$end_macrocode/) { # trailer starts here
+ if ($keep_end_macrocode) {
+ $done = 1;
+ } else {
+ end_macrocode unless $indoc;
+ last;
+ }
+ } elsif (/$begin_macrocode/) {
+ die "Nested '$begin_macrocode'";
+ }
+ if (/^ *(\Q$comment$comment\E+)/) { # code: multiple comments
+ begin_macrocode if $indoc;
+ print($empty); $empty = '';
print;
$indoc = 0;
- } elsif (/^%(<[^>]*>)(.*)$/) { # code: unindented guard
- begin_macrocode if ($indoc);
+ } elsif (/^\Q$comment\E(<[^>]*>)(.*)$/) { # code: unindented guard
+ begin_macrocode if $indoc;
print;
$indoc = 0;
- } elsif (/^( *)%(<[^>]*>) *(.*)$/) { # code: indented guard
- begin_macrocode if ($indoc);
+ } elsif (/^( *)\Q$comment\E(<[^>]*>) *(.*)$/) { # code: indented guard
+ begin_macrocode if $indoc;
print("%$2$1$3\n");
$indoc = 0;
- } elsif (/^% *(.*)$/) { # doc: unindented comment
- end_macrocode unless ($indoc);
+ } elsif (/^\Q$comment\E *(.*)$/) { # doc: unindented comment
+ end_macrocode unless $indoc;
+ convert_comments;
print;
$indoc = 1;
- } elsif (/^( ?)( *)% *(.*)$/) { # doc: indented comment
- end_macrocode unless ($indoc);
+ } elsif (/^( ?)( *)\Q$comment\E *(.*)$/) { # doc: indented comment
+ end_macrocode unless $indoc;
print "%$2$3\n";
$indoc = 1;
+ } elsif (/^\s*$/) { # code: empty line
+ if ($strip) {
+ $empty .= $_ unless $indoc;
+ } else {
+ print;
+ }
} else { # code
- begin_macrocode if ($indoc);
+ print($empty); $empty = '';
+ begin_macrocode if $indoc;
print;
$indoc = 0;
}
+ if ($done) {
+ end_macrocode unless $indoc;
+ last;
+ }
}
}
@@ -83,17 +133,25 @@
$dtx =~ s/\.edtx$/.dtx/;
my $first = 1;
+print("% \\iffalse\n%\n");
while (<>) {
if ($first and s/$edtx +(.*)/$dtx (generated from $edtx by edtx2dtx)/) {
print;
$first = 0;
- } elsif (/^% \\begin{macrocode}/) {
+ } elsif (/$begin_macrocode/) {
+ print("% \\fi\n%\n");
+ if ($keep_begin_macrocode) {
+ $indoc = 1 if /^\Q$comment\E/;
+ begin_macrocode unless $indoc;
+ print;
+ } else {
+ $indoc = 1;
+ }
process_edtx;
- } elsif (/^% \\end{macrocode}/) {
- die "\\end{macrocode} without the opening \\begin{macrocode}!";
+ } elsif (/$end_macrocode/) {
+ die "'$end_macrocode' without the opening '$begin_macrocode'!";
} else {
+ convert_comments;
print;
}
}
-
-
Modified: trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.1 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.1 2024-11-24 20:51:58 UTC (rev 72952)
@@ -1,54 +1,96 @@
-.\" Automatically generated by Pandoc 3.0.1
+.\" Automatically generated by Pandoc 3.1.11.1
.\"
-.\" Define V font for inline verbatim, using C font in formats
-.\" that render this, and otherwise B font.
-.ie "\f[CB]x\f[]"x" \{\
-. ftr V B
-. ftr VI BI
-. ftr VB B
-. ftr VBI BI
-.\}
-.el \{\
-. ftr V CR
-. ftr VI CI
-. ftr VB CB
-. ftr VBI CBI
-.\}
-.TH "edtx2dtx" "1" "October 10, 2023" "edtx2dtx 0.1.0" "User Manual"
-.nh
+.TH "edtx2dtx" "1" "November 23, 2024" "edtx2dtx 0.2.0" "User Manual"
.SH NAME
-.PP
-edtx2dtx - Convert .edtx into .dtx
+edtx2dtx \- Convert .edtx into .dtx
.SH SYNOPSIS
-.PP
\f[B]edtx2dtx\f[R] \f[I]filename.edtx\f[R] > \f[I]filename.dtx\f[R]
.SH DESCRIPTION
This utility wraps code chunks by a (commented and properly indented)
-.PP
+\f[CR]\[rs]begin{macrocode}\f[R] and \f[CR]\[rs]end{macrocode}\f[R]
pair.
A code chunk is any sequence of lines not introduced by a single
-(possibly indented) comment character (%); i.e.\ both non-commented
-lines and lines introduced by multiple comment characters count as code,
-and documentation lines may be indented.
-The part(s) of the file which should undergo conversion should be marked
-by a
+(possibly indented) comment character (\f[CR]%\f[R]); i.e.\ both
+non\-commented lines and lines introduced by multiple comment characters
+count as code, and documentation lines may be indented.
.PP
-pair (unlike in a .dtx, these lines need not immediately precede and
-follow the code, respectively).
-This convention allows for the driver to remain as is, and also makes it
-easy to paste a .dtx file into an .edtx, as using this utility on a .dtx
-does not change the file.
+The part of the file which should be processed should be marked by a
+\f[CR]\[rs]begin{macrocode}\f[R] and \f[CR]\[rs]end{macrocode}\f[R]
+pair.
+In other words, everything preceding \f[CR]\[rs]begin{macrocode}\f[R] is
+considered a header and not changed, and everything following
+\f[CR]\[rs]end{macrocode}\f[R] is considered a trailer and not changed.
+In fact, any number of \f[CR]\[rs]begin{macrocode}\f[R] \[em]
+\f[CR]\[rs]end{macrocode}\f[R] pairs is allowed.
+(The system allows for the driver to remain as is, and also makes it
+easy to paste a \f[CR].dtx\f[R] file into an \f[CR].edtx\f[R], as using
+this utility on a \f[CR].dtx\f[R] does not change the file.)
.PP
The utility furthermore replaces the first occurrence of
-\[lq].edtx\[rq], followed by an optional parenthesized note, with
-\[lq].dtx\[rq], plus the note on how the file was generated.
+\f[CR]<filename>.edtx\f[R] in the header, followed by an optional
+parenthesized note, with \f[CR]<filename>.dtx\f[R], plus the note on how
+the file was generated.
.SH OPTIONS
.TP
-\f[B]-h, --help\f[R]
+\f[B]\-c, \-\-comment\f[R]
+The input comment character; the default is \f[CR]%\f[R].
+(Any input comment characters in the header and the trailer will be
+replaced by the output comment character, which is always \f[CR]%\f[R].)
+.PP
+\f[B]\-b, \-\-begin\-macrocode\f[R] \f[I]regex\f[R]
+.PD 0
+.P
+.PD
+.TP
+\f[B]\-e, \-\-end\-macrocode\f[R] \f[I]regex\f[R]
+Use these options to change the default \f[I]input\f[R]
+\f[CR]\[rs]begin{macrocode}\f[R] and \f[CR]\[rs]end{macrocode}\f[R]
+markers.
+(The \f[I]output\f[R] markers are always
+\f[CR]\[rs]begin{macrocode}\f[R] and \f[CR]\[rs]end{macrocode}\f[R].)
+The markers should be given as regular expressions matching the entire
+line.
+The input markers are not kept in the file, i.e.\ they are replaced by
+the output markers.
+.PP
+\f[B]\-B, \-\-Begin\-macrocode\f[R] \f[I]regex\f[R]
+.PD 0
+.P
+.PD
+.TP
+\f[B]\-E, \-\-End\-macrocode\f[R] \f[I]regex\f[R]
+As \f[CR]\-b\f[R] and \f[CR]\-e\f[R], but the input markers are kept in
+the output.
+.TP
+\f[B]\-s, \-\-strip\-empty\f[R]
+If this option is given, empty lines are not included in the output.
+.TP
+\f[B]\-h, \-\-help\f[R]
Show help and exit.
.TP
-\f[B]-V, --version\f[R]
+\f[B]\-V, \-\-version\f[R]
Show the version number and exit.
+.SH EXAMPLES
+If \f[CR]input.edtx\f[R] is just like a \f[CR]dtx\f[R] file, just
+without \f[CR]\[rs]begin{macrocode}\f[R] and
+\f[CR]\[rs]end{macrocode}\f[R] around every chunk of code:
+.IP
+.EX
+edtx2dtx input.edtx > output.dtx
+.EE
+.PP
+Memoize uses the invocation below to produce a \f[CR].dtx\f[R] from
+documented Python code of \f[CR]memoize\-extract.py\f[R].
+The value of \f[CR]\-c\f[R] adapts the \f[CR]edtx2dtx\f[R] to Python
+comments.
+\f[CR]\-B\f[R] marks everything preceding the version number statement
+as a header, and keeps the version number statement in the output.
+Similarly, \f[CR]\-E\f[R] says that the processing should stop when
+encountering Emacs\[cq] local variables (which are kept, unchanged, in
+the output).
+.IP
+.EX
+edtx2dtx \-s \-c \[aq]#\[aq] \-B \[aq]\[ha]__version__\[aq] \-E \[aq]\[ha]# Local Variables:\[aq] $< \[rs]
+.EE
.SH SEE ALSO
-.PP
easydoctex.el
Modified: trunk/Master/texmf-dist/doc/man/man1/edtx2dtx.man1.pdf
===================================================================
(Binary files differ)
Added: trunk/Master/texmf-dist/doc/support/easydtx/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/easydtx/CHANGELOG.md (rev 0)
+++ trunk/Master/texmf-dist/doc/support/easydtx/CHANGELOG.md 2024-11-24 20:51:58 UTC (rev 72952)
@@ -0,0 +1,15 @@
+# EasyDTX changelog
+
+For the development history, see [EasyDTX's GitHub
+repository](https://github.com/sasozivanovic/easydtx).
+
+## 2024/11/23 v0.2.0
+
+* Generalize to support comments in other programming languages
+ (used to typeset documented code of Memoize's extraction scripts).
+
+* Fix some minor issues with the documentation and the licence.
+
+## 2023/10/10 v0.1.0
+
+The initial release.
Property changes on: trunk/Master/texmf-dist/doc/support/easydtx/CHANGELOG.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/support/easydtx/FILES
===================================================================
--- trunk/Master/texmf-dist/doc/support/easydtx/FILES 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Master/texmf-dist/doc/support/easydtx/FILES 2024-11-24 20:51:58 UTC (rev 72952)
@@ -1,6 +1,8 @@
doc/man/man1/edtx2dtx.1
doc/support/easydtx/LICENCE
doc/support/easydtx/easydoctex-mode.el
+doc/support/easydtx/edtx2dtx.1.md
+doc/support/easydtx/CHANGELOG.md
doc/support/easydtx/FILES
doc/support/easydtx/README.md
scripts/easydtx/edtx2dtx.pl
Modified: trunk/Master/texmf-dist/doc/support/easydtx/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/easydtx/README.md 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Master/texmf-dist/doc/support/easydtx/README.md 2024-11-24 20:51:58 UTC (rev 72952)
@@ -8,3 +8,20 @@
forward and inverse search. (The script does what it should, and would really
deserve version 1.0.0. The Emacs mode, however, is just something that works
well enough for me.)
+
+# LICENCE
+
+Copyright (c) 2023- Saso Zivanovic <saso.zivanovic at guest.arnes.si>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
Modified: trunk/Master/texmf-dist/doc/support/easydtx/easydoctex-mode.el
===================================================================
--- trunk/Master/texmf-dist/doc/support/easydtx/easydoctex-mode.el 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Master/texmf-dist/doc/support/easydtx/easydoctex-mode.el 2024-11-24 20:51:58 UTC (rev 72952)
@@ -1,4 +1,4 @@
-;; easydoctex-mode.el 0.1.0
+;; easydoctex-mode.el 0.2.0
;;
;; This file is a part of TeX package EasyDTX, available at
;; https://ctan.org/pkg/easydtx and https://github.com/sasozivanovic/easydtx.
Added: trunk/Master/texmf-dist/doc/support/easydtx/edtx2dtx.1.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/easydtx/edtx2dtx.1.md (rev 0)
+++ trunk/Master/texmf-dist/doc/support/easydtx/edtx2dtx.1.md 2024-11-24 20:51:58 UTC (rev 72952)
@@ -0,0 +1,91 @@
+---
+title: edtx2dtx
+section: 1
+header: User Manual
+footer: edtx2dtx 0.2.0
+date: November 23, 2024
+hyphenate: false
+---
+
+# NAME
+edtx2dtx - Convert .edtx into .dtx
+
+
+# SYNOPSIS
+**edtx2dtx** *filename.edtx* > *filename.dtx*
+
+
+# DESCRIPTION
+
+This utility wraps code chunks by a (commented and properly indented)
+`\begin{macrocode}` and `\end{macrocode}` pair. A code chunk is any sequence of
+lines not introduced by a single (possibly indented) comment character (`%`);
+i.e. both non-commented lines and lines introduced by multiple comment
+characters count as code, and documentation lines may be indented.
+
+The part of the file which should be processed should be marked by a
+`\begin{macrocode}` and `\end{macrocode}` pair. In other words, everything
+preceding `\begin{macrocode}` is considered a header and not changed, and
+everything following `\end{macrocode}` is considered a trailer and not changed.
+In fact, any number of `\begin{macrocode}` — `\end{macrocode}` pairs is
+allowed. (The system allows for the driver to remain as is, and also makes it
+easy to paste a `.dtx` file into an `.edtx`, as using this utility on a `.dtx`
+does not change the file.)
+
+The utility furthermore replaces the first occurrence of `<filename>.edtx` in
+the header, followed by an optional parenthesized note, with `<filename>.dtx`,
+plus the note on how the file was generated.
+
+
+# OPTIONS
+
+**-c, \--comment**
+: The input comment character; the default is `%`. (Any input comment
+ characters in the header and the trailer will be replaced by the output
+ comment character, which is always `%`.)
+
+**-b, \--begin-macrocode** *regex*\
+
+**-e, \--end-macrocode** *regex*
+: Use these options to change the default *input* `\begin{macrocode}` and
+ `\end{macrocode}` markers. (The *output* markers are always
+ `\begin{macrocode}` and `\end{macrocode}`.) The markers should be given as
+ regular expressions matching the entire line. The input markers are not kept
+ in the file, i.e. they are replaced by the output markers.
+
+**-B, \--Begin-macrocode** *regex*\
+
+**-E, \--End-macrocode** *regex*
+: As `-b` and `-e`, but the input markers are kept in the output.
+
+**-s, \--strip-empty**
+: If this option is given, empty lines are not included in the output.
+
+**-h, \--help**
+: Show help and exit.
+
+**-V, \--version**
+: Show the version number and exit.
+
+
+# EXAMPLES
+
+If `input.edtx` is just like a `dtx` file, just without `\begin{macrocode}` and
+`\end{macrocode}` around every chunk of code:
+
+ edtx2dtx input.edtx > output.dtx
+
+Memoize uses the invocation below to produce a `.dtx` from documented Python
+code of `memoize-extract.py`. The value of `-c` adapts the `edtx2dtx` to
+Python comments. `-B` marks everything preceding the version number statement
+as a header, and keeps the version number statement in the output. Similarly,
+`-E` says that the processing should stop when encountering Emacs' local
+variables (which are kept, unchanged, in the output).
+
+ edtx2dtx -s -c '#' -B '^__version__' -E '^# Local Variables:' $< \
+
+
+
+# SEE ALSO
+
+[easydoctex.el](????)
Property changes on: trunk/Master/texmf-dist/doc/support/easydtx/edtx2dtx.1.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/easydtx/edtx2dtx.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/easydtx/edtx2dtx.pl 2024-11-24 17:37:46 UTC (rev 72951)
+++ trunk/Master/texmf-dist/scripts/easydtx/edtx2dtx.pl 2024-11-24 20:51:58 UTC (rev 72952)
@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
-# The files belonging to this work and covered by LPPL are listed in
+# The files belonging to this program and covered by GPL are listed in
# <texmf>/doc/support/easydtx/FILES.
use strict;
@@ -26,12 +26,28 @@
my $usage = <<END;
EasyDTX: convert .edtx into .dtx
-Usage: edtx2dtx filename.edtx > filename.dtx
+Usage: edtx2dtx [options] filename.edtx > filename.dtx
+Options: TODO
END
-my $VERSION = '0.1.0';
+my $VERSION = '0.2.0';
my ($help, $print_version);
+
+my $comment = '%';
+my $begin_macrocode = '^% \\\\begin{macrocode}';
+my $end_macrocode = '% \\\\end{macrocode}';
+my $Begin_macrocode = '';
+my $End_macrocode = '';
+my $strip = '';
+
+Getopt::Long::Configure (qw/bundling no_ignore_case/);
GetOptions(
+ "comment|c=s" => \$comment,
+ "begin-macrocode|b=s" => \$begin_macrocode,
+ "end-macrocode|e=s" => \$end_macrocode,
+ "Begin-macrocode|B=s" => \$Begin_macrocode,
+ "End-macrocode|E=s" => \$End_macrocode,
+ "strip-empty|s" => \$strip,
"help|h|?" => \$help,
"version|V" => \$print_version,
) or die $usage;
@@ -39,42 +55,76 @@
if ($print_version) { print("edtx2dtx $VERSION\n"); exit 0 }
die $usage unless @ARGV == 1;
+my $keep_begin_macrocode = '';
+my $keep_end_macrocode = '';
+if ($Begin_macrocode) {
+ $begin_macrocode = $Begin_macrocode;
+ $keep_begin_macrocode = 1;
+}
+if ($End_macrocode) {
+ $end_macrocode = $End_macrocode;
+ $keep_end_macrocode = 1;
+}
+
sub begin_macrocode { print("% \\begin{macrocode}\n"); }
sub end_macrocode { print("% \\end{macrocode}\n"); }
+# doc: replace initial in-comments with out-comments
+sub convert_comments { s/^\Q$comment\E+// && print('%' x length($&)); }
+
+my $indoc;
sub process_edtx {
- my $indoc = 1;
+ my $done;
+ my $empty;
while (<>) {
- if (/^% \\end{macrocode}/) { # trailer starts here
- end_macrocode unless ($indoc);
- last;
- } elsif (/^% \\begin{macrocode}/) {
- die "Nested \\begin{macrocode}";
- } elsif (/^ *(%%+)/) { # code: multiple comments
- begin_macrocode if ($indoc);
+ if (/$end_macrocode/) { # trailer starts here
+ if ($keep_end_macrocode) {
+ $done = 1;
+ } else {
+ end_macrocode unless $indoc;
+ last;
+ }
+ } elsif (/$begin_macrocode/) {
+ die "Nested '$begin_macrocode'";
+ }
+ if (/^ *(\Q$comment$comment\E+)/) { # code: multiple comments
+ begin_macrocode if $indoc;
+ print($empty); $empty = '';
print;
$indoc = 0;
- } elsif (/^%(<[^>]*>)(.*)$/) { # code: unindented guard
- begin_macrocode if ($indoc);
+ } elsif (/^\Q$comment\E(<[^>]*>)(.*)$/) { # code: unindented guard
+ begin_macrocode if $indoc;
print;
$indoc = 0;
- } elsif (/^( *)%(<[^>]*>) *(.*)$/) { # code: indented guard
- begin_macrocode if ($indoc);
+ } elsif (/^( *)\Q$comment\E(<[^>]*>) *(.*)$/) { # code: indented guard
+ begin_macrocode if $indoc;
print("%$2$1$3\n");
$indoc = 0;
- } elsif (/^% *(.*)$/) { # doc: unindented comment
- end_macrocode unless ($indoc);
+ } elsif (/^\Q$comment\E *(.*)$/) { # doc: unindented comment
+ end_macrocode unless $indoc;
+ convert_comments;
print;
$indoc = 1;
- } elsif (/^( ?)( *)% *(.*)$/) { # doc: indented comment
- end_macrocode unless ($indoc);
+ } elsif (/^( ?)( *)\Q$comment\E *(.*)$/) { # doc: indented comment
+ end_macrocode unless $indoc;
print "%$2$3\n";
$indoc = 1;
+ } elsif (/^\s*$/) { # code: empty line
+ if ($strip) {
+ $empty .= $_ unless $indoc;
+ } else {
+ print;
+ }
} else { # code
- begin_macrocode if ($indoc);
+ print($empty); $empty = '';
+ begin_macrocode if $indoc;
print;
$indoc = 0;
}
+ if ($done) {
+ end_macrocode unless $indoc;
+ last;
+ }
}
}
@@ -83,17 +133,25 @@
$dtx =~ s/\.edtx$/.dtx/;
my $first = 1;
+print("% \\iffalse\n%\n");
while (<>) {
if ($first and s/$edtx +(.*)/$dtx (generated from $edtx by edtx2dtx)/) {
print;
$first = 0;
- } elsif (/^% \\begin{macrocode}/) {
+ } elsif (/$begin_macrocode/) {
+ print("% \\fi\n%\n");
+ if ($keep_begin_macrocode) {
+ $indoc = 1 if /^\Q$comment\E/;
+ begin_macrocode unless $indoc;
+ print;
+ } else {
+ $indoc = 1;
+ }
process_edtx;
- } elsif (/^% \\end{macrocode}/) {
- die "\\end{macrocode} without the opening \\begin{macrocode}!";
+ } elsif (/$end_macrocode/) {
+ die "'$end_macrocode' without the opening '$begin_macrocode'!";
} else {
+ convert_comments;
print;
}
}
-
-
More information about the tex-live-commits
mailing list.