Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove whitespace from citation popups
  • Loading branch information
kthoden committed Jul 31, 2019
1 parent 9f817d6 commit 17407af
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tei2imxml.py
Expand Up @@ -226,6 +226,17 @@ def make_publication_cfg(info_dict, translation_file):
# def make_publication_cfg ends here


def sanitize_data_string(text_string):
"""Remove line breaks and multiple spaces"""

text_string = text_string.replace('\r', '').replace('\n', '')

return_string = re.sub("\s\s+" , " ", text_string)

return return_string.strip()
# def sanitize_data_string ends here


def check_bibliography(xml_tree):
"""Check TEI header for bibliography data, return relevant data as dictionary."""

Expand Down Expand Up @@ -599,8 +610,10 @@ def handle_refs_hyperimage(ref):
logging.error("Citekey %s was not found in the references. Exiting." % citekey)
sys.exit(1)

citation.text = formatted_citation
citation.set("data-title", formatted_citation)
sanitized_citation_string = sanitize_data_string(formatted_citation)

citation.text = sanitized_citation_string
citation.set("data-title", sanitized_citation_string)
citation.set("data-content", cited_data[citekey][2])

#############
Expand Down

0 comments on commit 17407af

Please sign in to comment.