Created
July 15, 2011 13:36
-
-
Save romac/1084698 to your computer and use it in GitHub Desktop.
Markdown to PDF
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
TEMP_DIR:=$(shell mktemp -d -t /tmp) | |
MARKDOWN=perl Resources/Markdown.pl | |
WKHTMLTOPDF=/usr/local/bin/wkhtmltopdf | |
BUILD_DIR=Build | |
MD_OUTPUT=Documentation.md | |
HTML_OUTPUT=Documentation.html | |
PDF_OUTPUT=Documentation.pdf | |
COVER=__Couverture | |
all: convert clean | |
@echo -- The documentation has been successfully generated and can be found in $(BUILD_DIR)/$(PDF_OUTPUT) | |
cprsrc: | |
@echo -n -- Copying documents and resources... | |
@ditto *.md $(TEMP_DIR)/ | |
@ditto Assets $(TEMP_DIR)/Assets | |
@echo ' Done.' | |
convert: html2pdf | |
concat: cprsrc | |
@echo -n -- Concatenating the Markdown files... | |
@cat $(TEMP_DIR)/0*.md > $(TEMP_DIR)/$(MD_OUTPUT) | |
@echo ' Done.' | |
md2html: concat | |
@echo -n -- Converting Markdown documents to HTML... | |
@$(MARKDOWN) $(TEMP_DIR)/$(COVER).md > $(TEMP_DIR)/$(COVER).html | |
@$(MARKDOWN) $(TEMP_DIR)/$(MD_OUTPUT) > $(TEMP_DIR)/$(HTML_OUTPUT) | |
@echo ' Done.' | |
html2pdf: md2html | |
@echo -- Converting the HTML documents to PDFs... | |
@$(WKHTMLTOPDF) \ | |
--load-error-handling ignore \ | |
--encoding utf-8 \ | |
--user-style-sheet Resources/Styles.css \ | |
--minimum-font-size 14 \ | |
--footer-left "[date]" \ | |
--footer-right "[page] / [topage]" \ | |
--footer-font-size 10 \ | |
cover $(TEMP_DIR)/$(COVER).html \ | |
toc \ | |
--disable-dotted-lines \ | |
--xsl-style-sheet Resources/TOC.xsl \ | |
$(TEMP_DIR)/$(HTML_OUTPUT) \ | |
$(BUILD_DIR)/$(PDF_OUTPUT) | |
clean: | |
@rm -rf $(TEMP_DIR) | |
test: | |
@open $(BUILD_DIR)/$(PDF_OUTPUT) | |
.PHONY: all |
I assume this makefile is for a MAC since it uses ditto
? Is there too much to change to convert it to Linux?
perl Resources/Markdown.pl
?? where we can find this code?
perl Resources/Markdown.pl
?? where we can find this code?
I don't remember exactly, but it's probably this: https://daringfireball.net/projects/markdown/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@abalter this is a Makefile; it's meant to be used with Make instead of executed in bash. Check out this article for some motivation Why Use Make.