diff options
| -rw-r--r-- | src/latex.ml | 4 | ||||
| -rw-r--r-- | test/latex/main.tex | 4 | ||||
| -rw-r--r-- | test/latex/reference-type.commands.tex.exp | 54 | ||||
| -rw-r--r-- | test/latex/reference-type.sail | 27 | ||||
| -rwxr-xr-x | test/latex/run_tests.sh | 2 |
5 files changed, 86 insertions, 5 deletions
diff --git a/src/latex.ml b/src/latex.ml index 96a74e06..a4265686 100644 --- a/src/latex.ml +++ b/src/latex.ml @@ -241,7 +241,7 @@ let latex_of_markdown str = | Paragraph elems -> let prepend = if state.noindent then (state.noindent <- false; "\\noindent ") else "" in prepend ^ format elems ^ "\n\n" - | Text str -> Str.global_replace (Str.regexp_string "_") "\\_" str + | Text str -> text_code str | Emph elems -> sprintf "\\emph{%s}" (format elems) | Bold elems -> sprintf "\\textbf{%s}" (format elems) | Ref (r, "THIS", alt, _) -> @@ -505,7 +505,7 @@ let defs (Defs defs) = identifiers then outputs the correct mangled command. *) let id_command cat ids = sprintf "\\newcommand{\\%s%s}[1]{\n " !opt_prefix (category_name cat) - ^ Util.string_of_list "%\n " (fun id -> sprintf "\\ifstrequal{#1}{%s}{\\%s}{}" (string_of_id id) (latex_cat_id cat id)) + ^ Util.string_of_list "%\n " (fun id -> sprintf "\\ifstrequal{#1}{%s}{\\%s}{}" (text_code (string_of_id id)) (latex_cat_id cat id)) (IdSet.elements ids) ^ "}" |> string diff --git a/test/latex/main.tex b/test/latex/main.tex index 154ad0c2..a0948482 100644 --- a/test/latex/main.tex +++ b/test/latex/main.tex @@ -24,10 +24,10 @@ \begin{document} \clearpage -type: \sailtype{cap_uperms_width} +type: \sailtype{cap\_uperms\_width} \clearpage -reftytpe: \sailreftype{cap\_uperms\_width}{ref to cap\_uperms\_width} +ref type: \sailreftype{cap\_uperms\_width}{ref to cap\_uperms\_width} \clearpage val: \sailval{main} diff --git a/test/latex/reference-type.commands.tex.exp b/test/latex/reference-type.commands.tex.exp new file mode 100644 index 00000000..3c8c80ab --- /dev/null +++ b/test/latex/reference-type.commands.tex.exp @@ -0,0 +1,54 @@ +\providecommand\saildoclabelled[2]{\phantomsection\label{#1}#2} +\providecommand\saildocval[2]{#1 #2} +\providecommand\saildocfcl[2]{#1 #2} +\providecommand\saildoctype[2]{#1 #2} +\providecommand\saildocfn[2]{#1 #2} +\providecommand\saildocoverload[2]{#1 #2} + +\newcommand{\sailtypecapUpermsWidth}{\saildoclabelled{sailtypezcapzyupermszywidth}{\saildoctype{}{\lstinputlisting[language=sail]{out/typezcap_uperms_widthf6dfed0942499b0c2d58b90971faca40.tex}}}} + +\newcommand{\sailvalmain}{\saildoclabelled{sailzmain}{\saildocval{}{\lstinputlisting[language=sail]{out/valzmaine3ee21bf8f1dbb3fd716a5a1803d7e24.tex}}}} + +\newcommand{\sailfnmain}{\saildoclabelled{sailfnzmain}{\saildocfn{\begin{itemize} +\item Ref to \hyperref[sailzcapzyupermszywidth]{\lstinline{cap_uperms_width}} +\item Ref to \hyperref[sailzcapzyupermszywidth]{description} +\item Ref to \hyperref[sailztypez0capzyupermszywidth]{type description} +\item Ref to % FIXME: this should be using type\_description \hyperref[sailztypezycapzyupermszywidth]{type_description} +\item Ref to \sailreftype{cap\_uperms\_width}{uperms\_width} +\item Ref to \sailreftype{cap\_uperms\_width}{uperms\_width} +\end{itemize} +}{\lstinputlisting[language=sail]{out/fnzmaine3ee21bf8f1dbb3fd716a5a1803d7e24.tex}}}} + +\newcommand{\sailvalfunctionWithUnderscores}{\saildoclabelled{sailzfunctionzywithzyunderscores}{\saildocval{}{\lstinputlisting[language=sail]{out/valzfunction_with_underscores6e195bff96b3fe3d60b356f28519989f.tex}}}} + +\newcommand{\sailfnfunctionWithUnderscores}{\saildoclabelled{sailfnzfunctionzywithzyunderscores}{\saildocfn{\begin{itemize} +\item \hyperref[sailzfunction\_with\_underscores]{\lstinline{function\_with\_underscores}} +\item \hyperref[sailzfunctionzywithzyunderscores]{\lstinline{function_with_underscores}} +\item \hyperref[sailzNOTz0function\_with\_underscores]{function\_with\_underscores} +\item \hyperref[sailzNOTz0\lstinline{function_with_underscores}]{\lstinline{function_with_underscores}} +\item \hyperref[sailzfunction\_with\_underscores]{NOT function\_with\_underscores} +\item \hyperref[sailzfunctionzywithzyunderscores]{NOT \lstinline{function_with_underscores}} +\end{itemize} +}{\lstinputlisting[language=sail]{out/fnzfunction_with_underscores6e195bff96b3fe3d60b356f28519989f.tex}}}} + +\newcommand{\sailval}[1]{ + \ifstrequal{#1}{function\_with\_underscores}{\sailvalfunctionWithUnderscores}{}% + \ifstrequal{#1}{main}{\sailvalmain}{}} + +\newcommand{\sailrefval}[2]{ + \ifstrequal{#1}{function_with_underscores}{\hyperref[sailzfunctionzywithzyunderscores]{#2}}{}% + \ifstrequal{#1}{main}{\hyperref[sailzmain]{#2}}{}} + +\newcommand{\sailfn}[1]{ + \ifstrequal{#1}{function\_with\_underscores}{\sailfnfunctionWithUnderscores}{}% + \ifstrequal{#1}{main}{\sailfnmain}{}} + +\newcommand{\sailreffn}[2]{ + \ifstrequal{#1}{function_with_underscores}{\hyperref[sailfnzfunctionzywithzyunderscores]{#2}}{}% + \ifstrequal{#1}{main}{\hyperref[sailfnzmain]{#2}}{}} + +\newcommand{\sailtype}[1]{ + \ifstrequal{#1}{cap\_uperms\_width}{\sailtypecapUpermsWidth}{}} + +\newcommand{\sailreftype}[2]{ + \ifstrequal{#1}{cap_uperms_width}{\hyperref[sailtypezcapzyupermszywidth]{#2}}{}} diff --git a/test/latex/reference-type.sail b/test/latex/reference-type.sail new file mode 100644 index 00000000..d41ae10f --- /dev/null +++ b/test/latex/reference-type.sail @@ -0,0 +1,27 @@ +default Order dec + +$include <flow.sail> +$include <vector_dec.sail> + +type cap_uperms_width : Int = 4 +let cap_uperms_width = sizeof(cap_uperms_width) + +/*! + * - Ref to [cap_uperms_width] + * - Ref to [description][cap_uperms_width] + * - Ref to [type description][type cap_uperms_width] + * - Ref to % FIXME: this should be using type\_description [type_description][type_cap_uperms_width] + * - Ref to \sailreftype{cap_uperms_width}{uperms\_width} + * - Ref to \sailreftype{cap\_uperms\_width}{uperms\_width} + */ +function main() -> unit = return(()) + +/*! + * - [NAME] + * - [THIS] + * - [NAME][NOT NAME] + * - [THIS][NOT THIS] + * - [NOT NAME][NAME] + * - [NOT THIS][THIS] + */ +function function_with_underscores() -> unit = return(()) diff --git a/test/latex/run_tests.sh b/test/latex/run_tests.sh index 8c317b98..17edb567 100755 --- a/test/latex/run_tests.sh +++ b/test/latex/run_tests.sh @@ -48,7 +48,7 @@ for testfile in *.sail; do # Check that the generated latex builds: if command -v latexmk > /dev/null; then cp -f "$DIR/main.tex" "$temp_dir" - if latexmk -pdf -cd -interaction=batchmode "$temp_dir/main.tex" > /dev/null 2>&1; then + if latexmk -pdf -cd -file-line-error -interaction=batchmode "$temp_dir/main.tex" > /dev/null 2>&1; then green "Building LaTeX for $testfile" "ok" else tail -n 50 "$temp_dir/main.log" |
