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

Fix non-paragraph elements in divs #11

Closed
wants to merge 2 commits into from

Conversation

jefelino
Copy link

This addresses issue #9.

This patch changes the behavior of the script in all cases. The previous behavior was to add a RawInline element to the beginning of the first child of a Div, and another RawInline element to the end of the last child. This behavior made sense if the first and last children were Plain or Para, but in general could break, leading to a crash.

The new behavior is to add a RawBlock child as the first child of the Div, and another RawBlock as the last child. The existing child nodes are unmodified. (This approach also simplifies the code.)

It looks like in latex output this has the effect of including some extra newlines surrounding the raw latex code. In latex output this may result in some extra whitespace, depending on the environment. Since the pandoc latex writer seems to add newlines to pretty much any top-level element (RawBlock, Plain) this seems hard to avoid. But I may be missing something.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 94.595% when pulling 5cdb188 on jefelino:fix-lists-in-divs into 002d57c on chdemko:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 94.595% when pulling 5cdb188 on jefelino:fix-lists-in-divs into 002d57c on chdemko:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 94.595% when pulling 5cdb188 on jefelino:fix-lists-in-divs into 002d57c on chdemko:master.

@jefelino
Copy link
Author

I see that pull request #10 addresses the same issue. My patch is basically the same as that one. The main difference is that I use RawBlock instead of a Para containing a RawInline. That doesn't seem to make any difference to current latex output, but strikes me as more correct in principle. That version (the "streamlined" one) also modifies the list of children in-place, which might be more efficient. I also updated the tests. Otherwise I think they're identical.

@rokk4
Copy link

rokk4 commented Jan 20, 2021

Please merge this.
I really need this 💯

@rokk4
Copy link

rokk4 commented Jan 21, 2021

For search engine visitors, use:
pip3 install https://github.com/jefelino/pandoc-latex-environment/archive/fix-lists-in-divs.zip
To get it working.

@chdemko
Copy link
Owner

chdemko commented Feb 24, 2021

Fix in code

@chdemko chdemko closed this Feb 24, 2021
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

4 participants