diff abctemplate.py @ 594:60749c792cde

Replace Change and Credit with Markdown-enabled Notes section. Data in Notes is taken from N: section starting "Dottes:".
author Jim Hague <jim.hague@acm.org>
date Wed, 02 Nov 2016 15:02:06 +0000
parents afc031477784
children ed823ea54c83
line wrap: on
line diff
--- a/abctemplate.py	Wed Nov 02 14:59:31 2016 +0000
+++ b/abctemplate.py	Wed Nov 02 15:02:06 2016 +0000
@@ -56,30 +56,20 @@
         lines = f.readlines()
 
     input_path = pathlib.Path(args.input.name)
+    fname = input_path.stem
+    fdir = input_path.parent
 
     vars = dict()
-    vars["changename"] = ""
-    vars["changetitle"] = ""
-    vars["changevisibility"] = "no"
-    vars["creditvisibility"] = "no"
+    vars["notesvisibility"] = "no"
 
-    vars["name"] = input_path.stem
-    vars["title"] = getFieldDisplayText(lines, "T", latex=args.latex)
-    vars["subtitle"] = getFieldDisplayText(lines, "T", n=2, latex=args.latex)
-    vars["composer"] = getFieldDisplayText(lines, "C", latex=args.latex)
-    vars["key"] = getFieldDisplayText(lines, "K", latex=args.latex)
-    vars["changefile"] = getFieldDisplayText(lines, "N", starts="Change:", latex=args.latex)
-    vars["credit"] = getFieldDisplayText(lines, "N", starts="Credit:", latex=args.latex)
-
-    if vars["changefile"]:
-        vars["changevisibility"] = "yes"
-        vars["changename"] = pathlib.Path(vars["changefile"]).stem
-        cf = pathlib.Path(input_path.parent, vars["changefile"])
-        with cf.open() as f:
-            vars["changetitle"] = getFieldDisplayText(f, "T", latex=args.latex)
-
-    if vars["credit"]:
-        vars["creditvisibility"] = "yes"
+    vars["name"] = fname
+    vars["title"] = getFieldDisplayText(lines, fdir, "T", latex=args.latex)
+    vars["subtitle"] = getFieldDisplayText(lines, fdir, "T", n=2, latex=args.latex)
+    vars["composer"] = getFieldDisplayText(lines, fdir, "C", latex=args.latex)
+    vars["key"] = getFieldDisplayText(lines, fdir, "K", latex=args.latex)
+    vars["notes"] = getFieldDisplayText(lines, fdir, "N", starts="Dottes:", latex=args.latex)
+    if vars["notes"]:
+        vars["notesvisibility"] = "yes"
 
     for val in args.values:
         keyval = val.partition("=")