dialoa / columns Goto Github PK
View Code? Open in Web Editor NEWMulticolumn support for pandoc's markdown
License: MIT License
Multicolumn support for pandoc's markdown
License: MIT License
Hello,
Thanks for this filter which seems complete.
While testing with the README.md and running the command make
, pandoc throws this error :
$ make
pandoc --lua-filter columns.lua --standalone --output expected.html README.md
Error running filter columns.lua:
attempt to index a nil value
stack traceback:
[C]: in metamethod '__index'
columns.lua:393: in upvalue 'convert_explicit_columbreaks'
columns.lua:583: in function <columns.lua:578>
(...tail calls...)
make: *** [expected.html] Error 83
I think there is a missing condition at the lines https://github.com/jdutant/columns/blob/master/columns.lua#L393-L394
Here is my proposal:
# https://github.com/jdutant/columns/blob/master/columns.lua#L393-L394
- if elem.content[#elem.content] and elem.content[#elem.content].classes
- and elem.content[#elem.content].classes:includes('column') then
+ if elem.content[#elem.content]
+ and elem.content[#elem.content].t == 'Div'
+ and elem.content[#elem.content].classes
+ and elem.content[#elem.content].classes:includes('column') then
The main addition here is that we now check if the element is a Div
. After adding that, everything works fine
Can I submit a pull request with that change?
Thanks
I'm using your script to generate a PDF of a recipe collection in markdown. Ingredients are in two columns and the cooking instructions follows in one column layout.
Sometimes the list of ingredients does not fit evenly in two columns and LaTeX fills up with vertical space (too much white space in right column):
By inserting
\vspace*{\fill}
before \end{multicols}
I can get my desired result (see this SO thread):
It would be nice to have an option to not layout column text in the entire column height. This would insert \vspace*{\vfill}
before \columnbreak
(for left column) and \end{multicols}
(for right column).
See this discussion for the suggested LaTeX fix.
Possibly a job for a separate filter. From Bastien Dumont (https://groups.google.com/g/pandoc-discuss/c/JxV3nF_igdw):
I noticed one problem though: LaTeX always places on top of the page full-width figures in a multicolumn environment. It means that the stream will be broken after the figure, as this document will show:
\documentclass{article}
\usepackage{multicol}
\usepackage{lipsum}
\begin{document}
\begin{multicols}{2}
\lipsum[1-7]
\end{multicols}
\begin{figure}
\begin{quote}
\lipsum[8]
\end{quote}
\end{figure}
\begin{multicols}{2}
\lipsum[1-7]
\end{multicols}
\end{document}
If you only want to make all figures span the entire width in a two-column layout, you can simply add this in the metadata block of your document (without changing anything in the command-line):
header-includes: |
\renewenvironment{figure}{\begin{figure*}}{\end{figure*}}
However, the limitation regarding the figures' placement will still apply.
Add support for the CSS column-fill options and multicol* environment
Supporting individual column widths (similar to the beamer case) would be useful in some situations.
While testing with README.md and make, pandoc throws some errors like :
Error running filter columns.lua:
columns.lua:71: attempt to call a nil value (method 'insert')
stack traceback:
columns.lua:71: in function <columns.lua:53>
(...tail calls...)
It seems to be due to an import error with pandoc.List
[removed]
Check whether the class option "twocolumn" is set. If so, handle column breaks and column spans in the document and (optionally) generate HTML output with two columns. Provide a global two-columns option that sets the class option twocolumn.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.