mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:23:11 +02:00
feat: make functional tests work
This commit is contained in:
parent
a52cef8dbc
commit
fc0b625df0
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html>Error!
|
<!DOCTYPE html><html><table><tr><td align='left'>1 </td><td align='center'> 2 </td><td align='right'> 3 </td></tr><tr><td align='left'></td></tr><tr></tr><tr><td align='left'></td></tr><tr><td align='left'></td></tr></table>
|
||||||
Binary file not shown.
@ -1,10 +1,7 @@
|
|||||||
\documentclass{article}
|
\documentclass{article}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{tabular}{ l | c | r }
|
\begin{tabular}{ l | c | r }
|
||||||
\hline
|
|
||||||
test & 2 & test \\
|
test & 2 & test \\
|
||||||
\hline
|
|
||||||
4 & 5 & 6 \\
|
4 & 5 & 6 \\
|
||||||
\hline
|
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{document}
|
\end{document}
|
||||||
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html>Error!</tr></table>
|
<!DOCTYPE html><html><table><tr><td align='left'>test </td><td style='border-left: 1px solid black'> 2 </td><td style='border-left: 1px solid black'style='border-left: 1px solid black'> test </td></tr><tr><td align='left'></td></tr><tr><td align='left'>4 </td><td style='border-left: 1px solid black'> 5 </td><td style='border-left: 1px solid black'style='border-left: 1px solid black'> 6 </td></tr><tr><td align='left'></td></tr><tr><td align='left'></td></tr></table>
|
||||||
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
\documentclass{article}
|
||||||
|
\usepackage{array}
|
||||||
|
\begin{document}
|
||||||
|
\begin{tabular}{ p{1pt} | m{1pt} | b{1pt} }
|
||||||
|
test & 2 & test \\
|
||||||
|
4 & 5 & 6 \\
|
||||||
|
\end{tabular}
|
||||||
|
\end{document}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<!DOCTYPE html><html><table><tr><td style='vertical-align: top; width: 1.3px;'>test </td><td style='border-left: 1px solid black'> 2 </td><td style='border-left: 1px solid black'style='border-left: 1px solid black'> test </td></tr><tr><td style='vertical-align: top; width: 1.3px;'></td></tr><tr><td style='vertical-align: top; width: 1.3px;'>4 </td><td style='border-left: 1px solid black'> 5 </td><td style='border-left: 1px solid black'style='border-left: 1px solid black'> 6 </td></tr><tr><td style='vertical-align: top; width: 1.3px;'></td></tr><tr><td style='vertical-align: top; width: 1.3px;'></td></tr></table>
|
||||||
@ -319,6 +319,8 @@ def split_columns(table_row, column_count):
|
|||||||
"""
|
"""
|
||||||
columns = table_row.split("&")
|
columns = table_row.split("&")
|
||||||
if len(columns) != column_count and columns != [""]:
|
if len(columns) != column_count and columns != [""]:
|
||||||
|
print(
|
||||||
|
f"Error! extracted columns length: {columns} and columns_count: {column_count} is different!")
|
||||||
return "Error!"
|
return "Error!"
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
@ -327,7 +329,7 @@ def translate_column(latex_column):
|
|||||||
"""
|
"""
|
||||||
Translate insides of a single latex tabular column to html
|
Translate insides of a single latex tabular column to html
|
||||||
"""
|
"""
|
||||||
hline_string_literal = "\\hline"
|
hline_string_literal = "hline"
|
||||||
replaced_hline = latex_column.replace(hline_string_literal, "<hr>")
|
replaced_hline = latex_column.replace(hline_string_literal, "<hr>")
|
||||||
replaced_newline = replaced_hline.replace("\newline", "<br>")
|
replaced_newline = replaced_hline.replace("\newline", "<br>")
|
||||||
return replaced_newline
|
return replaced_newline
|
||||||
@ -338,12 +340,12 @@ def handle_line_strings(line_string,
|
|||||||
"""
|
"""
|
||||||
Converts lines untill there are no more lines
|
Converts lines untill there are no more lines
|
||||||
"""
|
"""
|
||||||
current_style = column_style[column_number]
|
current_style = column_style[column_number - 1]
|
||||||
if current_style == line_string:
|
if current_style == line_string:
|
||||||
while current_style == line_string:
|
while current_style == line_string:
|
||||||
return_string += line_string
|
return_string += line_string
|
||||||
column_number += 1
|
column_number += 1
|
||||||
current_style = column_style[column_number]
|
current_style = column_style[column_number - 1]
|
||||||
return return_string, column_number
|
return return_string, column_number
|
||||||
|
|
||||||
|
|
||||||
@ -374,12 +376,14 @@ def handle_latex_columns(columns, column_style,
|
|||||||
"""
|
"""
|
||||||
Goes through every column in a row and translates it to html
|
Goes through every column in a row and translates it to html
|
||||||
"""
|
"""
|
||||||
for column in columns:
|
|
||||||
return_string, column_number = handle_single_column(column,
|
if columns != "Error!":
|
||||||
column_style,
|
for column in columns:
|
||||||
column_number,
|
return_string, column_number = handle_single_column(column,
|
||||||
line_string,
|
column_style,
|
||||||
return_string)
|
column_number,
|
||||||
|
line_string,
|
||||||
|
return_string)
|
||||||
return return_string, column_number
|
return return_string, column_number
|
||||||
|
|
||||||
|
|
||||||
@ -494,8 +498,7 @@ def handle_table_whole(html_string, data, table_start, table_end):
|
|||||||
|
|
||||||
parameters_start_index = data.find(
|
parameters_start_index = data.find(
|
||||||
"{", table_start + len(tabular_begin_string))
|
"{", table_start + len(tabular_begin_string))
|
||||||
|
parameters_end_index = data.find(" }", parameters_start_index)
|
||||||
parameters_end_index = data.find("}", parameters_start_index)
|
|
||||||
parameters_string = data[parameters_start_index: parameters_end_index + 1]
|
parameters_string = data[parameters_start_index: parameters_end_index + 1]
|
||||||
parameters_array = tabular_required_parameters(parameters_string)
|
parameters_array = tabular_required_parameters(parameters_string)
|
||||||
inside_table = data[parameters_end_index + 1: table_end]
|
inside_table = data[parameters_end_index + 1: table_end]
|
||||||
@ -537,7 +540,7 @@ def main_function(tex_filename):
|
|||||||
when reading documentclass or begin document""")
|
when reading documentclass or begin document""")
|
||||||
return "Error"
|
return "Error"
|
||||||
html_string, data = handle_insides(html_string, data)
|
html_string, data = handle_insides(html_string, data)
|
||||||
|
html_string = html_string.replace('}', '')
|
||||||
return html_string
|
return html_string
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user