I made a simple shell script and a similar system service via automator to turn .txt files into .pdf via xelatex. They work well but require a couple steps outside TextMate. It would be a great convenience to have a command in the markdown bundle that would add this capacity. I tried it but failed even when giving full path to pandoc and pandoc-citeproc which are in /usr/local/bin, or to xelatex. I have little knowledge in these matters and would appreciate any help.
Here is my little shell script:
#!/bin/sh pandoc -S --filter pandoc-citeproc --latex-engine=xelatex "${1}" -o "${1}".pdf
My similar automator service:
PATH=$HOME/.cabal/bin:/usr/local/bin:/usr/texbin:$PATH for file in "$@" do output=${file%%.*}.pdf pandoc -S --filter pandoc-citeproc --latex-engine=xelatex "$file" -o "$output" done
The metadata at the head of my .md or .txt files give extra info, such as title, font, bibliography, as in:
--- title: My title author: My Name date: \today mainfont: Hoefler Text bibliography: /Users/me/Library/texmf/bibtex/bib/data.bib ---
Any pointers towards making a markdown bundle command that accomplishes what the scripts above do would be great. --Gildas
Hi Gildas,
On 24 Dec 2014, at 8:54 , Gildas Hamel gweltaz@ucsc.edu wrote:
I made a simple shell script and a similar system service via automator to turn .txt files into .pdf via xelatex. They work well but require a couple steps outside TextMate. It would be a great convenience to have a command in the markdown bundle that would add this capacity. I tried it but failed even when giving full path to pandoc and pandoc-citeproc which are in /usr/local/bin, or to xelatex. I have little knowledge in these matters and would appreciate any help.
Here is my little shell script:
#!/bin/sh pandoc -S --filter pandoc-citeproc --latex-engine=xelatex "${1}" -o "${1}".pdf
My similar automator service:
PATH=$HOME/.cabal/bin:/usr/local/bin:/usr/texbin:$PATH for file in "$@" do output=${file%%.*}.pdf pandoc -S --filter pandoc-citeproc --latex-engine=xelatex "$file" -o "$output" done
The metadata at the head of my .md or .txt files give extra info, such as title, font, bibliography, as in:
title: My title author: My Name date: \today mainfont: Hoefler Text bibliography: /Users/me/Library/texmf/bibtex/bib/data.bib
Any pointers towards making a markdown bundle command that accomplishes what the scripts above do would be great. —Gildas
Hi Gildas,
you could for example create a command containing the following code:
—
#!/bin/bash
PDF_PATH=`echo "${TM_FILEPATH}" | sed -E 's/.[^/]+$/.pdf/'` PDF_NAME=`basename "${PDF_PATH}"` pandoc -S --latex-engine=xelatex "${TM_FILEPATH}" -o "${PDF_PATH}" echo "PDF saved to ${PDF_NAME}"
—
using the options:
Name: Generate PDF Scope Selector: text.html.markdown Key Equivalent: ⌥⌘ Save: Current Document Input: Nothing Output: Show in Tool Tip Format: Text Caret Placement: After Output
I attached a bundle that should contain the command described above. Just double click it to install the bundle. If you have any questions, please feel free to ask.
Kind regards, René
* Skriv a reas René Schwaiger (sanssecours@f-m.fm):
|> #!/bin/bash |> |> PDF_PATH=`echo "${TM_FILEPATH}" | sed -E 's/.[^/]+$/.pdf/'` |> PDF_NAME=`basename "${PDF_PATH}"` |> pandoc -S --latex-engine=xelatex "${TM_FILEPATH}" -o "${PDF_PATH}" |> echo "PDF saved to ${PDF_NAME}" |> Thank you René for the command. When I try it on my .txt files, however, a tool tip comes up with "Generate PDF: line 5: pandoc: command not found." I wonder whether my path is set up correctly and how I should check it. --Gildas
Joyeux Noël!
* Skriv a reas René Schwaiger (sanssecours@f-m.fm): |> |> I attached a bundle that should contain the command described above. Just double click it to install the bundle. If you have any questions, please feel free to ask. |> |> Kind regards, |> René
Hi René, after I sent the previous message about my path difficulties with pandoc, I realized I had to set PATH as recommended in http://blog.macromates.com/2014/defining-a-path/ for pandoc and xelatex, and it works perfectly. Your bundle is a wonderful Christmas present, thank you. --Gildas