summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-03-29 20:00:15 +0000
committerKarl Berry <karl@freefriends.org>2023-03-29 20:00:15 +0000
commit9fa41d1fc8f435a890f121050e2920d593b9dfff (patch)
tree39a033bfc90c52a768050d474ce2d2907a9f4783 /Master/texmf-dist/doc
parenta995526c1114d8fef2fe8b1f065e7a4a06750908 (diff)
songproj (28mar23)
git-svn-id: svn://tug.org/texlive/trunk@66704 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
-rwxr-xr-xMaster/texmf-dist/doc/latex/songproj/song2tex.py26
-rw-r--r--Master/texmf-dist/doc/latex/songproj/songproj.pdfbin100783 -> 131017 bytes
2 files changed, 16 insertions, 10 deletions
diff --git a/Master/texmf-dist/doc/latex/songproj/song2tex.py b/Master/texmf-dist/doc/latex/songproj/song2tex.py
index dc32da2b3fa..270a9ef7214 100755
--- a/Master/texmf-dist/doc/latex/songproj/song2tex.py
+++ b/Master/texmf-dist/doc/latex/songproj/song2tex.py
@@ -8,6 +8,7 @@ import re
# The following regexp match the typical markers of refrain and couplet:
re_refrain = re.compile(r'(R(efrain)?|C(horus)?)( |[-./] ?)', re.IGNORECASE)
re_couplet = re.compile(r'\d+( |[-./] ?)')
+re_txt_ext = re.compile(r'\.te?xt$')
def match_rest(regexp, s):
@@ -41,35 +42,35 @@ def parse_song(lines, re_refrain, re_couplet):
yield '\\begin{refrain}\n'
state = State.REFRAIN
line = rest
- yield ' {} \\\\\n'.format(line)
+ yield ' {}'.format(line)
elif (rest := match_rest(re_couplet, line)) is not None:
# when a couplet start marker is found, enter a couplet.
yield '\\begin{couplet}\n'
state = State.COUPLET
line = rest
- yield ' {} \\\\\n'.format(line)
+ yield ' {}'.format(line)
elif line != '':
# when a non-empty line is found, also enter a couplet as all.
yield '\\begin{couplet}\n'
state = State.COUPLET
- yield ' {} \\\\\n'.format(line)
+ yield ' {}'.format(line)
elif state == State.REFRAIN:
# We are in the refrain. Depending on what we find:
if line != '':
# when a non-empty line is found, stay in the refrain.
- yield ' {} \\\\\n'.format(line)
+ yield ' \\\\\n {}'.format(line)
else:
# when an empty line is found, leave the refrain.
- yield '\\end{refrain}\n\n'
+ yield '\n\\end{refrain}\n\n'
state = State.LIMBO
elif state == State.COUPLET:
# We are in a couplet. Depending on what we find:
if line != '':
# when a non-empty line is found, stay in the couplet.
- yield ' {} \\\\\n'.format(line)
+ yield ' \\\\\n {}'.format(line)
else:
# when an empty line is found, leave the couplet.
- yield '\\end{couplet}\n\n'
+ yield '\n\\end{couplet}\n\n'
state = State.LIMBO
# No matter what we found, we have a song line, possibly empty, that we
# have to check to see if it could not be the new longest line seen so far.
@@ -78,9 +79,9 @@ def parse_song(lines, re_refrain, re_couplet):
# The song text file is now finished. We may still be in the refrain or in a
# couplet, that we have to close.
if state == State.REFRAIN:
- yield '\\end{refrain}\n\n'
+ yield '\n\\end{refrain}\n\n'
elif state == State.COUPLET:
- yield '\\end{couplet}\n\n'
+ yield '\n\\end{couplet}\n\n'
# Now print the longest line of the entire song.
yield '\\longest{{{}}}\n'.format(longest)
@@ -92,8 +93,13 @@ def main(args=None):
parser.add_argument("--couplet", '-c', type=re.compile, default=re_couplet, metavar="REGEXP",
help="specify the couplet marker (regexp, default \"{}\")".format(re_couplet.pattern))
parser.add_argument("infile", help="input song text file", type=argparse.FileType('r'))
- parser.add_argument("outfile", help="output LaTeX file", type=argparse.FileType('w'))
+ parser.add_argument("outfile", help="output LaTeX file", type=argparse.FileType('w'), nargs='?')
args = parser.parse_args(args)
+ if args.outfile is None:
+ try:
+ args.outfile = open(re_txt_ext.sub('', args.infile.name) + '.tex', 'w')
+ except AttributeError:
+ parser.error("the following argument is required: outfile")
for line in parse_song(args.infile, args.refrain, args.couplet):
args.outfile.write(line)
diff --git a/Master/texmf-dist/doc/latex/songproj/songproj.pdf b/Master/texmf-dist/doc/latex/songproj/songproj.pdf
index 24216ce1505..1329f0e9863 100644
--- a/Master/texmf-dist/doc/latex/songproj/songproj.pdf
+++ b/Master/texmf-dist/doc/latex/songproj/songproj.pdf
Binary files differ