Try โ€‚โ€‰HackMD

Rendering markdown as pdf

Among other places, I found this path here, and ended up finding the way below to be the easiest.

Install needed program in conda environment

conda create -y -n grip python=3
conda activate grip
pip install grip

Now we need the markdown file we want to turn into a pdf, but we don't want to get the page that looks like this (if doing this to a page from github):

We want to click the "Raw" button to get to the plain text version, which will look something like this:

Then we want to get that file on our computer, so we can copy the link at the top of our browser and download it with curl like this example (if this particular example file still exists โ€“ if it doesn't because this is the future times, you will get a 404 error at the next step, but the process will work the same with your own):

curl -LO https://raw.githubusercontent.com/asaravia-butler/GeneLab_Data_Processing/master/Metagenomics/Illumina/GL-DPPD-7107.md

Render local html

grip GL-DPPD-7107.md

Go to the link it prints out that it is serving it on, e.g. something like localhost:6419/. (I was working in a chrome browswer, so the images below match that)

NOTE
The example file used previously is gone, and was updated. So the pics below don't match the new example file above. But the concepts are the same.

Remove anything we don't want, like the top part here

Right-click and select "Inspect":

In the top-right box, select the elements we want to remove, hovering over them highlights them in the rendered html page, e.g.:

And hitting the delete key on our keyboard when that object is selected deletes it from this local rendering:

Get rid of everything wanted, here I did up to the Table of Contents, so this will start as page 2 and we'll add the cover page:

Saving as PDF

Then right-click and select "Printโ€ฆ" (I have no idea why this is the standard way to save as a PDF):

Click on the "More settings" drop-down menu and make sure "Headers and footers" box is not checked, and that the "Background graphics" is checked:

I also found a "scale" setting that sometimes helps to get more text on the page width-wise, so mess with that if things are getting cut off more than we can trim down.

Click save. The browser can now be closed and ctrl+c can be run on the command line to cancel the grip program.

Adding front page (for GL-DPPDs)

I saved Amanda's front page word doc as a template so we can easily modify it. Can be downloaded with this line:

curl -L -o GL-protocol-pg-1-template.docx https://ndownloader.figshare.com/files/26031350

I modified that in word and saved it as a PDF. Then I combined them into one PDF. I use Mac's Preview app to do this, by dragging the cover page thumbnail over to the full PDF doc: