From 0e8c7d3175f18bd3bbb7cafae7762691f432eacc Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 7 Jun 2023 08:36:53 +0200 Subject: [PATCH 1/4] fix: erroneous unit test and missplaced whitespace --- program/code/main.py | 4 ++-- program/unit_tests/test_code/test_translate_inside_to_html.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/program/code/main.py b/program/code/main.py index 5f366675..df52084e 100644 --- a/program/code/main.py +++ b/program/code/main.py @@ -329,7 +329,7 @@ def translate_column(latex_column): """ 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, "
") replaced_newline = replaced_hline.replace("\newline", "
") return replaced_newline @@ -498,7 +498,7 @@ def handle_table_whole(html_string, data, table_start, table_end): parameters_start_index = data.find( "{", 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_array = tabular_required_parameters(parameters_string) inside_table = data[parameters_end_index + 1: table_end] diff --git a/program/unit_tests/test_code/test_translate_inside_to_html.py b/program/unit_tests/test_code/test_translate_inside_to_html.py index db469183..d55e8957 100644 --- a/program/unit_tests/test_code/test_translate_inside_to_html.py +++ b/program/unit_tests/test_code/test_translate_inside_to_html.py @@ -6,7 +6,9 @@ def given_correct_then_correct(): latex_string = "test & 2 & test \\ 4 & 5 & 6 \\" parameters_string = "{ l | c | r }" column_styles = tabular_required_parameters(parameters_string) - assert translate_inside_to_html(latex_string, column_styles) == "
test 2 test
4 5 6
" + assert translate_inside_to_html(latex_string, column_styles) == "
test 2 test
4 5 6
" + + def test_translate_inside_to_html(): From 24105e4606657c8cf0375176afd9b4361fc613d2 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 7 Jun 2023 16:19:44 +0200 Subject: [PATCH 2/4] feat: update tests --- .../PASScomplicatedTable/texfilelonger.pdf | Bin 3184 -> 3188 bytes .../PASScomplicatedTable/texfilelonger.tex | 1 + .../PassparametersTable/texfilelonger.pdf | Bin 3184 -> 3183 bytes .../PassparametersTable/texfilelonger.tex | 2 +- .../texfilelonger.tex.html | 2 +- 5 files changed, 3 insertions(+), 2 deletions(-) diff --git a/program/code/functional_tests/PASScomplicatedTable/texfilelonger.pdf b/program/code/functional_tests/PASScomplicatedTable/texfilelonger.pdf index 548a103b1a0c8b232dee44f1f6b2b78def22b2e1..c9802064293bbd91fa7c1c04596ac6c7976e46c8 100644 GIT binary patch delta 1054 zcmV+(1mXMe81xvhP62;2K0XR_baG{3Z3=kWU6D;|!!Qhn@BS4!c8rp*CG8*twv@6! zyN{$DyE?X#1sdBp&LRJPi5+^Fz=lWCD@(GM7l%T02E0!#S%n6gPH>Hb95q9zvF!v2 zLf{=UE7_a%R1q&fQ}s@J1h4#gJAHpWp3bH0sR;aSiS2l!dV7Dp9D@WnHZJ=zDTHw4 z;!sV4!M+fUgft~E*O`kCMo+ML;j+eu#rL5(>Q1z`@r-NtW4ifoqRR zj)S5MH5DzA)SoSb^f+5aQ1E~8y;Ic<`=xrxj>0+H_meoYw6_$k^z7)#QtUFLz*6F9 z7deVuEOF#?JEtg1UR^A-{j4u9oh>W9Z`i1nf zaRPz{e=7sXi!++{$E-hA(PZ+4&nt=>T@B!Yw)6nHZT4*g7FueI?ijrb43s}K{iJO|)!>l6=KJ({cYwzM zf1@n)Bt8y@eV$yGi@2e|;=&|A7d;d0*ypIu5YLAFm0h)`p1ShqaT6ChV{hnSXxnz= zxGZtOh>>p@F$(-p1$HD+cB(`tRNRC_uhXNCSr{(FrhRI<%&UdbjRVCjuBr2`AFi(N zex6_7to1G~C63mVwMASR_~uwQv|E+Wf4U2(4yLJoqM`UvrBvl*Hdv)hMBW^S zeA9kk(9W=g%)80IpgO7YJx|pvis^E350;PO-fU5~AD^oIjTh58F`0aHg|QlWBm-M) zxTZUB10L1>it_BG$4p zmPMS^;Bww$K^-Nf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vANxYHvUz+})=s&p` zy^nl!Bfb`iPMHSrhpiu18gmKSyb-70|DC=saz+zKJXi4xc1<{ zHZ(9WG&M70IAb_wIASt0F*P}4Wn?xmVLm)CW-%~hGB!3eFfcSVGh;YoIA%CvGBYtX zIb>yIHZWn6zYAh4t}Ke7Bnq@SeX^QhfjNVuIh!LVokQGUq5MiA_0p+$OS^LX%k{tl U;PC{=lT8dC2r&vJB}Gq03eF4kdjJ3c diff --git a/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex b/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex index 781e89ce..81ca65c5 100644 --- a/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex +++ b/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex @@ -1,4 +1,5 @@ \documentclass{article} + \begin{document} \begin{tabular}{ l | c | r } test & 2 & test \\ diff --git a/program/code/functional_tests/PassparametersTable/texfilelonger.pdf b/program/code/functional_tests/PassparametersTable/texfilelonger.pdf index a820f09f430dac5382932df71e9f33440c86d7a7..d93913e5d24e7782ccbf790f7b45cc719b9014b1 100644 GIT binary patch delta 1237 zcmV;`1SVma%Ev{3V7OukG)PqF$_j`p5l9fy0LR@#}Z;dDoAV< z*$@jLy3nB$uaDbX)L*!YEK6UU93O1JD0vtza0_aI_jLx3Su5Ok%pVv*VPfc?XhIg4 z8529Bf4tn5Vo^$!?AwaF*Zzb>#|BiRDZatn$W`;zklnF9BwZ@hir@>+SYE*JqMX7a`ADn{wM23&T=ffUv5g)EAciO5$$i;1L4$u zO7;X`x&yRE%{)ETN%ODqQstMvy!ipAad&5v5dk`XFg`vCb98cLVQmU{+Fg-NYlJWm zhVTB0Ic_P7U)9|O5n5$IsBO`eJ;!9Ufi($H5B~dVB70~cfoEpkWaf>V6?q}}1n!TP zw8jZKE||tq&YB{$*mL3d0WeOdoy4=Kk~jeFD&ym%7dX5#+2YF<`_>FK7d;%BtTvH) zR_cKRiU~X?P0e+_ZI4QZqaqYF5j{GIx2_bD>$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^!9&tJ%uSSY+dzrQV7w?<*}XygMBGl30dX=__K@;Mo+MLXR^VUC3evaH5VOhZbfY) z^{CVXdlUu&FVF3Dp=*yyhJzv$H4zNuLKgCI?E zOM6T4N(V=8mJ(MPhn7-DyVz0Ua;YPy+c_s)`r&es?Pq;?>1?s|=_nnwp69c^Tj!P` zxxnYwD5(~e-G3n%h6%H80+I%QPTN2beeYMy8;MY|vtC~jij+$uqC!DQ3aG{p#vY6% z#~b;AlE3e)9cYnSsebUz<;?8NoLLVL6u1fkkd^`qr0;P}ZN~i|U zgp2KQPvVXN{Hv&JxEy1i^DV5^p=;Dr><6}Hf6G`YzU65hstzM=D9z)UK7`1+6F6hb z2j7-sKRCtDD~cOk4d9Ws^a#3b_H6?eT562$7`+Qr${w12(l()La7f?sefqLHz|(+H z7J3q&hQmHjuFFN-&|qvH*_$xZ98&Y zmbhTV$hV9b1%9XkJCZ0nRiYCrZbG8h>Cwk53>RY4J~v(F)xzk;fnpZd)Oqjk*PGj) z=hruDy^BkUqcvr15myGjIo1vBR^^NCh{^K0sg8qbs-I~nZmX1ks=UkwtCWezo8ypg z+V2b68J3WFH~AM-Csn@ZshUMGT`nHL@=-jPE$a5;Q?09=Yr_C!kcF?7o8LCINLKs;Ag0v;?ue7{Kta!wEGA*-$0L8M1 zvl?8^dn~Ag;>Gqkm7&AeMPSiXTtEuslxUjkN#L^an-%$<63} zAWJ{kYPYOVH+xIQ{-_^^Y=VG=aoZ6~6!&cqZ19ObaYRIW;meHZWp2 zV>D(oIA$f1D sG&Es2WHOVw3t$Np;kGQ%3nkH@lOqfw16>5dlSm972r&vJB}Gq03ipvrQUCw| diff --git a/program/code/functional_tests/PassparametersTable/texfilelonger.tex b/program/code/functional_tests/PassparametersTable/texfilelonger.tex index 82045dde..f54117c5 100644 --- a/program/code/functional_tests/PassparametersTable/texfilelonger.tex +++ b/program/code/functional_tests/PassparametersTable/texfilelonger.tex @@ -1,7 +1,7 @@ \documentclass{article} \usepackage{array} \begin{document} -\begin{tabular}{ p{1pt} | m{1pt} | b{1pt} } +\begin{tabular}{ p{30pt} | m{5pt} | b{5pt} } test & 2 & test \\ 4 & 5 & 6 \\ \end{tabular} diff --git a/program/code/functional_tests/PassparametersTable/texfilelonger.tex.html b/program/code/functional_tests/PassparametersTable/texfilelonger.tex.html index 22ef8842..891544a1 100644 --- a/program/code/functional_tests/PassparametersTable/texfilelonger.tex.html +++ b/program/code/functional_tests/PassparametersTable/texfilelonger.tex.html @@ -1 +1 @@ -
test 2 test
4 5 6
\ No newline at end of file +
test 2 test
4 5 6
\ No newline at end of file From f3e5d300079d46a93414011deacb4ee4caa49829 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 7 Jun 2023 16:26:37 +0200 Subject: [PATCH 3/4] fix: handle_line_strings access correct column number --- .../PASScomplicatedTable/texfilelonger.tex.html | 2 +- program/code/main.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex.html b/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex.html index 91adcdef..b7090eed 100644 --- a/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex.html +++ b/program/code/functional_tests/PASScomplicatedTable/texfilelonger.tex.html @@ -1 +1 @@ -
test 2 test
4 5 6
\ No newline at end of file +
test 2 test
4 5 6
\ No newline at end of file diff --git a/program/code/main.py b/program/code/main.py index df52084e..9b7c045c 100644 --- a/program/code/main.py +++ b/program/code/main.py @@ -340,12 +340,12 @@ def handle_line_strings(line_string, """ Converts lines untill there are no more lines """ - current_style = column_style[column_number - 1] + current_style = column_style[column_number] if current_style == line_string: while current_style == line_string: return_string += line_string column_number += 1 - current_style = column_style[column_number - 1] + current_style = column_style[column_number] return return_string, column_number From 86e444464568baeeaf1c114d697b45b1477e954d Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 7 Jun 2023 16:39:56 +0200 Subject: [PATCH 4/4] fix: unit test --- program/unit_tests/test_code/test_translate_inside_to_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/unit_tests/test_code/test_translate_inside_to_html.py b/program/unit_tests/test_code/test_translate_inside_to_html.py index d55e8957..a949a1a5 100644 --- a/program/unit_tests/test_code/test_translate_inside_to_html.py +++ b/program/unit_tests/test_code/test_translate_inside_to_html.py @@ -6,7 +6,7 @@ def given_correct_then_correct(): latex_string = "test & 2 & test \\ 4 & 5 & 6 \\" parameters_string = "{ l | c | r }" column_styles = tabular_required_parameters(parameters_string) - assert translate_inside_to_html(latex_string, column_styles) == "
test 2 test
4 5 6
" + assert translate_inside_to_html(latex_string, column_styles) == "
test 2 test
4 5 6
"