mirror of https://github.com/Nonannet/pyladoc.git
Compare commits
No commits in common. "71f211022f81aa977e0d332c36db447e81b28bba" and "10ace61abc92d4c6dab830d8d80e5c8151f4d97e" have entirely different histories.
71f211022f
...
10ace61abc
|
@ -277,6 +277,7 @@ def inject_to_template(fields_dict: dict[str, str],
|
|||
raise Exception('No template provided')
|
||||
|
||||
def replace_field(match: re.Match[str]) -> str:
|
||||
print('--->', match.group(0))
|
||||
return fields_dict.get(match.group(1), match.group(0))
|
||||
|
||||
return re.sub(r"(?:\%+\s*)?\<!--(.*?)-->", replace_field, template, 0, re.MULTILINE)
|
||||
|
|
|
@ -131,7 +131,7 @@ def render_pandas_styler_table(df_style: Styler, caption: str = '', label: str =
|
|||
yield '\\centering\n'
|
||||
|
||||
# Guess column type
|
||||
numeric = re.compile('^[<>\\-\u2212]?\\s*(?:\\d+,?)+(?:\\.\\d+)?(?:\\s\\D.*)?$')
|
||||
numeric = re.compile('^[<>-\u2212]?\\s*(?:\\d+,?)+(?:\\.\\d+)?(?:\\s\\D.*)?$')
|
||||
formats = ['S' if all(
|
||||
(numeric.match(line[ci]['display_value'].strip()) for line in table['body'])
|
||||
) else 'l' for ci in range(len(table['body'][0])) if table['body'][0][ci]['is_visible']]
|
||||
|
|
|
@ -68,8 +68,7 @@ unicode_to_latex_dict = {
|
|||
'£': r'{\pounds}',
|
||||
'¥': r'{\yen}',
|
||||
'\u00A0': r'~', # Non-breaking space
|
||||
'\u2007': ' ', # Figure space
|
||||
'\u2212': '-' # Unicode minus sign
|
||||
'\u2007': ' ' # Figure space
|
||||
}
|
||||
|
||||
latex_escape_dict = {
|
||||
|
|
|
@ -71,11 +71,11 @@ def make_document():
|
|||
mydataset = {
|
||||
'Row1': ["Line1", "Line2", "Line3", "Line4", "Line5"],
|
||||
'Row2': [120, '95 km/h', 110, '105 km/h', 130],
|
||||
'Row3': ['12 g/km', '> 150 g/km', '-110 g/km', '1140 g/km', '\u221213.05 g/km'],
|
||||
'Row3': ['12 g/km', '> 150 g/km', '110 g/km', '1140 g/km', '13.05 g/km'],
|
||||
'Row4': ['5 stars', '4 stars', '5 stars', '4.5 stars', '5 stars'],
|
||||
'Row5': [3.5, 7.8, 8.5, 6.9, 4.2],
|
||||
'Row6': ['1850 kg', '150 kg', '140 kg', '1600 kg', '17.55 kg'],
|
||||
'Row7': ['600 Nm', '250 Nm', '280,8 Nm', '320 Nm', '450 Nm']
|
||||
'Row6': ['1850 kg', '1500 kg', '1400 kg', '1600 kg', '1700 kg'],
|
||||
'Row7': ['600 Nm', '250 Nm', '280 Nm', '320 Nm', '450 Nm']
|
||||
}
|
||||
df = pd.DataFrame(mydataset)
|
||||
|
||||
|
@ -98,13 +98,9 @@ def test_html_render():
|
|||
def test_latex_render():
|
||||
doc = make_document()
|
||||
|
||||
latex_code = doc.to_latex()
|
||||
|
||||
assert r'\begin{tabular}{lSSSSSS}' in latex_code, "Table format not correct in LaTeX output"
|
||||
|
||||
if WRITE_RESULT_FILES:
|
||||
with open('tests/out/test_html_render2.tex', 'w', encoding='utf-8') as f:
|
||||
f.write(latex_code)
|
||||
f.write(doc.to_latex())
|
||||
|
||||
assert doc.to_pdf('tests/out/test_latex_render2.pdf', font_family='serif')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue