diff options
Diffstat (limited to 'Build')
3 files changed, 140 insertions, 0 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index d27610a7fd4..ca56decda93 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -1,5 +1,6 @@ ## Makefile.am for the TeX Live subdirectory texk/texlive/linked_scripts/ ## +## Copyright (C) 2016 Karl Berry <tex-live@tug.org> ## Copyright (C) 2009-2015 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## @@ -147,6 +148,7 @@ texmf_other_scripts = \ musixtex/musixflx.lua \ musixtex/musixtex.lua \ oberdiek/pdfatfi.pl \ + parades/parades.py \ pax/pdfannotextractor.pl \ pdfcrop/pdfcrop.pl \ pedigree-perl/pedigree.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index 4191059aab6..2c6bf3927b1 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -363,6 +363,7 @@ texmf_other_scripts = \ musixtex/musixflx.lua \ musixtex/musixtex.lua \ oberdiek/pdfatfi.pl \ + parades/parades.py \ pax/pdfannotextractor.pl \ pdfcrop/pdfcrop.pl \ pedigree-perl/pedigree.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/parades/parades.py b/Build/source/texk/texlive/linked_scripts/parades/parades.py new file mode 100755 index 00000000000..5a8741b1fdf --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/parades/parades.py @@ -0,0 +1,137 @@ +# Paragraph designer generation +import sys, time, os.path +styles_438dsg48 = [] + +def add_style(style): + styles_438dsg48.append(style) + return style + +class ParagraphOptions: + + def __init__(self, **kw): + arg_names = ('cmd', 'parent', 'space_above', 'space_below', 'fontsize', 'baseline', 'fontcmd', 'stylecmd', 'boxes', 'leftskip', 'moresetup', 'afterpar', 'env', 'hsize', 'preamble_arg1', 'preamble_arg2', 'preamble_arg3', 'preamble_arg4') + cmd = kw.get('stylecmd') # 'cmd' or 'stylecmd' are required + if not cmd: + cmd = kw['cmd'] + parent = kw.get('parent', None) + if parent: + for arg in arg_names: + if ('cmd' == arg) or ('stylecmd' == arg): + setattr(self, arg, None) + continue + setattr(self, arg, getattr(parent, arg)) + else: + for arg in arg_names: + setattr(self, arg, None) + for (arg, val) in kw.iteritems(): + if not (arg in arg_names): + raise AttributeError(arg) + setattr(self, arg, val) + + # + # Print style as an internal command + # + def get_style_string(self): + s = '' + #if self.space_above: + # s = "\\ParaSpaceAbove{%s}" % self.space_above + fontcmd = self.fontcmd + if self.fontsize and self.baseline: + s = s + "\\fontsize{%s}{%s}" % (self.fontsize, self.baseline) + if not fontcmd: + fontcmd = '\\selectfont' + if fontcmd: + s = s + fontcmd + return s + + # + # Print the style as command + # + def print_command(self, h): + if self.stylecmd: + s_style = self.get_style_string() + h.write("\\newcommand{\\%s}{%s}%%\n" % (self.stylecmd, s_style)) + if not self.cmd: + return + if self.boxes: + n_boxes = len(self.boxes) + else: + n_boxes = 0 + n_lastarg = n_boxes + 1 + h.write("\\newcommand{\\%s}[%i]{{%%\n" % (self.cmd, n_lastarg)) + self.write_para_setup(h) + if self.boxes: + if self.leftskip: + h.write("\\advance\\pd@leftskip by %s " % self.leftskip) + self.print_boxes(h) + h.write("%\n\\the\\everypar ") + s_after_par = self.get_after_para() + if self.hsize: + h.write("\\hsize=%s\\relax\n" % self.hsize) + preamble_attr = 'preamble_arg' + str(n_lastarg) + s_preamble = getattr(self, preamble_attr, None) + if s_preamble is None: + s_preamble = '' + h.write("%s#%i\\par}%s}\n" % (s_preamble, n_lastarg, s_after_par)) + + def print_env(self, h): + if not self.env: + return + h.write("\\newenvironment{%s}{" % self.env) + self.write_para_setup(h) + h.write("\ignorespaces}\n{") + ap = self.get_after_para() + if ap: + h.write("\\par\\global\\def\\pd@after@para{%s}\\aftergroup\\pd@after@para" % ap) + h.write("}\n") + + def write_para_setup(self, h): + # "space_above" before "moresetup" because the latter + # may contain a call to "headbreaker" + s_style = self.get_style_string() + h.write(s_style) + spa = self.space_above or '0pt' + if '#natural' != spa: + h.write("%%\n\\ParaSpaceAbove{%s}" % spa) + if self.moresetup: + h.write("%%\n%s" % self.moresetup) + h.write("%\n\\noindent ") + + def get_after_para(self): + s_after_par = '' + if self.afterpar: + s_after_par = self.afterpar + if '#natural' != self.space_below: + spb = self.space_below or '0pt' + s_after_par = s_after_par + ('\\ParaSpaceBelow{%s}' % spb) + return s_after_par + + def print_boxes(self, h): + box_i = 0 + for box in self.boxes: + box_i = box_i + 1 + (offset, width) = box + h.write("%%\n\\hbox to 0pt{\\hss\\hbox to %s{#%i\\hss}\\dimen0=%s " % (width, box_i, self.leftskip)) + h.write("%%\n\\advance\\dimen0 by -%s \\advance\\dimen0 by -%s \\hskip\\dimen0}" % (offset, width)) + +def print_styles(h): + for style in styles_438dsg48: + h.write("\n") + style.print_command(h) + style.print_env(h) + +# +# Command-line +# +def main(codeword): + h = sys.stdout + if len(sys.argv) > 1: + file_name = sys.argv[1] + h = open(file_name, 'w') + s_name = os.path.splitext(os.path.basename(file_name))[0] + s_date = time.strftime('%Y/%m/%d') + h.write("\\ProvidesPackage{%s}[%s Automatically generated paragraph styles for: %s]\n" % (s_name, s_date, s_name)) + h.write("% RTL hook\n\\let\\pd@leftskip=\\leftskip\n") + print_styles(h) + if h != sys.stdout: + h.close() |