MacOS – wrong in this command about grepping and pandocing

command linelatexmacosterminal

I am thinking this answer which returns a broken PDF document in OSX 10.10.3.

The file test_dummy.tex is here.

pandoc test_dummy.tex -f markdown -t html | grep -E '(^<|^$|^ *$)' \
| grep -v "^<p" | pandoc -f html -o tables.pdf

where pandoc 1.13.2.1 and grep grep (BSD grep) 2.5.1-FreeBSD.

1 Mistake in test_dummy.tex -file (different than you having real LaTeX)

I installed Pandoc by brew install pandoc.
Something is wrong in the very beginning command

pandoc test_dummy.tex -f markdown -t html

returns a blank line, likewise pandoc test_dummy.tex -f markdown.

[fixed by the answer]

2 Connecting the full command still challenge

The command (with cabal Pandoc)

pandoc test_dummy.tex -f markdown -t html | grep -E '(^<|^$|^ *$)' | grep -v "^<p" | pandoc -f html -o tables.pdf

returns

! Package inputenc Error: Unicode char \u8:≤ not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

                                                  
l.134 ≤

[fixed the addition of this answer solves this part]

How can I troubleshoot this chain of commands?

Best Answer

If you get a blank line from pandoc then something is quite amiss.

My guess is you've got several `pandoc or the tex file is encoded oddly or throwing some error that the version I downloaded from dropbox isn't the same as the one you are using.

$ pandoc test_dummy.tex -f markdown -t html | wc 
     311    1349   11676
$ pandoc test_dummy.tex -f markdown -t html | head

<p>everything - etiology, symptoms, diagnostic tests, grades of aortic valve stenosis</p>
<p>Aortic regurgitation. The murmur of aortic regurgitation occurs during diastole as the aortic valve fails to lose completely and blood regurgitates from the aorta back into the LV. Murmur - high-pitched decrescendo murmur heard best along left lower sternal border.</p>
<table>
<caption>Common causes of Aortic Stenosis Among Patients requiring Surgery. % http://emedicine.medscape.com/article/150638-overview#aw2aab6b2b4aa</caption>
<colgroup>
<col width="38%" />
<col width="38%" />
</colgroup>
<thead>
$ which pandoc
/usr/local/bin/pandoc
$ wc test_dummy.tex 
     210    1049    8801 test_dummy.tex

The troubleshooting would be to check the path to be sure you are using the tools you expect. Then break apart the chain of commands and inspect the beginnings of each output file using things like wc, head or more so you can make sure each link in the chain is working. The post you linked to is an exceptional answer by Kurt in that it explains exactly what the command line tools are doing with grep and why.