diff --git a/program/README.md b/program/README.md new file mode 100644 index 00000000..9c884d58 --- /dev/null +++ b/program/README.md @@ -0,0 +1,9 @@ +To run unit tests: +Enter project environment: + +source /ecote/bin/activate + +Run tests: + +python -m pytest unit_tests + diff --git a/program/code/functional_tests/texfile.tex b/program/code/functional_tests/texfile.tex new file mode 100644 index 00000000..0c46d149 --- /dev/null +++ b/program/code/functional_tests/texfile.tex @@ -0,0 +1,15 @@ +\documentclass{article} +\begin{document} +some random text +\begin{tabular}{c} + inside table +\end{tabular} +some random text 2 +\begin{tabular}{c} + inside table2 +\end{tabular} + +\begin{tabular}{c} + inside table3 +\end{tabular} +\end{document} \ No newline at end of file diff --git a/program/code/functional_tests/texfile.tex.html b/program/code/functional_tests/texfile.tex.html new file mode 100644 index 00000000..eeda3484 --- /dev/null +++ b/program/code/functional_tests/texfile.tex.html @@ -0,0 +1 @@ +some random text
inside table
some random text 2
inside table2
inside table3
\ No newline at end of file diff --git a/program/code/functional_tests/texfilecolumnswrong.tex b/program/code/functional_tests/texfilecolumnswrong.tex new file mode 100644 index 00000000..5f7a98e6 --- /dev/null +++ b/program/code/functional_tests/texfilecolumnswrong.tex @@ -0,0 +1,7 @@ +\documentclass{class} +\begin{document} +\begin{tabular}{ l c r } +1 & 2 & 3 \\ +4 & 5 6 \\ +\end{tabular} +\end{document} \ No newline at end of file diff --git a/program/code/functional_tests/texfilecolumnswrong.tex.html b/program/code/functional_tests/texfilecolumnswrong.tex.html new file mode 100644 index 00000000..33e82118 --- /dev/null +++ b/program/code/functional_tests/texfilecolumnswrong.tex.html @@ -0,0 +1 @@ +Error! \ No newline at end of file diff --git a/program/code/functional_tests/texfilelonger.tex b/program/code/functional_tests/texfilelonger.tex new file mode 100644 index 00000000..4bc0aa29 --- /dev/null +++ b/program/code/functional_tests/texfilelonger.tex @@ -0,0 +1,9 @@ +\documentclass{class} +\begin{document} +\begin{tabular}{ l | c | r } +test & 2 & test \\ +4 & 5 & 6 \\ +\end{tabular} +\end{document} +\end{lstlisting}& +\begin{lstlisting} \ No newline at end of file diff --git a/program/code/functional_tests/texfilelonger.tex.html b/program/code/functional_tests/texfilelonger.tex.html new file mode 100644 index 00000000..31ed8b4a --- /dev/null +++ b/program/code/functional_tests/texfilelonger.tex.html @@ -0,0 +1 @@ +
test 2 test
4 5 6
\ No newline at end of file diff --git a/program/code/latex_classes/latex_classes.py b/program/code/latex_classes/latex_classes.py deleted file mode 100644 index 616f1d46..00000000 --- a/program/code/latex_classes/latex_classes.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Holds an array of all classes from https://ctan.org/topic/class -""" -classes = [ - "article", - "report", - "book", - "beamer", - "letter", - "memoir", - "slides", - "IEEEtran", - "exam", - "amsart", - "amsbook", - "tufte-book", - "scrartcl", - "scrreprt", - "moderncv", - "cv", - "res", - "elsarticle", - "acm_proc_article-sp", - "scrbook", -] - - -def return_latex_classes(): - """Returns latex classes array""" - return classes diff --git a/program/code/main.py b/program/code/main.py index 53c328ff..f81ba830 100644 --- a/program/code/main.py +++ b/program/code/main.py @@ -217,6 +217,10 @@ def translate_inside_to_html(latex_table_inside, column_style): column_number = 0 for column in columns: return_string += "= len(column_style): + print( + f"Error! column_number index: {column_number} is out of length of column_style: {column_style}") + return "Error!" current_style = column_style[column_number] while current_style == line_string: return_string += line_string @@ -315,8 +319,7 @@ def handle_insides(html_string, data): return html_string, data -def main_function(): - tex_filename = "texfile.tex" +def main_function(tex_filename): data = read_file(tex_filename) html_string = "" html_string, data = read_start(html_string, data) @@ -329,4 +332,7 @@ def main_function(): if __name__ == "__main__": - print(main_function()) + tex_filename = "texfile.tex" + final_html = main_function(tex_filename) + f = open(tex_filename + ".html", "w") + f.write(final_html) diff --git a/program/code/texfile.pdf b/program/code/texfile.pdf deleted file mode 100644 index d2c1749d..00000000 Binary files a/program/code/texfile.pdf and /dev/null differ diff --git a/program/code/texfile.tex.html b/program/code/texfile.tex.html new file mode 100644 index 00000000..eeda3484 --- /dev/null +++ b/program/code/texfile.tex.html @@ -0,0 +1 @@ +some random text
inside table
some random text 2
inside table2
inside table3
\ No newline at end of file diff --git a/program/tests/test_code/__init__.py b/program/tests/test_code/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/program/code/latex_classes/__init__.py b/program/unit_tests/__init__.py similarity index 100% rename from program/code/latex_classes/__init__.py rename to program/unit_tests/__init__.py diff --git a/program/tests/__init__.py b/program/unit_tests/test_code/__init__.py similarity index 100% rename from program/tests/__init__.py rename to program/unit_tests/test_code/__init__.py diff --git a/program/tests/test_code/test_begin_document.py b/program/unit_tests/test_code/test_begin_document.py similarity index 100% rename from program/tests/test_code/test_begin_document.py rename to program/unit_tests/test_code/test_begin_document.py diff --git a/program/tests/test_code/test_begin_tabular.py b/program/unit_tests/test_code/test_begin_tabular.py similarity index 100% rename from program/tests/test_code/test_begin_tabular.py rename to program/unit_tests/test_code/test_begin_tabular.py diff --git a/program/tests/test_code/test_document_class.py b/program/unit_tests/test_code/test_document_class.py similarity index 100% rename from program/tests/test_code/test_document_class.py rename to program/unit_tests/test_code/test_document_class.py diff --git a/program/tests/test_code/test_length_conversions.py b/program/unit_tests/test_code/test_length_conversions.py similarity index 100% rename from program/tests/test_code/test_length_conversions.py rename to program/unit_tests/test_code/test_length_conversions.py diff --git a/program/tests/test_code/test_only_pipes_and_space.py b/program/unit_tests/test_code/test_only_pipes_and_space.py similarity index 100% rename from program/tests/test_code/test_only_pipes_and_space.py rename to program/unit_tests/test_code/test_only_pipes_and_space.py diff --git a/program/tests/test_code/test_split_columns.py b/program/unit_tests/test_code/test_split_columns.py similarity index 100% rename from program/tests/test_code/test_split_columns.py rename to program/unit_tests/test_code/test_split_columns.py diff --git a/program/tests/test_code/test_split_rows.py b/program/unit_tests/test_code/test_split_rows.py similarity index 100% rename from program/tests/test_code/test_split_rows.py rename to program/unit_tests/test_code/test_split_rows.py diff --git a/program/tests/test_code/test_tabular_columns_parameters.py b/program/unit_tests/test_code/test_tabular_columns_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_columns_parameters.py rename to program/unit_tests/test_code/test_tabular_columns_parameters.py diff --git a/program/tests/test_code/test_tabular_parameters.py b/program/unit_tests/test_code/test_tabular_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_parameters.py rename to program/unit_tests/test_code/test_tabular_parameters.py diff --git a/program/tests/test_code/test_tabular_required_parameters.py b/program/unit_tests/test_code/test_tabular_required_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_required_parameters.py rename to program/unit_tests/test_code/test_tabular_required_parameters.py diff --git a/program/tests/test_code/test_translate_column.py b/program/unit_tests/test_code/test_translate_column.py similarity index 100% rename from program/tests/test_code/test_translate_column.py rename to program/unit_tests/test_code/test_translate_column.py diff --git a/program/tests/test_code/test_translate_inside_to_html.py b/program/unit_tests/test_code/test_translate_inside_to_html.py similarity index 100% rename from program/tests/test_code/test_translate_inside_to_html.py rename to program/unit_tests/test_code/test_translate_inside_to_html.py