feat: intermediate project

This commit is contained in:
Krzysztof Rudnicki 2023-04-26 05:51:56 +02:00
parent 0ca2a44e2a
commit dffd938862
3 changed files with 172 additions and 0 deletions

13
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,13 @@
{
"recommendations": [
"mhutchie.git-graph",
"pkief.material-icon-theme",
"ms-python.black-formatter",
"ms-python.pylint",
"ms-python.python",
"wesbos.theme-cobalt2",
"donjayamanne.githistory",
"kisstkondoros.vscode-gutter-preview",
"james-yu.latex-workshop"
]
}

View File

@ -1,5 +1,14 @@
\documentclass[12pt]{article}
\usepackage{listings}
\lstset{
basicstyle=\small,
breaklines=true
}
\date{\today}
\title{ECOTE - preliminary project \\
Translator of a LaTeX subset to HTML
@ -23,9 +32,21 @@ I decided to change to translator of \LaTeX \, subset to HTML since I know \LaTe
\item "Tables" will be represented using \LaTeX \, \emph{table} environment
\end{itemize}
\section{Functional requirements}
The goal of the project is to transform .tex file to (working ) .html file if the subset of .tex file is within project scope or output error message explaining why the html could not be outputed
\subsection{\LaTeX \, subset}
This project will focus almost exclusively on \emph{table} environment \\
more speciffically table environment containing tabular inside of it
\begin{enumerate}
\item $\backslash$documentclass\{class\}: Defines what layout standard \LaTeX will use
\item $\backslash$begin\{document\}: Ends (in our case empty) preamble
\item $\backslash$end\{document\}: Ends \LaTeX \, document
\item $\backslash$textit\{Text\}: Makes the text italic.
\item $\backslash$underline\{Text\}: Underlines the text.
\item $\backslash$begin\{itemize\} $\backslash$item Item 1 $\backslash$item Item 2 $\backslash$end\{itemize\}: Creates an unordered list with the given items.
\item $\backslash$begin\{enumerate\} $\backslash$item Item 1 $\backslash$item Item 2 $\backslash$end\{enumerate\}: Creates an ordered list with the given items.
\item $\backslash$begin\{center\} Text $\backslash$end\{center\}: Centers the text.
\item $\backslash$begin\{tabular\}\{|c|c|c|\} $\backslash$hline Column 1 \& Column 2 \& Column 3 $\backslash$ $\backslash$hline Row 1, Column 1 \& Row 1, Column 2 \& Row 1, Column 3 $\backslash$ Row 2, Column 1 \& Row 2, Column 2 \& Row 2, Column 3 $\backslash$ $\backslash$hline $\backslash$end\{tabular\}: Creates a table with the given columns and rows.
\end{enumerate}
\section{Implementation}
I decided to use Python as a language in which I will implement my solution \\
The reasons for using python are as follow:
@ -37,9 +58,147 @@ The reasons for using python are as follow:
Negative aspects of python which is that it is very slow language do not bother me as I believe the project scope will not be big enough for this to become an issue
\subsection{General architecture}
\subsection{Data structures}
\subsection{Module descriptions}
\subsection{Input/output description}
Input is a .tex file (\LaTeX \, file) \\
Outpus is an .html file \\
In case of errors error message will be outputed on the terminal \\
Input File path is entered as an argument to terminal with "-i" or "--input" flag for example:
\begin{lstlisting}[language=bash]
python main.py -i texFile.tex
\end{lstlisting}
Output file path can be named by user by using "-o" or "--output" flag:
\begin{lstlisting}[language=bash]
python main.py -i texFile.tex -o htmlFile.html
\end{lstlisting}
If no "-o" flag is issued the output file will have the same name as input file with changed extension to html (so in this example texFile.tex will become texFile.html) \\
If the path to file name consists of spaces, path name needs to be but in ""
\begin{lstlisting}[language=bash]
python main.py -i "My Folder/input.tex"
\end{lstlisting}
\subsection{Others}
\section{Functional test cases}
\begin{tabular}{|p{3cm}|p{6cm}|p{6cm}|}
\hline
Title & Input (\LaTeX) & Output \\
\hline
empty file &
\begin{lstlisting}
\end{lstlisting}&
\begin{lstlisting}
Error! expected \documentclass at the begining of LaTeX file
\end{lstlisting} \\
\hline
Document class &
\begin{lstlisting}
\documentclass[options]{class}
\end{lstlisting}&
\begin{lstlisting}
Error! expected \begin{document} after document class
\end{lstlisting} \\
\hline
\begin{lstlisting}
Extra text between document class and begin document
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
"extra text"
\begin{document}
\end{lstlisting}&
\begin{lstlisting}
Error! unexpected text between document class and begin document
\end{lstlisting} \\
\hline
\begin{lstlisting}
Just document class and begin document
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
\begin{document}
\end{lstlisting}&
\begin{lstlisting}
Error! no \end{document} at the end of LaTeX code
\end{lstlisting} \\
\hline
\end{tabular}
\begin{tabular}{|p{3cm}|p{6cm}|p{6cm}|}
\hline
Title & Input (\LaTeX) & Output \\
\hline
\begin{lstlisting}
Just document class and begin/end document
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
\begin{document}
\end{document}
\end{lstlisting}&
\begin{lstlisting}
<html>
</html>
\end{lstlisting} \\
\hline
\begin{lstlisting}
Plain text inside
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
\begin{document}
Lorem ipsum dolor sit amet.
\end{document}
\end{lstlisting}&
\begin{lstlisting}
<html>
Lorem ipsum dolor sit amet.
</html>
\end{lstlisting} \\
\hline
\begin{lstlisting}
Reduntant \end{document} (ignored)
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
\begin{document}
Lorem ipsum dolor sit amet.
\end{document}
\end{document}
\end{lstlisting}&
\begin{lstlisting}
<html>
Lorem ipsum dolor sit amet.
</html>
\end{lstlisting} \\
\hline
\begin{lstlisting}
LaTeX comments
\end{lstlisting}&
\begin{lstlisting}
\documentclass[options]{class}
\begin{document}
Lorem ipsum dolor sit amet.
% some comment
\end{document}
\end{document}
\end{lstlisting}&
\begin{lstlisting}
Error! LaTeX comment detected at line 3
\end{lstlisting} \\
\hline
\end{tabular}
\end{document}