Use the Markdown editor in Linux for document work

Source: Internet
Author: User

Use the Markdown editor in Linux for document work

Since Markdown is used, it is easy to do document work. I almost used Markdown to complete all the document work in my work. There have been some new experiences and some new problems recently.

In Linux, you can use the retext tool to edit markdown:

# Debian/Ubuntu
Sudo apt-get install retext
# Use the following command to edit a file:
Retext Release-Notes.md

To convert a markdown file to an html file, you can use the markdown provided by the discount or python-markdown software package:

# Debian/Ubuntu
Sudo apt-get install discount

Or:

# Debian/Ubuntu
Sudo apt-get install python-markdown

The conversion is simple:

# Use the markdown tool provided by discount
Markdown-o Release-Notes.html Release-Notes.md
# Use the markdown_py tool provided by python-markdown
Markdown_py-o html4 Release-Notest.md> Release-Notes.html

To generate a PDF file, you can use the xhtml2pdf file provided by python-pisa:

# Debian/Ubuntu
Sudo apt-get install python-pisa

# Converting html to PDF
Xhtml2pdf -- html Release-Notes.html Release-Notes.pdf <span class = "pln"> </span>

Therefore, you can place such a Makefile in the document directory to automate this process:

# Makefile

MD = markdown
MDFLAGS =-T
H2P = xhtml2pdf
H2PFLAGS = -- html
SOURCES: = $ (wildcard *. md)
OBJECTS: = $ (patsubst %. md, example .html, $ (wildcard *. md ))
OBJECTS_PDF: = $ (patsubst %. md, commandid, $ (wildcard *. md ))

All: build

Build: html pdf

Pdf: $ (OBJECTS_PDF)

Html: $ (OBJECTS)

$ (OBJECTS_PDF): objects.html
$ (H2P) $ (H2PFLAGS) $ <>$ @

$ (OBJECTS): OBJECTS .html: %. md
$ (MD) $ (MDFLAGS)-o $ @ $ <
Clean:
Rm-f $ (OBJECTS)

In this way, you can use a simple command to generate pdf or html output of all md files in the current directory:

# Html output
Make html

# Pdf output
Make pdf

The problem here is that if the content of markdown is Chinese, the converted html cannot be automatically recognized when opened in the browser, and the pdf is worse, which is a bunch of garbled characters. In this case, we can use markdown's support for html tags to add encoding information to the markdown file. For example, to convert markdown to an HTML 4 file, you can add the meta tag at the beginning of the file to specify the encoding format:

Sed-I '1i \ <meta http-equiv = "content-type" content = "text/html; charset = UTF-8"> '*. md

In this way, you can. In addition, when the editing system of the Turing community is recently used, markdown uses the underscore (_) as an italic mark from time to time, and the result function name becomes like this:

# Ssl_use_cabundle
Sslusecabundle

We recommend that you use a single asterisk (*) and a bold font with two asterisks (**) for Italics. This makes it much easier to use. Of course, this problem lies in the fact that markdown can be used with asterisks or underscores. But in fact, both support may cause some problems. For example, in some cases, underlines (_ bold _-> bold) are used, and in some cases, asterisks (** bold **-> bold) are used ), it Seems messy (another reason for selecting an asterisk * is that the probability of an underline appearing in the content is much higher than that of an asterisk ).

Markdown: Basics (Quick Start)

Markdown syntax description (Simplified Chinese Version)

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.