Convert markdown to html view.
To convert markdown files to html file, or you can use discount package provided by python-markdown markdown
# Debian/Ubuntu sudo apt-get install discount
or:
# Debian/Ubuntu sudo apt-get install python-markdown
Conversion work is very simple:
# Markdown tool provided with a discount markdown -o-notes.html Release Release- Notes.md # with Python - markdown_py tool markdown provided markdown_py -o HTML4 Release-Notest.md> Release-notes.html
If you want to generate PDF, it is also very simple, you can use xhtml2pdf python-pisa provided:
Debian # / Ubuntu sudo APT-GET install Python - pisa # Convert html into PDF xhtml2pdf --html Release-Release-Notes.pdf notes.html
So you can put in the documentation directory such a Makefile to automate this process:
# Makefile MD = markdown MDFLAGS = -T H2P = xhtml2pdf H2PFLAGS = --html SOURCES := $(wildcard *.md) OBJECTS := $(patsubst %.md, %.html, $(wildcard *.md)) OBJECTS_PDF := $(patsubst %.md, %.pdf, $(wildcard *.md)) all: build build: html pdf pdf: $(OBJECTS_PDF) html: $(OBJECTS) $(OBJECTS_PDF): %.pdf: %.html $(H2P) $(H2PFLAGS) $< > $@ $(OBJECTS): %.html: %.md $(MD) $(MDFLAGS) -o $@ $< clean: rm -f $(OBJECTS)
So you can be generated by a simple command in the current directory md pdf or html output of all of the documents:
# Html output of the make HTML # pdf output of the make pdf
The problem here is that if the content markdown is Chinese, then the conversion will not be able to open out html coding automatically recognize the browser, pdf worse, is a pile of garbage directly. Then we can use markdown support for html tags to encode information in the markdown added to the file. For example, we want to convert markdown html4 file, you can add a meta tag in the beginning of the file, specify the encoding format:
sed -i '1i\<meta http-equiv="content-type" content="text/html; charset=UTF-8">' *.md
that's it. In addition, recent use editing system Turing community, markdown from time to time will underscore (_) as italic tags, became the result of the function name like this:
# Actually ssl_use_cabundle
sslusecabundle
I recommend italics mark with a single asterisk (*), bold use of two asterisks (**), so much more convenient to use. Of course, the problem itself is that markdown said with an asterisk or underscore can be. But in fact, both support actually cause problems. For instance, some places are underlined (bold __ __ -> bold ), in some places with an asterisk (** bold ** -> bold ), it appears to have actually chaos (choose another asterisk * one reason is that the probability underlined appear in the content much) higher than the asterisk.
We recommend Turing community online editing system to specify one, then in the examples and online editor have adopted a unified, so that most people can understand the kind of use.
Editor:
http://www.ituring.com.cn/article/10044 Author: Wu Haifeng (ID: acid-free)