Skip to content

Commit 842562f

Browse files
committed
filters: Fix examples tex
Modify the tex files/filters code so that the filters do indeed parse the given tex correctly.
1 parent 9057aa9 commit 842562f

File tree

14 files changed

+84
-195
lines changed

14 files changed

+84
-195
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
python-version: ${{ env.PYTHON_VERSION }}
2424
- uses: awalsh128/cache-apt-pkgs-action@v1.3.0
2525
with:
26-
packages: texlive-latex-base
26+
packages: texlive-latex-extra
2727
version: 1.0
2828
- name: Install Python Dependencies
2929
run: |

example.tex

Lines changed: 0 additions & 127 deletions
This file was deleted.

tex2lambda/filters/PartPartSolSol/example.tex

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
\documentclass{article}
22

3-
\begin{document}
3+
\usepackage{comment}
4+
5+
% This is a common method for including/excluding solutions from the PDF.
6+
\includecomment{solution}
7+
%\excludecomment{solution}
48

5-
\newenvironment{SomeSolutionDividerName}{}{}
9+
\begin{document}
610

711
\section*{Minimal Example}
812

@@ -12,25 +16,25 @@ \section*{Minimal Example}
1216

1317
\begin{enumerate}
1418

15-
\item Here is some interesting information. Calculate the following:
19+
\item Here is some interesting information. Calculate the following:
1620

17-
\begin{enumerate}
18-
\item $1+1$
19-
\item $2+2$
20-
\end{enumerate}
21+
\begin{enumerate}
22+
\item $1+1$
23+
\item $2+2$
24+
\end{enumerate}
2125

22-
\begin{SomeSolutionDividerName}
23-
\begin{enumerate}
24-
\item $1+1=2$
25-
\item $2+2=4$
26-
\end{enumerate}
27-
\end{SomeSolutionDividerName}
26+
\begin{solution}
27+
\begin{enumerate}
28+
\item $1+1=2$
29+
\item $2+2=4$
30+
\end{enumerate}
31+
\end{solution}
2832

29-
\item This questions has no parts. What is the solution?
33+
\item This questions has no parts. What is the solution?
3034

31-
\begin{SomeSolutionDividerName}
32-
This is the solution.
33-
\end{SomeSolutionDividerName}
35+
\begin{solution}
36+
This is the solution.
37+
\end{solution}
3438

3539
\end{enumerate}
3640

tex2lambda/filters/PartPartSolSol/filter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python3
22

3-
"""A filter that parses files where solutions come after the whole questions and are broken down by part."""
3+
"""A filter that parses files where solutions come after the whole question and are broken down by part.
4+
5+
i.e. Parts follow each other, and solutions for those parts follow next.
6+
"""
47

58
from typing import Optional
69

tex2lambda/filters/PartSolPart/example.tex

Lines changed: 0 additions & 39 deletions
This file was deleted.
File renamed without changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
\documentclass[12pt]{article}
2+
3+
\usepackage{comment}
4+
5+
% This is a common method for including/excluding solutions from the PDF.
6+
\includecomment{solution}
7+
%\excludecomment{solution}
8+
9+
\begin{document}
10+
11+
\section*{Minimal Example}
12+
13+
\begin{enumerate}
14+
15+
\item Here is some interesting information. Calculate the following:
16+
17+
\begin{enumerate}
18+
\item $1+1$
19+
20+
\begin{solution}
21+
$1+1 = 2$
22+
\end{solution}
23+
24+
25+
\item $2+2$
26+
27+
\begin{solution}
28+
$2+2=4$
29+
\end{solution}
30+
31+
\end{enumerate}
32+
33+
\item This questions has no parts. What is the solution?
34+
35+
\begin{solution}
36+
This is the solution.
37+
\end{solution}
38+
39+
\end{enumerate}
40+
41+
\end{document}

tex2lambda/filters/PartSolPart/filter.py renamed to tex2lambda/filters/PartSolPartSol/filter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ def pandoc_filter(
5959
if pandoc_filter.question:
6060
module.add_question(main_text="\n".join(pandoc_filter.question))
6161
module.current_question.add_solution(pf.stringify(elem))
62+
module.current_question._last_part["solution"] -= 1
6263
pandoc_filter.question = []
6364
return None
File renamed without changes.

tex2lambda/filters/PartsOneSol/example.tex renamed to tex2lambda/filters/PartsWithOneSol/example.tex

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
\documentclass[12pt]{article}
22

3-
\newenvironment{AnyName}{}{}
3+
\usepackage{comment}
4+
5+
% This is a common method for including/excluding solutions from the PDF.
6+
\includecomment{solution}
7+
%\excludecomment{solution}
48

59
\begin{document}
610

@@ -15,8 +19,7 @@ \subsection{}
1519
\item The filter still works even if there aren't any parts
1620
\end{enumerate}
1721

18-
\begin{AnyName}
19-
\paragraph{Solution}
22+
\begin{solution}
2023

2124
This is the final answer. It contains the solutions for all parts without breaking them up.
2225

@@ -26,14 +29,14 @@ \subsection{}
2629

2730
The solution is copied across all parts.
2831

29-
\end{AnyName}
32+
\end{solution}
3033

3134
\subsection{}
3235

3336
This is question 2.
3437

35-
\begin{AnyName}
36-
\paragraph{Solution} And here's the solution
37-
\end{AnyName}
38+
\begin{solution}
39+
And here's the solution
40+
\end{solution}
3841

3942
\end{document}

0 commit comments

Comments
 (0)