Skip to content

Commit 7e752fd

Browse files
committed
filters: Move to generic naming
1 parent 13c0e9a commit 7e752fd

14 files changed

Lines changed: 161 additions & 26 deletions

File tree

tex2lambda/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Python library and CLT for converting LaTeX documents into Lambda Feedback compatible JSON/ZIP files."""
22

3+
import beartype
34
import click
45
import panflute
56
import rich_click
6-
import beartype
77
from beartype.claw import beartype_this_package
88
from rich.traceback import install
99

tex2lambda/filters/PartPartSolSol/__init__.py

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
\documentclass{article}
2+
3+
\begin{document}
4+
5+
\newenvironment{SomeSolutionDividerName}{}{}
6+
7+
\section*{Minimal Example}
8+
9+
\hrulefill
10+
11+
\medskip
12+
13+
\begin{enumerate}
14+
15+
\item Here is some interesting information. Calculate the following:
16+
17+
\begin{enumerate}
18+
\item $1+1$
19+
\item $2+2$
20+
\end{enumerate}
21+
22+
\begin{SomeSolutionDividerName}
23+
\begin{enumerate}
24+
\item $1+1=2$
25+
\item $2+2=4$
26+
\end{enumerate}
27+
\end{SomeSolutionDividerName}
28+
29+
\item This questions has no parts. What is the solution?
30+
31+
\begin{SomeSolutionDividerName}
32+
This is the solution.
33+
\end{SomeSolutionDividerName}
34+
35+
\end{enumerate}
36+
37+
\end{document}

tex2lambda/filters/linear.py renamed to tex2lambda/filters/PartPartSolSol/filter.py

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

3-
"""Pandoc filter for Physics Linear Algebra.
4-
5-
See https://pandoc.org/filters.html for more information.
6-
"""
3+
"""A filter that parses files where solutions come after the whole questions and are broken down by part."""
74

85
from typing import Optional
96

tex2lambda/filters/PartSolPart/__init__.py

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
\documentclass{article}
2+
3+
\begin{document}
4+
5+
\newenvironment{SomeSolutionDividerName}{}{}
6+
7+
\section*{Minimal Example}
8+
9+
\hrulefill
10+
11+
\medskip
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{SomeSolutionDividerName}
21+
$1+1=2$
22+
\end{SomeSolutionDividerName}
23+
24+
\item $2+2$
25+
26+
\begin{SomeSolutionDividerName}
27+
$2+2=4$
28+
\end{SomeSolutionDividerName}
29+
\end{enumerate}
30+
31+
\item This questions has no parts. What is the solution?
32+
33+
\begin{SomeSolutionDividerName}
34+
This is the solution.
35+
\end{SomeSolutionDividerName}
36+
37+
\end{enumerate}
38+
39+
\end{document}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env python3
22

3-
"""Pandoc filter for Physics Linear Algebra.
4-
5-
See https://pandoc.org/filters.html for more information.
6-
"""
3+
"""A filter that parses files where a soltution follows each individual part."""
74

85
from collections import deque
96
from typing import Optional

tex2lambda/filters/PartsOneSol/__init__.py

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
\documentclass[12pt]{article}
2+
3+
\newenvironment{AnyName}{}{}
4+
5+
\begin{document}
6+
7+
\section{Minimal Example}
8+
9+
\subsection{}
10+
11+
Here is some preliminary question information that might be useful.
12+
13+
\begin{enumerate}
14+
\item This is part (a)
15+
\item The filter still works even if there aren't any parts
16+
\end{enumerate}
17+
18+
\begin{AnyName}
19+
\paragraph{Solution}
20+
21+
This is the final answer. It contains the solutions for all parts without breaking them up.
22+
23+
$$
24+
1+1 = 2
25+
$$
26+
27+
The solution is copied across all parts.
28+
29+
\end{AnyName}
30+
31+
\subsection{}
32+
33+
This is question 2.
34+
35+
\begin{AnyName}
36+
\paragraph{Solution} And here's the solution
37+
\end{AnyName}
38+
39+
\end{document}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env python3
22

3-
"""Pandoc filter for Materials files (specifically by Jonathan Rackham).
4-
5-
See https://pandoc.org/filters.html for more information.
6-
"""
3+
"""A filter that parses files where solutions are denoted by beginning with the paragraph text 'Solution'. The solutions don't break down by part."""
74

85
from typing import Optional
96

@@ -36,6 +33,7 @@ def pandoc_filter(
3633
"""
3734
match type(elem):
3835
# Question text is stored in paragraph blocks where the preceding block is a section header.
36+
# TODO: This doesn't work if the question has more than one paragraph
3937
case pf.Para:
4038
if (
4139
isinstance(elem.prev, pf.Header)

0 commit comments

Comments
 (0)