diff abcfield.py @ 716:f620323ff96d

Add subtitle if present in tune links.
author Jim Hague <jim.hague@acm.org>
date Mon, 09 Oct 2017 17:30:31 +0100
parents 972d3dab1142
children f8ab14cc9d8d
line wrap: on
line diff
--- a/abcfield.py	Mon Oct 09 16:38:38 2017 +0100
+++ b/abcfield.py	Mon Oct 09 17:30:31 2017 +0100
@@ -181,7 +181,12 @@
         fname = m.group(1) + ".abc"
         path = pathlib.Path(dir, fname)
         with path.open() as f:
-            return "[" + getFieldDisplayText(f, dir, "T", latex) + "](" + fname + ")"
+            title = getFieldDisplayText(f, dir, "T", latex=latex)
+            f.seek(0)
+            subtitle = getFieldDisplayText(f, dir, "T", n=2, latex=latex)
+            if len(subtitle) > 0:
+                title = title + " (" + subtitle + ")"
+            return "[" + title + "](" + fname + ")"
     return re.sub(r'<(.*?).abc>', getTitle, t)
 
 # Return the raw text for a given field. Optionally the nth field is taken,