forked from rust-lang/book
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
121ad3d
commit b53d923
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
# Get all the docx files in the tmp dir. | ||
ls tmp/*.docx | \ | ||
# Extract just the filename so we can reuse it easily. | ||
xargs -n 1 basename -s .docx | \ | ||
while IFS= read -r filename; do | ||
# Make a directory to put the XML in. | ||
mkdir -p "tmp/$filename" | ||
# Unzip the docx to get at the XML. | ||
unzip -o "tmp/$filename.docx" -d "tmp/$filename" | ||
# Convert to markdown with XSL. | ||
xsltproc tools/docx-to-md.xsl "tmp/$filename/word/document.xml" | \ | ||
# Hard wrap at 80 chars at word bourdaries. | ||
fold -w 80 -s | \ | ||
# Remove trailing whitespace and save in the `nostarch` dir for comparison. | ||
sed -e "s/ *$//" > "nostarch/$filename.md" | ||
done |