Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to convert docx to markdown with Pandoc
:: pandoc-docx-md.bat
::
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Convert docx to markdown with Pandoc
:: Select file marker
:selectfile
:: Clear any preexisting filename variables
SET filename=
:: Ask which file we're converting.
SET /p filename=Which file? (Don't include the .docx file extension):
:: Feedback
ECHO Running pandoc...
:: Run pandoc
CALL pandoc -f docx -t markdown_mmd "%filename%".docx --output="%filename%".md --atx-headers --wrap=none --toc --extract-media=""
:: Feedback
ECHO Done. Ready for another file.
:: Let the user easily run that again
SET repeat=
SET /p repeat=Hit enter to convert another file, or any other key and enter to stop.
IF "%repeat%"=="" GOTO selectfile
:: Otherwise end
:end
#!/bin/bash
cd -- "$(dirname "$0")"
# That tells the system to use a Bourne shell interpreter,
# and then tells OSX to run this script from the current directory.
# Don't echo these commands:
set +v
repeat=
while [ "$repeat" = "" ]
do
# Clear any preexisting filename variables
filename=
# Ask which file we're converting.
echo "Which file? (Don't include the .docx file extension): "
read filename
# Feedback
echo "Running pandoc..."
# Run pandoc
pandoc -f docx -t markdown_mmd "$filename".docx --output="$filename".md --atx-headers --wrap=none --toc --extract-media=""
# Feedback
echo "Done. Ready for another file."
# Let the user easily run that again
repeat=
echo "Hit enter to convert another file, or any other key and enter to stop. "
read repeat
# Otherwise end
done
@yboujraf

This comment has been minimized.

Show comment
Hide comment
@yboujraf

yboujraf May 23, 2018

Dear

Thanks for the script to convert docx to markdown.

I am looking to generate the correct markdown for BITBUCKET.

I used the format "gfm". When I am readind with a standard markdown viewer, the pictures are correctly renderised.
But when I push to the Bitbucket

Now, when I am reading with a warkdown viewer, i can't see :

  • pictures
  • Table of content : is generated but not link
  • Table of Images : is generated but not link

Do you have any ideas ? or which format do I need to use to fix that ?

Best Regards,
Youssef

yboujraf commented May 23, 2018

Dear

Thanks for the script to convert docx to markdown.

I am looking to generate the correct markdown for BITBUCKET.

I used the format "gfm". When I am readind with a standard markdown viewer, the pictures are correctly renderised.
But when I push to the Bitbucket

Now, when I am reading with a warkdown viewer, i can't see :

  • pictures
  • Table of content : is generated but not link
  • Table of Images : is generated but not link

Do you have any ideas ? or which format do I need to use to fix that ?

Best Regards,
Youssef

@NicSil

This comment has been minimized.

Show comment
Hide comment
@NicSil

NicSil Aug 22, 2018

Merci +++. Works at firsdt launch.

NicSil commented Aug 22, 2018

Merci +++. Works at firsdt launch.

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