Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
from dataclasses import dataclass, field
|
| 4 |
from typing import List, Optional, Dict
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
|
| 7 |
import numpy as np
|
| 8 |
import pandas as pd
|
|
@@ -154,11 +155,38 @@ def get_path():
|
|
| 154 |
|
| 155 |
def display_dialogue(hf_path: str):
|
| 156 |
txt = load_text(hf_path)
|
| 157 |
-
|
| 158 |
-
st.markdown(
|
| 159 |
-
|
| 160 |
-
unsafe_allow_html=True)
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
def display_image(image_path):
|
| 163 |
with hf_fs.open(image_path) as f:
|
| 164 |
img = Image.open(f)
|
|
@@ -363,7 +391,7 @@ st.markdown(
|
|
| 363 |
div[data-testid="stMarkdownContainer"] > p {
|
| 364 |
font-size: 1rem;
|
| 365 |
}
|
| 366 |
-
section.main > div {max-width:
|
| 367 |
</style>
|
| 368 |
""", unsafe_allow_html=True)
|
| 369 |
|
|
|
|
| 3 |
from dataclasses import dataclass, field
|
| 4 |
from typing import List, Optional, Dict
|
| 5 |
from PIL import Image
|
| 6 |
+
import html
|
| 7 |
|
| 8 |
import numpy as np
|
| 9 |
import pandas as pd
|
|
|
|
| 155 |
|
| 156 |
def display_dialogue(hf_path: str):
|
| 157 |
txt = load_text(hf_path)
|
| 158 |
+
markdown_with_line_numbers(txt, title="Session Transcription")
|
| 159 |
+
#st.markdown(
|
| 160 |
+
# f"<details><summary><b>Herr Laus</b></summary><div>{txt}</div></details><br>",
|
| 161 |
+
#unsafe_allow_html=True)
|
| 162 |
+
|
| 163 |
+
def markdown_with_line_numbers(text: str, title: str | None = None):
|
| 164 |
+
# escape to avoid HTML injection, keep original newlines
|
| 165 |
+
escaped = html.escape(text)
|
| 166 |
+
lines = escaped.splitlines()
|
| 167 |
+
# keep blank lines visible so numbering doesn't collapse
|
| 168 |
+
body = "".join(f"<span>{ln or ' '}</span>" for ln in lines)
|
| 169 |
+
|
| 170 |
+
css = """
|
| 171 |
+
<style>
|
| 172 |
+
.ln pre { counter-reset: line; margin: 0; white-space: pre-wrap; }
|
| 173 |
+
.ln pre span { display: block; }
|
| 174 |
+
.ln pre span::before {
|
| 175 |
+
counter-increment: line;
|
| 176 |
+
content: counter(line);
|
| 177 |
+
display: inline-block;
|
| 178 |
+
width: 4ch; /* gutter width */
|
| 179 |
+
margin-right: 1ch;
|
| 180 |
+
text-align: right;
|
| 181 |
+
opacity: .6;
|
| 182 |
+
}
|
| 183 |
+
.ln { border: 1px solid #ddd; border-radius: .5rem; padding: .75rem; }
|
| 184 |
+
</style>
|
| 185 |
+
"""
|
| 186 |
+
st.markdown(css + (f"<p><b>{html.escape(title)}</b></p>" if title else "") +
|
| 187 |
+
f'<div class="ln"><pre>{body}</pre></div>',
|
| 188 |
+
unsafe_allow_html=True)
|
| 189 |
+
|
| 190 |
def display_image(image_path):
|
| 191 |
with hf_fs.open(image_path) as f:
|
| 192 |
img = Image.open(f)
|
|
|
|
| 391 |
div[data-testid="stMarkdownContainer"] > p {
|
| 392 |
font-size: 1rem;
|
| 393 |
}
|
| 394 |
+
section.main > div {max-width:100rem}
|
| 395 |
</style>
|
| 396 |
""", unsafe_allow_html=True)
|
| 397 |
|