midtowndrafting.com/content/docs/guide/markdown.zh-cn.md
2024-05-03 19:04:48 -04:00

2.6 KiB
Raw Blame History

title weight
Markdown 2

Hugo 支持 Markdown 来书写内容,创建列表等。本页将向你展示一些最常见的 Markdown 语法示例。

Markdown 示例

文本样式

Style Syntax Example Output
Bold **bold text** **bold text** bold text
Italic *italicized text* `italicized text italicized text
Strikethrough ~~strikethrough text~~ ~~strikethrough text~~ strikethrough text
Subscript <sub></sub> This is a <sub>subscript</sub> text This is a subscript text
Superscript <sup></sup> This is a <sup>superscript</sup> text This is a superscript text

引用

带角标的块引用:

Don't communicate by sharing memory, share memory by communicating.
Rob Pike1

表格

表格并非核心 Markdown 规范,但 Hugo 支持开箱即用的表格:

Name Age
Bob 27
Alice 23

Markdown 表格中的内联

Italics Bold Code
italics bold code

代码块

{{< cards >}} {{< card link="../../guide/syntax-highlighting" title="Syntax Highlighting" icon="sparkles" >}} {{< /cards >}}

列表

有序列表

  1. First item
  2. Second item
  3. Third item

无序列表

  • List item
  • Another item
  • And another item

嵌套列表

  • Fruit
    • Apple
    • Orange
    • Banana
  • Dairy
    • Milk
    • Cheese

图片

带有标题:

配置

Hugo 使用 Goldmark 解析 Markdown。 Markdown 渲染可以在 hugo.yaml 中的 markup.goldmark 中配置。以下是Hextra的默认配置

markup:
  goldmark:
    renderer:
      unsafe: true
  highlight:
    noClasses: false

如需了解更多选项,转至 Configure Markup

参考资料


  1. The above quote is excerpted from Rob Pike's talk during Gopherfest, November 18, 2015. ↩︎