1

I would like to use a regular expression to modify a file and then feed it to pandoc in the cli.

Something like this:

perl -pe 's/_(.*)_/\\underline{$1}/g' source.md > pandoc -o source.pdf

So, I'm taking anything surrounded by _ and replacing it with the Latex command \underline{found text} and then feed the result into the pandoc command.

I thought I saw someone else do something like that but haven't been able to find it.

Update:

OS: Lubuntu 13.04

2
  • Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version? – terdon Jan 21 '14 at 15:44
  • @terdon, You are right, I should have. It is now included. – Jon49 Jan 21 '14 at 19:34
2

Don't know what pandoc is, but if it can read from STDIN (standard input) than you should be using pipe | and not > which outputs the result of perl command to pandoc file:

perl -pe 's/_(.*)_/\\underline{$1}/g' source.md | pandoc -o source.pdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.