Markdown Tutorial
Markdown is a lightweight markup language that allows people to write documents using an easy-to-read, easy-to-write plain-text format.
The Markdown language was created in 2004 by John Gruber (English: John Gruber).
Markdown's design philosophy is 'easy to read, easy to write,' enabling people to use a simple plain-text format to write structured documents.
Documents written in Markdown can be exported to many formats such as HTML, Word, images, PDF, and EPUB.
Documents written in Markdown use the extensions .md and .markdown.
Markdown's core features include:
simplicity: Uses intuitive symbols to represent formatting, for example, using # to represent headings and * to represent list items. These symbols convey their meaning visually and remain readable even without rendering.
Readability: Even a plain-text Markdown document clearly shows the structure and hierarchy of the content. Readers can understand how the content is organized without specialized software.
Portability: Markdown files are in plain-text format and can be opened and edited in any text editor, without depending on specific software or an operating system.
Convertibility: It can be easily converted to HTML, PDF, Word documents, and other formats to meet different publishing needs.
The concept of lightweight markup languages
A markup language is a language that uses specific symbols to describe the structure and formatting of a document. Traditional markup languages like HTML are powerful but have complex syntax, whereas lightweight markup languages simplify this process.
Compared with HTML, Markdown's advantages are:
- Low learning cost; you can master the basic syntax in a few minutes
- High writing efficiency; no need to type complex tags
- Focus on content rather than formatting details
- Version-control friendly, making collaboration and change tracking easy
The relationship between Markdown and HTML
Markdown is not a replacement for HTML but a simplified version of it. In fact, Markdown's ultimate goal is to be converted to HTML. The relationship between the two can be understood as follows:
Markdown 源码 → 解析器 → HTML 输出 → 浏览器渲染
For example, when you write:
# 这是一个标题
It will be converted to:
这是一个标题
Importantly, in Markdown you can directly use HTML tags, which provides flexibility for complex formatting. When Markdown's basic syntax cannot meet your needs, you can embed HTML code to achieve specific effects.
Why choose Markdown
Improve writing efficiency: No need to frequently use the mouse for formatting, allowing you to maintain a continuous flow of thought. Writers can focus on content creation without being distracted by formatting issues.
Lower the learning barrier: Compared with markup languages such as LaTeX and HTML, Markdown's syntax is extremely simple, and most people can master the basics within an hour.
Broad compatibility: Almost all modern text editors, code editors, and note-taking apps support Markdown. From a simple Notepad to a professional IDE, you can find Markdown everywhere.
Version-control friendly: Because it is plain text, Markdown files work well with version control systems such as Git, making it easy to track document change history and collaborate as a team.
Future adaptability: Even if specific software or platforms disappear, Markdown files as plain text can still be accessed and edited, ensuring the long-term availability of the content.
Markdown use cases
Technical documentation authoring
In software development, Markdown has become the standard format for technical documentation. It is especially suitable for:
-
API Documentation: Clear heading levels and code blocks make API descriptions both professional and readable. Many API documentation generators (such as Swagger) support Markdown-format descriptions.
-
Project documentation: From installation guides to user manuals, Markdown can effectively organize technical information. Code examples, configuration files, and command-line operations can all be presented appropriately.
-
Development guidelines: A team's coding standards, design principles, and workflows can all be written in Markdown, making it easy for team members to consult and update.
Blog post writing
Most modern blogging platforms and static site generators support Markdown:
-
Content management: Bloggers can focus on content creation without worrying about complex HTML coding. Article formatting is accomplished with simple markup.
-
Platform migration: Articles written in Markdown can be easily migrated between different platforms without being locked in by platform-specific formatting.
-
Offline writing: You can write articles offline in any text editor and then publish them in batches, increasing writing flexibility.
GitHub README files
The GitHub platform widely uses Markdown, especially for project README files:
-
Project introduction: Clearly present key information such as the project's purpose, features, and usage.
-
Installation guide: Provide detailed installation and configuration steps through code blocks and lists.
-
Contribution guide: Explain how to participate in project development, including code standards and submission workflows.
-
Issue tracking: In Issues and Pull Requests, developers use Markdown to describe problems and provide solutions.
Note-taking and knowledge management
Markdown is becoming the preferred format for digital notes:
-
study notes: It supports various content types such as math formulas, code highlighting, and diagrams, making it suitable for technical learning and knowledge organization.
-
Meeting notes: A clear heading structure and list format make meeting points clear at a glance.
-
Knowledge base building: Both enterprises and individuals use Markdown to build knowledge bases, organizing information through links and tags.
Online writing platforms
More and more writing platforms are beginning to support Markdown:
-
GitHub, Jianshu, Zhihu: The editors on these platforms support Markdown syntax, allowing creators to format articles quickly.
-
GitBook, Notion: Professional documentation and note-taking platforms natively support Markdown, providing powerful organization and collaboration features.
-
Static site generators: Tools such as Jekyll, Hugo, and Hexo let users create professional websites with Markdown.
Useful books
The book 'The Amazing Markdown':