Easiest way to install latest Pandoc and LaTeX on Heroku - heroku

I want to build a Markdown to PDF converter running on Heroku using Pandoc and LaTeX that I can send markdown to and it will return a PDF. On my local machine this worked fine without any problem. I am using Pandoc 2.7.3 and pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019).
Now I wanted to host this on heroku, but I just get errors for missing files when I run the pandoc command because the versions are old or don't match.
What is the easiest way to get this to run?
Heroku obviously has some limitations on the slug size (500mb), so a full tex install is not possible. It would need to be a smaller subset.
There are Buildpacks for pandoc and TeX Live, but espacially the TeX Live buildpacks seem to be outdated and is not compatible with the pandoc one if you try to run the latest version. The Apt package seems also to maintain only an older version. Is a docker image maybe the answer? https://devcenter.heroku.com/articles/container-registry-and-runtime
I am not necessarily searching for installation instructions, but rather in which way you would handle that. I am a web developer, not a dev ops, so i am really lost in this LaTeX install mess.

Related

Alternative to wkhtmltopdf

I need to convert html text to pdf.
Most answers here recommend to use pdfkit and wkhtmltopdf (https://wkhtmltopdf.org/).
However, me company doesn't allow me to install wkhtmltopdf (it is also blocked by admin). There was an option to build from source but it seems like google blocks it due to security reason (https://github.com/wkhtmltopdf/wkhtmltopdf).
Is there an alternative or workaround?
I'm very new to python and don't have programming background, appreciate every detailed explanation.
Yes you can just download it and run it directly.
I used that for a shared host (WebFaction) where I have SSH but not root access nor installation option.
cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cd wkhtmltox/
./bin/wkhtmltopdf
You should be good.
Note that version 0.12.5 is out but has no linux-generic version. Therefore you may want to stick to 0.12.4 for now.
For Python, WeasyPrint would be the obvious replacement for wkhtmltopdf. Don't have a lot of experience, personally, however.
I recomend you to create a PDF on user browser with pdfmake.
Good luck!

How should I bundle pandoc with my OpenShift application?

I've been running jekyll on OpenShift using https://github.com/openshift-quickstart/jekyll-openshift. I want to be able to rebuild my web site automatically in order to future-date posts and not have to rebuild/reupload in order to publish them. This means that I have a cron job running on OpenShift that rebuilds my jekyll site, adapting the deploy bash script from the OpenShift cartridge I am using. So far, so good.
Now I want to use pandoc in place of kramdown. Now I have a problem. How do I install pandoc as part of my application's deployment to OpenShift?
I've searched the web for an hour or so. I'm getting conflicting reports. Use puppet. Build from source, which starts with "Install the Haskell platform". I don't mind the work, but I'd like some idea which path to go down before doing down them all and tearing my hair out.
So... which path would you choose and which articles can I read to guide me through learning what I need to learn in order to do this?
Thank you.
Pandoc is written in Haskell, so you'll have to build it using cabal or stack. However once built, you can move the binary to your server:
From Installing Pandoc:
It is possible to compile pandoc such that the data files pandoc uses are embedded in the binary. (The executables in the binary are built this way.) The resulting binary can be run from any directory and is completely self-contained.
cabal update
cabal install hsb2hs
cabal install --flags="embed_data_files" pandoc pandoc-citeproc

Pandoc: autogenerate and autoreload reveal.js slides on markdown modification

I am using pandoc to generate some slides for reveal.js. Now, when I edit the markdown file, I have to manually regenerate the HTML and then manually reload it in my browser to see the changes.
Is there a way to automate this task?
Update
I ended up creating a Python package for this: Markdownreveal.
You can install it with:
pip install markdownreveal
And start working with your presentations with:
markdownreveal my_presentation.md
You can customize the style, generate ZIPs or PDFs, upload to GitHub pages... For more information, have a look at the full project's documentation.
Old answer
Well, there is no way to configure pandoc to do that. But you can always create a script.
I made a script called pandoc-watch that watches the markdown file and, on modification (when you save your changes), it will automatically regenerate the HTML for reveal.js and it will be reloaded in your browser, using reveal.js's local server.
Note:
Made for GNU/Linux OSs.
Requires: bash, curl, npm, grunt, inotifywait.
Usage: pandoc-watch markdown_slides.md.
It is only meant for reveal.js output!
The first time is run it will download reveal.js and all the required node.js packages, so it may take some time. All the downloaded files are kept in ~/.pandoc-watch, in case you want to clean everything.

how to tell cpanm Image::Magick about header location?

On OS X cpanm Image::Magick fails with
Magick.xs:60:10: fatal error: 'magick/MagickCore.h' file not found
#include < magick/MagickCore.h>
The file is present though. (That space is from me to have it display here.)
How can I tell cpanm and/or Image::Magick where to find those headers?
(IM is installed from source.)
Workaround: download Module, edit Makefile.PL (add header dir to includes), make, make install as written on the imagemagick homepage.
While the question is rather old, I still ran into this issue recently.
I was able to resolve it with new ImageMagick installed via homebrew (brew install imagemagick which installed version 6.9.5-3), then firing up cpan and installing JCRISTY/PerlMagick-6.89-1.tar.gz package.
It fails in test section. Thus I analysed what tests fails and decided to cheat a bit (I don't need all ImageMagick functions). I manually edited tests files (use look Image::Magick to get into unarchived package) – for me, it was required to completely comment out test for input.miff (reference/filter/Segment.miff) in t/filter.t and tests for MPEG read in t/mpeg/read.t. Then cpan is able to process Image::Magick finally.
I ran my own tests upon set of GIF and PNG images and these are OK. Hope this helps someone.

How to create PDF documentation with Sphinx in Windows

I am using Sphinx to create documentation for my Python project in Windows. I need to generate PDF documentation. I found many explanation how to do this in Linux, but no good explanation how to do this in Windows. As far as i understand I need to create Latex format with Sphinx, and than use Texworks to convert Latex to PDF. Can someone provide step by step explanation how can I do this, assuming I created documentation in Latex format and installed Texworks?
Install MiKTeX (< 200mb)
wget -nv -N http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.4757.exe
7z.exe x -y miktex-portable-2.9.4757.exe -o"miktex"
Add the bin directory to your path
SET Path=%Path%;%CD%\miktex\miktex\bin
Run Sphinx's "make.bat" to generate the .tex file.
SET SPHINXOPTS=-W -E
make.bat latex
Invoke MiKTeX's pdflatex:
cd build/latex
pdflatex.exe YOUR_PROJECT_NAME.tex
The resultant PDF will be in your build/latex directory
Install the full tex live distribution, it will install latex, PDF backends and texworks. Yes it is much, yes, it will dl and install for a fat hour depending on your pipe. But it will be sub gig total, and harddisks are large nowadays.
From what I see, Texworks is just a simple LaTeX editor with some build functionality and latex syntax highlighting. It is not really needed for just compiling (you could use notepad)
Then it should be a matter of simply putting the tex live binary directory i the path and doing
pdflatex <yourlatexdocument.tex>
on the cmdline, at least that is what I do with the latex output of our own documentation generating tool
As you have figured out: use Sphinx to generate LaTeX source, and then run it through a LaTex compiler to produce your PDF.
Instead of troubling yourself with installing LaTeX (which can be daunting) and getting an editor set up, I suggest that you use one of the on-line LaTeX services. You then only have to create a project in ShareLaTeX or Overleaf, for example (which are in the process of merging), upload the contents of the Sphinx build\latex directory, compile on-line, and download the finished PDF.
This works reasonably well, but since the output targets are very different (HTML vs a formal document), you may have to fiddle with the reST to get things the way you like it.

Resources