Now shapes.html.j2 is a complete template for the shapes.html page.
./mkshapes.sh
touch shapes
-shapes.html : shapes mkshhtml.py html.html shapes.3 record.gif record2.gif sdlshapes.png templates/shapes.html.j2
- ./mkshhtml.py < shapelist > shapes.html
- cat html.html >> shapes.html
- cat shapes.3 >> shapes.html
+shapes.html : shapes mkshhtml.py html.html record.gif record2.gif sdlshapes.png templates/shapes.html.j2 shapelist
+ ./mkshhtml.py html.html < shapelist > shapes.html
lang.html : grammar lang.1 lang.2 mklang
./mklang grammar gramtmp
#!/usr/bin/env python3
+# Generates shapes.html. Takes path to an html.html file to include as argv[1],
+# and a shapelist on stdin.
-from dataclasses import dataclass
import jinja2
import markupsafe
-import re
import sys
-from typing import List, Dict
+from typing import List
-N_PER_ROW=4
+N_PER_ROW = 4
-shapes = []
-for line in sys.stdin:
- shape = line.strip()
- shapes.append(shape)
+shapes = [line.strip() for line in sys.stdin]
# From https://stackoverflow.com/a/312464/171898
def chunks(lst, n):
undefined=jinja2.StrictUndefined,
)
template = env.get_template('shapes.html.j2')
-print(template.render(rows=chunks(shapes, N_PER_ROW)))
+print(template.render(
+ html=markupsafe.Markup(open(sys.argv[1]).read()),
+ rows=chunks(shapes, N_PER_ROW),
+))
+++ /dev/null
-<H2><A NAME=epsf>User-defined Nodes</A></H2>
-
-There is a third type of node shape which is specified by the user.
-Typically, these shapes rely on the details of a concrete graphics
-format. At present, shapes can be described using PostScript, via a
-file or add-on library, for use in PostScript output, or shapes can
-be specified by a bitmap-image file for use with SVG or bitmap (jpeg,
-gif, etc.) output. More information can be found on the page
-<A HREF="../../../faq/#FaqCustShape">
-How to create custom shapes</A>.
-
-<H2><A NAME=sdlshapes>SDL Shapes for PostScript</A></H2>
-One example of user-defined node shapes is provided by Mark Rison of CSR.
-These are the <A HREF=http://www.sdl-forum.org/SDL/index.htm>SDL</A> shapes.
-These are available as PostScript functions whose use is described in
-<A HREF="../../../faq/#ext_ps_proc"> External PostScript procedures</A>.
-The necessary PostScript library file and sample use can be found in the
-<tt>contrib/sdlshapes</tt> directory in the release. Please note the
-COPYRIGHT AND PERMISSION NOTICE contained in the library file <tt>sdl.ps</tt>.
-<P>
-The table below
-gives the shape names and the corresponding node shapes.
-<P>
-<CENTER>
-<IMG SRC=sdlshapes.png>
-</CENTER>
-</BODY>
-</HTML>
<P>
Additional styles may be available with a specific code generator.
+{{ html -}}
+<H2><A NAME=epsf>User-defined Nodes</A></H2>
+
+There is a third type of node shape which is specified by the user.
+Typically, these shapes rely on the details of a concrete graphics
+format. At present, shapes can be described using PostScript, via a
+file or add-on library, for use in PostScript output, or shapes can
+be specified by a bitmap-image file for use with SVG or bitmap (jpeg,
+gif, etc.) output. More information can be found on the page
+<A HREF="../../../faq/#FaqCustShape">
+How to create custom shapes</A>.
+
+<H2><A NAME=sdlshapes>SDL Shapes for PostScript</A></H2>
+One example of user-defined node shapes is provided by Mark Rison of CSR.
+These are the <A HREF=http://www.sdl-forum.org/SDL/index.htm>SDL</A> shapes.
+These are available as PostScript functions whose use is described in
+<A HREF="../../../faq/#ext_ps_proc"> External PostScript procedures</A>.
+The necessary PostScript library file and sample use can be found in the
+<tt>contrib/sdlshapes</tt> directory in the release. Please note the
+COPYRIGHT AND PERMISSION NOTICE contained in the library file <tt>sdl.ps</tt>.
+<P>
+The table below
+gives the shape names and the corresponding node shapes.
+<P>
+<CENTER>
+<IMG SRC=sdlshapes.png>
+</CENTER>
+</BODY>
+</HTML>