htdebeer / pandocomatic

Automate the use of pandoc

Home Page:https://heerdebeer.org/Software/markdown/pandocomatic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't get tidy to work as a postprocessor

ngirard opened this issue · comments

Following the relevant part of the documentation doesn't seem to work.

Here's the test script I wrote (I'm also about to attach it):

#!/bin/bash

mkdir test_postproc && cd test_postproc

cat > tidy.sh <<EOF
#!/bin/bash
tidy -quiet -indent -wrap 78 -utf8
EOF

chmod +x tidy.sh

cat > doc.md <<EOF
---
pandocomatic_:
    pandoc:
        to: html
        standalone: true
    postprocessors:
    - ./tidy.sh
title: Lorem ipsum
---
## Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, /consectetur adipiscing elit/. Cras a turpis semper, **porttitor enim malesuada**, accumsan libero. Nunc id nisl vitae dui iaculis porttitor. Phasellus in sollicitudin lorem. Vestibulum quis orci a mauris pharetra finibus. Nulla pulvinar dictum ex. Integer arcu arcu, pretium id aliquam in, venenatis eget arcu. Fusce non lobortis turpis. Ut sed est consectetur, accumsan erat id, lacinia lectus. Vivamus nulla dui, rutrum nec tellus non, ultrices imperdiet nisl. Cras id mattis sem. Etiam in tellus auctor, convallis justo et, iaculis nunc. Suspendisse ipsum nisi, sollicitudin a semper vel, aliquet quis est.
EOF

pandocomatic -i doc.md

Running the test produces an unindented html file.

Well GitHub won't let me upload a .sh file, but there you have it in anyway.

I can reproduce the issue. I will look into it, probably during the weekend.

Great, thanks !

I found the issue. For some issue I changed the way local assets were handled by removing the ./ from their path. Although that might work great for, say, CSS files, it had an averse effect on running local scripts as processors. I have fixed this issue in pandocomatic version 0.2.5.4. Please install that version and test your scenario again.

Do note that your example still does not work because the ./tidy.sh script return with exit code 1 because the HTML element does not have a lang attribute. You can solve this by doing one of two things:

  1. set the lang metadata property in your doc.md file:

    ---
    pandocomatic_:
        pandoc:
            to: html
            standalone: true
        postprocessors:
        - ./tidy.sh
    title: Lorem ipsum
    lang: en
    ---
    
    Your text ...
  2. change the ./tidy.sh script to capture the output and echo that, thereby ignoring the error status:

    #!/bin/bash
    output=`tidy -quiet -indent -wrap 78 -utf8`
    echo "$output"

Does this solve your issue?