Skip to content

Instantly share code, notes, and snippets.

@zaiste
Created February 5, 2017 18:54
Show Gist options
  • Star 49 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save zaiste/77a946bbba73f5c4d33f3106a494e6cd to your computer and use it in GitHub Desktop.
Save zaiste/77a946bbba73f5c4d33f3106a494e6cd to your computer and use it in GitHub Desktop.
Convert RST to Markdown using Pandoc
FILES=*.rst
for f in $FILES
do
filename="${f%.*}"
echo "Converting $f to $filename.md"
`pandoc $f -f rst -t markdown -o $filename.md`
done
@mrmikee
Copy link

mrmikee commented Mar 20, 2017

Thanks, found this useful today.

@kennethreitz
Copy link

same

@spyoungtech
Copy link

👍

@MSeal
Copy link

MSeal commented Aug 1, 2018

Perfect

@swedishmike
Copy link

Great share - many thanks!

@aelmosalamy
Copy link

Thanks

@juddlyon
Copy link

juddlyon commented Aug 9, 2019

Thank you!

Here's what I ended up with in case it helps anybody.

# recursively find and convert RST to MD
find . -name '*.rst' -exec pandoc {} -f rst -t markdown -o {}.md \;
# rename .rst.md extensions to just .md
find . -name '*.rst.md' -exec rename "s/.rst.md/.md/" {} \;

@rachrobts
Copy link

When I run this I get "open binary file does not exist". help?

@Calinou
Copy link

Calinou commented Mar 14, 2020

@rachrobts Try this one-liner instead:

# Non-recursively
for rst in *.rst; do pandoc "$rst" -f rst -t markdown -o "${rst%.*}.md"; done

# Recursively (if your shell supports double-star globs)
for rst in **/*.rst; do pandoc "$rst" -f rst -t markdown -o "${rst%.*}.md"; done

@gbrlb
Copy link

gbrlb commented Oct 29, 2021

@rachrobts Try this one-liner instead:

# Non-recursively
for rst in *.rst; do pandoc "$rst" -f rst -t markdown -o "${rst%.*}.md"; done

# Recursively (if your shell supports double-star globs)
for rst in **/*.rst; do pandoc "$rst" -f rst -t markdown -o "${rst%.*}.md"; done

Great

@z-br
Copy link

z-br commented Nov 28, 2022

This doesn't seem to be working for me properly. I have this input:


.. literalinclude:: _output_sensor_flic.json
    :language: json
    :linenos:

And I get this output:

::: {.literalinclude language="json" linenos=""}
\_output_sensor_flic.json
:::

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment