Mercurial > dottes
comparison 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 |
comparison
equal
deleted
inserted
replaced
715:77cc2f932587 | 716:f620323ff96d |
---|---|
179 # title of the tune as the text of the link. | 179 # title of the tune as the text of the link. |
180 def getTitle(m): | 180 def getTitle(m): |
181 fname = m.group(1) + ".abc" | 181 fname = m.group(1) + ".abc" |
182 path = pathlib.Path(dir, fname) | 182 path = pathlib.Path(dir, fname) |
183 with path.open() as f: | 183 with path.open() as f: |
184 return "[" + getFieldDisplayText(f, dir, "T", latex) + "](" + fname + ")" | 184 title = getFieldDisplayText(f, dir, "T", latex=latex) |
185 f.seek(0) | |
186 subtitle = getFieldDisplayText(f, dir, "T", n=2, latex=latex) | |
187 if len(subtitle) > 0: | |
188 title = title + " (" + subtitle + ")" | |
189 return "[" + title + "](" + fname + ")" | |
185 return re.sub(r'<(.*?).abc>', getTitle, t) | 190 return re.sub(r'<(.*?).abc>', getTitle, t) |
186 | 191 |
187 # Return the raw text for a given field. Optionally the nth field is taken, | 192 # Return the raw text for a given field. Optionally the nth field is taken, |
188 # or the field data must start with a designated string to be recognised. | 193 # or the field data must start with a designated string to be recognised. |
189 def getFieldText(inf, field, n = 1, starts = None): | 194 def getFieldText(inf, field, n = 1, starts = None): |