mirror of
https://github.com/qurator-spk/dinglehopper.git
synced 2025-06-08 11:20:26 +02:00
🐛 dinglehopper: Escape text inserted into HTML (Fixes #8)
This commit is contained in:
parent
82e863fac2
commit
f32eb9eb69
1 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,7 @@ import os
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
from markupsafe import escape
|
||||||
|
|
||||||
|
|
||||||
from qurator.dinglehopper import *
|
from qurator.dinglehopper import *
|
||||||
|
@ -13,15 +14,17 @@ def gen_diff_report(gt_things, ocr_things, css_prefix, joiner, none, align):
|
||||||
|
|
||||||
def format_thing(t, css_classes=None):
|
def format_thing(t, css_classes=None):
|
||||||
if t is None:
|
if t is None:
|
||||||
t = none
|
html_t = none
|
||||||
css_classes += ' ellipsis'
|
css_classes += ' ellipsis'
|
||||||
if t == '\n':
|
elif t == '\n':
|
||||||
t = '<br>'
|
html_t = '<br>'
|
||||||
|
else:
|
||||||
|
html_t = escape(t)
|
||||||
|
|
||||||
if css_classes:
|
if css_classes:
|
||||||
return '<span class="{css_classes}">{t}</span>'.format(css_classes=css_classes, t=t)
|
return '<span class="{css_classes}">{html_t}</span>'.format(css_classes=css_classes, html_t=html_t)
|
||||||
else:
|
else:
|
||||||
return '{t}'.format(t=t)
|
return '{html_t}'.format(html_t=html_t)
|
||||||
|
|
||||||
for k, (g, o) in enumerate(align(gt_things, ocr_things)):
|
for k, (g, o) in enumerate(align(gt_things, ocr_things)):
|
||||||
if g == o:
|
if g == o:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue