Skip to content

Instantly share code, notes, and snippets.

@romac
Created May 4, 2011 14:01
Show Gist options
  • Save romac/955267 to your computer and use it in GitHub Desktop.
Save romac/955267 to your computer and use it in GitHub Desktop.
Convert Markdown files to a single Word document.
MARKDOWN=Scripts/Markdown.pl
DOC_FORMAT=doc
MD_OUTPUT=All.md
HTML_OUTPUT=Documentation.html
DOC_OUTPUT=Documentation.$(DOC_FORMAT)
.PHONY : all clean convert concat md2html html2doc
all: concat convert
@rm -f $(MD_OUTPUT) $(HTML_OUTPUT)
@echo
@echo The documentation has been successfully generated and can be found in $(DOC_OUTPUT)
convert: md2html html2doc
concat:
@echo -n Concatenating the Markdown files...
@cat *.md > $(MD_OUTPUT)
@echo ' Done.'
md2html:
@echo -n Converting the document to HTML...
@echo '<html><head><meta charset="utf-8"/></head><body>' > $(HTML_OUTPUT)
@perl $(MARKDOWN) $(MD_OUTPUT) >> $(HTML_OUTPUT)
@echo '</body></html>' >> $(HTML_OUTPUT)
@echo ' Done.'
html2doc:
@echo -n Converting the HTML document to Word...
@textutil -format html -convert $(DOC_FORMAT) -output $(DOC_OUTPUT) $(HTML_OUTPUT)
@echo ' Done.'
clean:
@echo -n Removing the previously generated files...
@rm -f $(MD_OUTPUT) $(HTML_OUTPUT) $(DOC_OUTPUT)
@echo ' Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment