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

Allow options for LaTeX minted blocks #313

Merged
merged 1 commit into from Jan 27, 2024

Conversation

peterjc
Copy link
Contributor

@peterjc peterjc commented Dec 22, 2023

I've not used them much, but LaTeX minted blocks can have optional arguments. My original regex did not consider this. Test and proposed fix attached.

@adamchainz adamchainz changed the title LaTeX minted blocks can have options Allow options for LaTeX minted blocks Jan 26, 2024
Comment on lines 69 to 75
r"(?P<before>^(?P<indent> *)\\begin{minted}(\[.*\])?{python}\n)"
r"(?P<code>.*?)"
r"(?P<after>^(?P=indent)\\end{minted}\s*$)",
re.DOTALL | re.MULTILINE,
)
LATEX_PYCON_RE = re.compile(
r"(?P<before>^(?P<indent> *)\\begin{minted}{pycon}\n)"
r"(?P<before>^(?P<indent> *)\\begin{minted}(\[.*\])?{pycon}\n)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switching to a non-greedy matches (.*?) for caution’s sake

@adamchainz adamchainz enabled auto-merge (squash) January 27, 2024 10:05
@adamchainz adamchainz merged commit 7c8d70f into adamchainz:main Jan 27, 2024
7 checks passed
@peterjc peterjc deleted the minted_opts branch January 27, 2024 20:40
@peterjc
Copy link
Contributor Author

peterjc commented Jan 27, 2024

Thanks for reviewing and merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants