diff options
author | Karl Berry <karl@freefriends.org> | 2023-10-11 20:32:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-10-11 20:32:41 +0000 |
commit | 9a9196eacd240c7126b5660aaf6d11c4ce30b111 (patch) | |
tree | 560d2a925744be951b096c48bd9e0d2394fe9f1c /Build | |
parent | 298e29eb95545e8c0feb6155d09db72c8c70a227 (diff) |
easydtx (11oct23)
git-svn-id: svn://tug.org/texlive/trunk@68514 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
4 files changed, 102 insertions, 0 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index fa1f3882543..40bcaa0a3a8 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -137,6 +137,7 @@ texmf_other_scripts = \ dosepsbin/dosepsbin.pl \ dviasm/dviasm.py \ dviinfox/dviinfox.pl \ + easydtx/edtx2dtx.pl \ ebong/ebong.py \ epspdf/epspdf.tlu \ epspdf/epspdftk.tcl \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index d978660158e..8766e9d1b9f 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -353,6 +353,7 @@ texmf_other_scripts = \ dosepsbin/dosepsbin.pl \ dviasm/dviasm.py \ dviinfox/dviinfox.pl \ + easydtx/edtx2dtx.pl \ ebong/ebong.py \ epspdf/epspdf.tlu \ epspdf/epspdftk.tcl \ diff --git a/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl b/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl new file mode 100755 index 00000000000..f3965b1a485 --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/easydtx/edtx2dtx.pl @@ -0,0 +1,99 @@ +#!/usr/bin/env perl + +# This file is a part of TeX package EasyDTX, available at +# https://ctan.org/pkg/easydtx and https://github.com/sasozivanovic/easydtx. +# +# Copyright (c) 2023- Saso Zivanovic <saso.zivanovic@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/>. +# +# The files belonging to this work and covered by LPPL are listed in +# <texmf>/doc/support/easydtx/FILES. + +use strict; +use Getopt::Long; + +my $usage = <<END; +EasyDTX: convert .edtx into .dtx +Usage: edtx2dtx filename.edtx > filename.dtx +END + +my $VERSION = '0.1.0'; +my ($help, $print_version); +GetOptions( + "help|h|?" => \$help, + "version|V" => \$print_version, + ) or die $usage; +if ($help) {print($usage); exit 0} +if ($print_version) { print("edtx2dtx $VERSION\n"); exit 0 } +die $usage unless @ARGV == 1; + +sub begin_macrocode { print("% \\begin{macrocode}\n"); } +sub end_macrocode { print("% \\end{macrocode}\n"); } + +sub process_edtx { + my $indoc = 1; + 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); + print; + $indoc = 0; + } elsif (/^%(<[^>]*>)(.*)$/) { # code: unindented guard + begin_macrocode if ($indoc); + print; + $indoc = 0; + } elsif (/^( *)%(<[^>]*>) *(.*)$/) { # code: indented guard + begin_macrocode if ($indoc); + print("%$2$1$3\n"); + $indoc = 0; + } elsif (/^% *(.*)$/) { # doc: unindented comment + end_macrocode unless ($indoc); + print; + $indoc = 1; + } elsif (/^( ?)( *)% *(.*)$/) { # doc: indented comment + end_macrocode unless ($indoc); + print "%$2$3\n"; + $indoc = 1; + } else { # code + begin_macrocode if ($indoc); + print; + $indoc = 0; + } + } +} + +my $edtx = @ARGV[0]; +my $dtx = $edtx; +$dtx =~ s/\.edtx$/.dtx/; + +my $first = 1; +while (<>) { + if ($first and s/$edtx +(.*)/$dtx (generated from $edtx by edtx2dtx)/) { + print; + $first = 0; + } elsif (/^% \\begin{macrocode}/) { + process_edtx; + } elsif (/^% \\end{macrocode}/) { + die "\\end{macrocode} without the opening \\begin{macrocode}!"; + } else { + print; + } +} + + diff --git a/Build/source/texk/texlive/linked_scripts/scripts.lst b/Build/source/texk/texlive/linked_scripts/scripts.lst index 580b7712739..3eb5c2aef55 100644 --- a/Build/source/texk/texlive/linked_scripts/scripts.lst +++ b/Build/source/texk/texlive/linked_scripts/scripts.lst @@ -79,6 +79,7 @@ digestif/digestif.texlua dosepsbin/dosepsbin.pl dviasm/dviasm.py dviinfox/dviinfox.pl +easydtx/edtx2dtx.pl ebong/ebong.py epspdf/epspdf.tlu epspdf/epspdftk.tcl |