-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
A lua filter enabling multiple columns in Latex, PDF, and HTML documents #191
base: master
Are you sure you want to change the base?
Conversation
based on Pandoc fenced divs
this filter targets document body only and pandoc does many things I don't control in the preamble.
as suggested by Benct Philip Jonsson Plus other minor refactoring and some details in README.md Some enhencements in the sample file.
NB, there's already a filter for that: https://github.com/jdutant/columns . The syntax is the same, and it provides the header-includes if needed. It handles column spacing, rules etc. as well. I didn't submit it here because @tarleb wants to keep this repo for smaller, easily maintainable filters, but I included it in the filters wiki. The main thing I'd like to add to my BTW few people seem to find the filters mentioned in the Pandoc filters wiki. This repo is good because we know we can trust the filters on it; but on the other hand, it can't accept largish filters. I hope at some point we get something more like CTAN... |
@jdutant Thanks for the clarification. |
@chrisaga ah, good point! Indeed |
@jdutant I don't know. It's up to you. :::::::: {.columns }
:::: {.column width="20%"}
content ...
::::
:::: {.column width="80%"}
content ...
::::
:::::::: Which is what you find on the net when you google something like "pandoc markdown columns". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, dropping the requirement on specific class order, and especially for adding tests!
.display.math{display: block; text-align: center; margin: 0.5rem auto;} | ||
</style> | ||
<!--[if lt IE 9]> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am uncomfortable with this. Do we have other instances in Pandoc templates where the default output includes loading 3rd party external resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well … I didn't do this. pandoc --standalone
did. I can remove the --standalone
option on the html test file.
I already did for the latex test file.
Would it be better like this ?
column-div/column-div.lua
Outdated
if style then | ||
div.attributes.style = style .. (div.attributes.style or '') | ||
returned_list = List:new{pandoc.Div(div.content, div.attr)} | ||
--returned_list = List:new{pandoc.Div(div.content)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize I'm reviewing this still in Draft mode so it might be too early, but just as a note for when this is ready for review lets cleanup the code so there are not instances of commented out bits without explanation for why the logic is not transparent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course !
column-div/column-div.lua
Outdated
-- process supported options | ||
opt = div.attributes['column-count'] | ||
if opt then options = '{' .. opt .. '}' end | ||
--[[ This functionality will be moved in another filter since it can't be consistent with the positionless classname requirement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.f. Comment on L151.
It's based on the use of simple Pandoc fenced divs, their class names and some arguments. This filter extends what is already available for HTML output, gives the same features to Latex (and PDF via Latex) documents.
Multiple columns are very useful to format fancy documents with text, pictograms etc. I have been missing this feature for a long time. I finally made my first Pandoc lua filter and share it hoping it will be useful to others.