viklofg commited on
Commit
d2d5258
·
1 Parent(s): dae80b9

Update transcription panel

Browse files

- add horizontal divider between regions

app/assets/jinja-templates/transcription CHANGED
@@ -1,10 +1,17 @@
1
- {%- for line in lines -%}
 
 
2
  <span
3
- class="textline line{{loop.index}}"
4
- onmouseover="document.querySelectorAll('.line{{loop.index}}').forEach(element => {element.classList.add('highlighted')});"
5
  onmouseout="document.querySelectorAll('*').forEach(element => {element.classList.remove('highlighted')});"
6
  >
7
  {{line.text}}
8
  </span>
9
  <br>
 
 
 
 
 
10
  {% endfor %}
 
1
+ {% set count = namespace(value=1) -%}
2
+ {% for region in regions -%}
3
+ {% for line in region -%}
4
  <span
5
+ class="textline line{{count.value}}"
6
+ onmouseover="document.querySelectorAll('.line{{count.value}}').forEach(element => {element.classList.add('highlighted')});"
7
  onmouseout="document.querySelectorAll('*').forEach(element => {element.classList.remove('highlighted')});"
8
  >
9
  {{line.text}}
10
  </span>
11
  <br>
12
+ {% set count.value = count.value + 1 %}
13
+ {% endfor %}
14
+ {% if not loop.last %}
15
+ <hr class="region-divider">
16
+ {%endif%}
17
  {% endfor %}
app/gradio_config.py CHANGED
@@ -41,4 +41,9 @@ span.highlighted {
41
  font-size: large;
42
  }
43
 
 
 
 
 
 
44
  """
 
41
  font-size: large;
42
  }
43
 
44
+ hr.region-divider {
45
+ margin-top: 0.5em;
46
+ margin-bottom: 0.5em;
47
+ }
48
+
49
  """
app/tabs/visualizer.py CHANGED
@@ -12,7 +12,8 @@ def render_image(collection, current_page_index):
12
 
13
 
14
  def render_transcription(collection, current_page_index):
15
- return _TRANSCRIPTION_TEMPLATE.render(lines=collection[current_page_index].traverse(lambda node: node.is_line()))
 
16
 
17
 
18
  def toggle_navigation_button(collection):
 
12
 
13
 
14
  def render_transcription(collection, current_page_index):
15
+ regions = collection[current_page_index].traverse(lambda node: node.children and all(child.is_line() for child in node))
16
+ return _TRANSCRIPTION_TEMPLATE.render(regions=regions)
17
 
18
 
19
  def toggle_navigation_button(collection):