This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Google Docs Conversion
Clay McLeod edited this page Jun 5, 2020
·
1 revision
First, install pandoc.
brew install pandocthen, you can use the following script.
#!/usr/bin/env bash
usage() {
>&2 echo "Usage: `basename $0` [docx-file] [guide-name] [output-dir]"
}
[[ "$#" -ne 3 ]] && usage && exit 1
DOCX_FILE=$1; shift;
GUIDE_NAME=$1; shift;
OUTPUT_DIR=$1; shift;
DIR="$CWD"
cd "$OUTPUT_DIR"
pandoc -s "$DOCX_FILE" \
-f docx-empty_paragraphs \
-t markdown_strict-smart+pipe_tables-all_symbols_escapable \
-o "$GUIDE_NAME.md" \
--extract-media . \
--atx-headers \
--toc \
--wrap=none \
--shift-heading-level-by 1 \
--tab-stop 2
cd "$DIR"If saved as convert-docx and with a document downloaded from Google Docs as SupplementaryTutorial.docx, here's an example of how to call it:
convert-docx SupplementaryTutorial.docx index guides/supplementary-tutorial