Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -449,8 +449,13 @@ with tabs[1]:
|
|
449 |
# -------------------------------
|
450 |
# Diplomatic Edition Tab
|
451 |
# -------------------------------
|
|
|
|
|
|
|
|
|
452 |
with tabs[2]:
|
453 |
st.subheader("Diplomatic Edition")
|
|
|
454 |
# Select Inscription
|
455 |
inscription_numbers = df['Number'].tolist()
|
456 |
selected_inscription_num = st.selectbox("Select Inscription Number", inscription_numbers)
|
@@ -462,6 +467,36 @@ with tabs[2]:
|
|
462 |
inscription_elem = root.find(f".//inscription[@n='{selected_inscription_num}']")
|
463 |
text_element = inscription_elem.find("Text") if inscription_elem is not None else None
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
if text_element is not None:
|
466 |
diplomatic_text = render_diplomatic(text_element)
|
467 |
st.code(diplomatic_text, language="plaintext")
|
|
|
449 |
# -------------------------------
|
450 |
# Diplomatic Edition Tab
|
451 |
# -------------------------------
|
452 |
+
import streamlit as st
|
453 |
+
import xml.etree.ElementTree as ET
|
454 |
+
|
455 |
+
# Assuming 'tabs' and 'df' are already defined in your Streamlit app
|
456 |
with tabs[2]:
|
457 |
st.subheader("Diplomatic Edition")
|
458 |
+
|
459 |
# Select Inscription
|
460 |
inscription_numbers = df['Number'].tolist()
|
461 |
selected_inscription_num = st.selectbox("Select Inscription Number", inscription_numbers)
|
|
|
467 |
inscription_elem = root.find(f".//inscription[@n='{selected_inscription_num}']")
|
468 |
text_element = inscription_elem.find("Text") if inscription_elem is not None else None
|
469 |
|
470 |
+
def render_diplomatic(text_elem):
|
471 |
+
"""
|
472 |
+
Transforms the XML Text element into uppercase Greek text with line breaks at <lb> tags.
|
473 |
+
"""
|
474 |
+
lines = []
|
475 |
+
current_line = []
|
476 |
+
|
477 |
+
for elem in text_elem.iter():
|
478 |
+
if elem.tag == 'lb':
|
479 |
+
# When encountering an <lb> tag, finalize the current line
|
480 |
+
line_text = ''.join(current_line).strip().upper()
|
481 |
+
if line_text:
|
482 |
+
lines.append(line_text)
|
483 |
+
current_line = []
|
484 |
+
elif elem.text:
|
485 |
+
# Append text, handling any nested tags
|
486 |
+
current_line.append(elem.text)
|
487 |
+
if elem.tail:
|
488 |
+
# Append tail text after a nested tag
|
489 |
+
current_line.append(elem.tail)
|
490 |
+
|
491 |
+
# Add the last line if exists
|
492 |
+
if current_line:
|
493 |
+
line_text = ''.join(current_line).strip().upper()
|
494 |
+
if line_text:
|
495 |
+
lines.append(line_text)
|
496 |
+
|
497 |
+
# Join all lines with newline characters
|
498 |
+
return '\n'.join(lines)
|
499 |
+
|
500 |
if text_element is not None:
|
501 |
diplomatic_text = render_diplomatic(text_element)
|
502 |
st.code(diplomatic_text, language="plaintext")
|