Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

itemize, enumerate: handle optional argument #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,36 @@ def test_4():
plain, pos = utils.get_txt_pos(toks)
assert plain_4 == plain

latex_5 = r"""
\begin{itemize}[topsep=1pt]
\item B
\end{itemize}
"""
plain_5 = r"""
* B
"""
def test_itemize_optional_arg():
parms = parameters.Parameters()
parms.item_default_label = ['*', '-']
p = parser.Parser(parms)
toks = p.parse(latex_5)
plain, pos = utils.get_txt_pos(toks)
assert plain_5 == plain

latex_6 = r"""
\begin{enumerate}[topsep=1pt]
\item B
\end{enumerate}
"""
plain_6 = r"""
1. B
"""
def test_itemize_optional_arg():
parms = parameters.Parameters()
parms.item_default_label = ['*']
parms.item_punctuation = []
p = parser.Parser(parms)
toks = p.parse(latex_6)
plain, pos = utils.get_txt_pos(toks)
assert plain_6 == plain

4 changes: 2 additions & 2 deletions yalafi/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def labs_itemize(level):

self.environment_defs += [

Environ(self, 'enumerate', add_pars=False, items=labs_enumerate),
Environ(self, 'itemize', add_pars=False, items=labs_itemize),
Environ(self, 'enumerate', args='O', add_pars=False, items=labs_enumerate),
Environ(self, 'itemize', args='O', add_pars=False, items=labs_itemize),

]

Expand Down