Linux command
cmark 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Convert Markdown to HTML
cmark [input.md]
Convert to specific format
cmark --to [html|xml|man|latex] [input.md]
Read from stdin
cat [input.md] | cmark
Output to file
cmark [input.md] > [output.html]
Enable smart typography
cmark --smart [input.md]
Convert to groff man page
cmark --to man [input.md]
Validate UTF-8
cmark --validate-utf8 [input.md]
Render with hard line breaks
cmark --hardbreaks [input.md]
说明
cmark is the reference C implementation of CommonMark, a strongly specified and highly compatible variant of Markdown. It parses Markdown input and converts it to various output formats including HTML, XML, groff man pages, CommonMark, and LaTeX. The parser is designed for correctness and performance, strictly following the CommonMark specification to eliminate the ambiguities present in the original Markdown description. This makes it suitable for applications that require predictable, consistent rendering across different tools. cmark reads from files or standard input and writes to standard output, making it easy to integrate into pipelines. The --smart option provides typographic enhancements like curly quotes and em-dashes, while --safe strips potentially dangerous raw HTML from input.
参数
- --to _format_
- Output format: html, xml, man, commonmark, latex.
- --smart
- Enable smart punctuation (curly quotes, dashes).
- --safe
- Omit raw HTML and potentially unsafe links.
- --validate-utf8
- Validate UTF-8 and replace invalid sequences.
- --hardbreaks
- Render soft breaks as hard breaks.
- --nobreaks
- Render soft breaks as spaces.
- --width _N_
- Wrap text at N columns (default 0, no wrap). Only affects commonmark and man output.
- --sourcepos
- Include source position information in output.
FAQ
What is the cmark command used for?
cmark is the reference C implementation of CommonMark, a strongly specified and highly compatible variant of Markdown. It parses Markdown input and converts it to various output formats including HTML, XML, groff man pages, CommonMark, and LaTeX. The parser is designed for correctness and performance, strictly following the CommonMark specification to eliminate the ambiguities present in the original Markdown description. This makes it suitable for applications that require predictable, consistent rendering across different tools. cmark reads from files or standard input and writes to standard output, making it easy to integrate into pipelines. The --smart option provides typographic enhancements like curly quotes and em-dashes, while --safe strips potentially dangerous raw HTML from input.
How do I run a basic cmark example?
Run `cmark [input.md]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --to _format_ do in cmark?
Output format: html, xml, man, commonmark, latex.