Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Type attribute for all citations
Signed-off-by: kthoden <kthoden@gwdg.de>
  • Loading branch information
kthoden committed Feb 8, 2019
1 parent d10db01 commit cbf263b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fix_tei.py
Expand Up @@ -156,17 +156,17 @@ def convert_citations(string, citedrangetext):
year_citations = re.findall(year_citations_pattern, string)
logging.info("Found %s year citations." % len(year_citations))
if citedrangetext:
string = re.sub(year_citations_pattern, r"<bibl><ref type='inline' target='#\g<citekey>'/><citedRange>\g<pages></citedRange></bibl>", string)
string = re.sub(year_citations_pattern, r"<bibl><ref type='year' target='#\g<citekey>'/><citedRange>\g<pages></citedRange></bibl>", string)
else:
string = re.sub(year_citations_pattern, r"<bibl><ref type='inline' target='#\g<citekey>'/><citedRange from='\g<pages>'/></bibl>", string)
string = re.sub(year_citations_pattern, r"<bibl><ref type='year' target='#\g<citekey>'/><citedRange from='\g<pages>'/></bibl>", string)

authoryear_citation_pattern = re.compile(r"(§|&#xA7;|&#167;)(?P<citekey>.+?)(\!(?P<pages>.*?))?(§|&#xA7;|&#167;)")
authoryear_citations = re.findall(authoryear_citation_pattern, string)
logging.info("Found %s author/year citations." % len(authoryear_citations))
if citedrangetext:
string = re.sub(authoryear_citation_pattern, r"<bibl><ref target='#\g<citekey>'/><citedRange>\g<pages></citedRange></bibl>", string)
string = re.sub(authoryear_citation_pattern, r"<bibl><ref type='authoryear' target='#\g<citekey>'/><citedRange>\g<pages></citedRange></bibl>", string)
else:
string = re.sub(authoryear_citation_pattern, r"<bibl><ref target='#\g<citekey>'/><citedRange from='\g<pages>'/></bibl>", string)
string = re.sub(authoryear_citation_pattern, r"<bibl><ref type='authoryear' target='#\g<citekey>'/><citedRange from='\g<pages>'/></bibl>", string)

for year_citation in year_citations:
citations.append(year_citation[2])
Expand Down

0 comments on commit cbf263b

Please sign in to comment.