-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from matze-dd/Circuitikz
New package circuitikz; addresses #158
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
import pytest | ||
from yalafi import parameters, parser, utils | ||
|
||
preamble = '\\usepackage{circuitikz}\n' | ||
|
||
def get_plain(latex): | ||
parms = parameters.Parameters() | ||
p = parser.Parser(parms) | ||
plain, nums = utils.get_txt_pos(p.parse(preamble + latex)) | ||
assert len(plain) == len(nums) | ||
return plain | ||
|
||
|
||
data_test_macros_latex = [ | ||
|
||
(r'A\ctikzset{X}B', 'AB'), | ||
(r'A\usetikzlibrary XB', 'AB'), | ||
( | ||
r""" | ||
A | ||
\begin{circuitikz} | ||
\ctikzset{voltage/bump b/.initial=0} % defines arrow's curvature | ||
\draw (0,3) to[short,o-*] (1,3) -- (1,3.5) to[R,l=$R$] (4,3.5) to[L=$L$] (7,3.5) -- (7,3) to[short,i=$I_{Last}$,*-] (9,3) | ||
to[R,l=$R_{Last}$] (9,0) to[short,-o] (0,0); | ||
\draw (1,3) -- (1,2.5) to[C,l_=$C$] (7,2.5) -- (7,3); | ||
\draw (0,3) to[open,v=$U_e$] (0,0); | ||
\end{circuitikz} | ||
B | ||
""", | ||
r""" | ||
A | ||
B | ||
""" | ||
), | ||
|
||
] | ||
|
||
@pytest.mark.parametrize('latex,plain_expected', data_test_macros_latex) | ||
def test_macros_latex(latex, plain_expected): | ||
plain = get_plain(latex) | ||
assert plain == plain_expected | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
# | ||
# YaLafi module for LaTeX package circuitikz | ||
# | ||
|
||
from yalafi.defs import Environ, InitModule | ||
|
||
require_packages = ['tikz'] | ||
|
||
def init_module(parser, options): | ||
parms = parser.parms | ||
|
||
macros_latex = r""" | ||
\newcommand{\ctikzset}[1]{} | ||
""" | ||
|
||
macros_python = [] | ||
|
||
environments = [ | ||
|
||
Environ(parms, 'circuitikz', remove=True, add_pars=False), | ||
|
||
] | ||
|
||
return InitModule(macros_latex=macros_latex, macros_python=macros_python, | ||
environments=environments) | ||
|