Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enable references with text in Django
  • Loading branch information
kthoden committed Sep 29, 2020
1 parent 6b1107a commit dbff85f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/eoatex2imxml.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2020-09-04 19:14:09 (kthoden)>
# Time-stamp: <2020-09-29 11:26:51 (kthoden)>

"""
Converts Latex files into a customized DocBook XML file.
Expand Down Expand Up @@ -1038,7 +1038,11 @@ def process_references(xmlTree):

eoarefs = xmlTree.xpath("//EOAref")
for ref in eoarefs:
ref.set("type", "number")
reftype = ref.get("type")
if reftype == "text":
pass
else:
ref.set("type", "number")
ref_element = ref.find("./ref")
target_attribute = ref.xpath("./ref/@target")
ref_label = ref.find("./Label").text
Expand Down
17 changes: 13 additions & 4 deletions src/imxml2django.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2020-09-11 16:38:19 (kthoden)>
# Time-stamp: <2020-09-29 11:38:15 (kthoden)>

"""
Create an XML file that can be inserted into the Django database
Expand Down Expand Up @@ -1702,14 +1702,23 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe
tmpTail = xmlReference.tail or ""

originalcontents = xmlReference.find("originalcontents")
if xmlReference.get("type") == "collage":

ref_is_text = False
ref_is_collage = False

reference_type = xmlReference.get("type")
if reference_type == "collage":
ref_is_collage = True
else:
ref_is_collage = False
elif reference_type == "text":
ref_is_text = True
reference_text = xmlReference.text.strip()

xmlReference.clear()
if originalcontents is not None:
logging.info("Found originalcontents")
xmlReference.append(originalcontents)
elif ref_is_text:
xmlReference.text = reference_text
else:
xmlReference.text = strResult
xmlReference.tail = tmpTail
Expand Down

0 comments on commit dbff85f

Please sign in to comment.