Replies: 1 comment
-
|
使用简单的语法在 GitHub 上为您的文章和代码创建复杂的格式。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
一个基于 Github Discussions 的静态页面(博客)构建工具,结合 Github Actions 的自动化,和 Github Pages 的托管服务,只需一个 Github 账号,即可实现无服务器的博客使用体验。
Markdown 语法示例
标题样式
要创建标题,请在标题文本前添加一至六个 # 符号。 你使用的 # 数量将决定标题的大小。
The largest heading
The second largest heading
The smallest heading
文本样式
可以在文章和评论中以粗体、斜体、删除线、下标或上标文本表示强调。
** **或__ __**This is bold text*** *或_ _*This text is italicized*~~ ~~~~This was mistaken text~~这是错误文本** **和_ _**This text is _extremely_ important***** ******All this text is important***<sub> </sub><sub>This is a subscript text</sub><sup> </sup><sup>This is a superscript text</sup>段落样式
通过在文本行之间留一个空白行,可创建新段落。
这是第一段。
这是第二段。
这是第三段。
引用文本
可以使用 > 来引用文本。
Text that is not a quote
引用代码
使用单反引号可标注句子中的代码或命令。 反引号中的文本不会被格式化。
Use
git statusto list all new or modified files that haven't yet been committed.要将代码或文本格式化为各自的不同块,请使用三反引号。
Some basic Git commands are:
要在代码块中显示三重倒引号,请将其包在四个倒引号内。
同理,如果要在代码块中显示四重倒引号,请将其包在五个倒引号内,以此类推。
语法突出显示
您可以添加可选的语言标识符,以在围栏代码块中启用语法突显。
例如,要语法突显 Ruby 代码:
支持的颜色模型
在文章中,可以使用反引号在句子中标注颜色。 反引号内支持的颜色模型将显示颜色的可视化效果。
The background color should be
#fffffffor light mode and#0d1117for dark mode.下面是当前支持的颜色模型。
`#RRGGBB``#0969DA`#0969DA`rgb(R,G,B)``rgb(9, 105, 218)`rgb(9, 105, 218)`hsl(H,S,L)``hsl(212, 92%, 45%)`hsl(212, 92%, 45%)链接样式
通过将链接文本用方括号 [ ] 括起来,然后将 URL 用括号 ( ) 括起来,可创建内联链接。
This site was built using GitHub Pages.
图片样式
通过添加 ! 并 将 alt 文本用 [ ] 括起来,可显示图像。 然后将图像的链接用括号 () 括起来。
指定图像显示的主题
你可以通过结合使用 HTML 元素和 prefers-color-scheme 媒体功能来指定在 Markdown 中显示图像的主题。 我们区分浅色和深色模式,因此有两个选项可用。 可以使用这些选项来显示针对深色或浅色背景进行了优化的图像。 这对于透明的 PNG 图像特别有用。
例如,以下代码显示浅色主题的太阳图像和深色主题的月亮,默认显示浅色主题的太阳图像(
img标签):列表样式
可通过在一行或多行文本前面加上
-、*或+来创建一个无序列表。嵌套列表
通过在一个列表项下面缩进一个或多个其他列表项,可创建嵌套列表。
在嵌套列表项的前面键入空格字符,直至列表标记字符(
-或*)位于其上方条目中第一个文本字符的正下方。在下例中,可以通过将嵌套列表项缩进至少五个空格来在列表项
100. First list item下添加一个嵌套列表项,因为在First list item前面有五个字符 (100.)。您可以使用相同的方法创建多层级嵌套列表。
任务列表
若要创建任务列表,请在列表项前加连字符
-和空格,后接[ ]。 要将任务标记为完成,请使用[x]。如果任务列表项说明以括号开头,则需要使用
\进行转义(仅第一个半括号):脚注样式
您可以使用此括号语法为您的内容添加脚注:
Here is a simple footnote1.
A footnote can also have multiple lines2.
You can also use words, to fit your writing style more closely3.
忽略 Markdown 格式
通过在 Markdown 字符前面输入
\,可指示 GitHub 忽略 Markdown 格式(或对其进行转义)。Let's rename \*our-new-project\* to \*our-old-project\*.Let's rename *our-new-project* to *our-old-project*.
使用表格组织信息
可以使用竖线 | 和连字符 - 创建表。 连字符用于创建每列的标题,而竖线用于分隔每列。 必须在表格前包含空白字符,以便其正确呈现。
表格末尾的竖线可选。
单元格的宽度可以不同,无需在列内准确对齐。 标题行的第一列中必须至少有三个横线。
格式化表格中的内容
可以在表格中使用上述格式,例如链接、内联代码块和文本样式:
git statusgit diff可以通过在标题行中连字符的左侧、右侧或两侧添加冒号
:,来靠左、靠右或居中对齐列中的文本。若要包含竖线
|作为单元格中的内容,请在竖线前使用\:编写数学表达式
为了实现数学表达式的清晰传达,GitHub 支持在 Markdown 中 LaTeX 格式的数学表达式。有关详细信息,请参阅 Wikibook 中的 LaTeX/数学。
GitHub 的数学呈现功能使用 MathJax;真是一种基于 JavaScript 的开源显示引擎。 MathJax 支持广泛的 LaTeX 宏,以及几个有用的辅助功能扩展。 有关详细信息,请参阅 MathJax 文档和 MathJax 辅助功能扩展文档。
编写内联表达式
要在文本中包含内联数学表达式,请使用美元符号
$分隔表达式。This sentence uses$\sqrt{3x-1}+(1+x)^2$
$delimiters to show math inline:将表达式编写为块
要以块的形式添加数学表达式,请启动一个新行,并使用两个美元符号
$$分隔表达式。The Cauchy-Schwarz Inequality
或者,可以使用
```math代码块语法将数学表达式显示为块。 使用此语法时,无需使用$$分隔符。Here is some math!
在数学表达式所在的行中和数学表达式内编写美元符号
要在数学表达式所在的同一行中将美元符号显示为字符,需要对非分隔符 $ 进行转义以确保行正确呈现。
在数学表达式内,在显式
$之前添加一个\符号。This expression uses
\$to display a dollar sign: $\sqrt{$4}$在数学表达式之外,但在同一行上,在显式
$两边使用span标记。To split $100 in half, we calculate$100/2$
使用折叠部分组织信息
可以通过创建读者可以选择展开的折叠部分来暂时隐藏 Markdown 的分区。
<details>块中的任何 Markdown 都将被折叠,直到读者单击 展开详细信息。 在<details>块中,使用<summary>标记创建一个标签。CLICK ME
We can hide anything, even code!
<details>标记是默认折叠的。关系图样式
可以使用以下三种不同的语法在 Markdown 中创建关系图:mermaid、geoJSON 和 topoJSON、ASCII STL。
创建 Mermaid 关系图
Mermaid 是一款受 Markdown 启发的工具,可将文本呈现为关系图。 例如,Mermaid 可以呈现流程图、序列图、饼图等。 有关详细信息,请参阅 Mermaid 文档。
若要创建 Mermaid 关系图,请使用
mermaid语言标识符在围栏代码块中添加 Mermaid 语法。Here is a simple flow chart:
graph TD; A-->B; A-->C; B-->D; C-->D;Here is a simple sequence diagram:
sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts <br/>prevail! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good!Here is a simple gantt diagram:
Here is a simple class diagram:
Here is a simple git graph:
gitGraph commit commit branch develop commit commit commit checkout main commit commitHere is a simple pie graph:
pie title Pets adopted by volunteers "Dogs" : 386 "Cats" : 85 "Rats" : 15等等,更多样式和语法请移步至官方文档。
创建 GeoJSON 和 TopoJSON 地图
可使用 GeoJSON/TopoJSON 语法创建交互式地图。 若要创建地图,请使用
geojson或topojson语法标识符在围栏代码块中添加 GeoJSON 或 TopoJSON。使用 GeoJSON
例如,可创建一个简单的地图:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "coordinates": [ [ [ 18.95789448727831, -26.559328216739694 ], [ 18.95789448727831, -29.231620443194416 ], [ 22.29983202967793, -29.231620443194416 ], [ 22.29983202967793, -26.559328216739694 ], [ 18.95789448727831, -26.559328216739694 ] ] ], "type": "Polygon" } } ] }使用 TopoJSON
例如,可创建简单的 TopoJSON 地图:
{ "type": "Topology", "transform": { "scale": [0.0005000500050005, 0.00010001000100010001], "translate": [100, 0] }, "objects": { "example": { "type": "GeometryCollection", "geometries": [ { "type": "Point", "properties": {"prop0": "value0"}, "coordinates": [4000, 5000] }, { "type": "LineString", "properties": {"prop0": "value0", "prop1": 0}, "arcs": [0] }, { "type": "Polygon", "properties": {"prop0": "value0", "prop1": {"this": "that"} }, "arcs": [[1]] } ] } }, "arcs": [[[4000, 0], [1999, 9999], [2000, -9999], [2000, 9999]],[[0, 0], [0, 9999], [2000, 0], [0, -9999], [-2000, 0]]] }有关使用
.geojson和.topojson文件的详细信息,请参阅“使用非代码文件”。创建 STL 3D 模型
可以直接在 Markdown 中使用 ASCII STL 语法来创建交互式 3D 模型。 若要显示模型,请使用
stl语法标识符在围栏代码块中添加 ASCII STL 语法。例如,一个简单的三角形 3D 模型:
solid cube_corner facet normal 0.0 -1.0 0.0 outer loop vertex 0.0 0.0 0.0 vertex 1.0 0.0 0.0 vertex 0.0 0.0 1.0 endloop endfacet facet normal 0.0 0.0 -1.0 outer loop vertex 0.0 0.0 0.0 vertex 0.0 1.0 0.0 vertex 1.0 0.0 0.0 endloop endfacet facet normal -1.0 0.0 0.0 outer loop vertex 0.0 0.0 0.0 vertex 0.0 0.0 1.0 vertex 0.0 1.0 0.0 endloop endfacet facet normal 0.577 0.577 0.577 outer loop vertex 1.0 0.0 0.0 vertex 0.0 1.0 0.0 vertex 0.0 0.0 1.0 endloop endfacet endsolid一个残缺的正方形 3D 模型:
solid cube facet normal 0.0 0.0 -1.0 outer loop vertex 0.0 0.0 0.0 vertex 0.0 1.0 0.0 vertex 1.0 1.0 0.0 endloop endfacet facet normal 0.0 0.0 -1.0 outer loop vertex 0.0 0.0 0.0 vertex 1.0 1.0 0.0 vertex 1.0 0.0 0.0 endloop endfacet facet normal 0.0 -1.0 0.0 outer loop vertex 0.0 0.0 1.0 vertex 1.0 0.0 1.0 vertex 1.0 0.0 0.0 endloop endfacet facet normal 0.0 -1.0 0.0 outer loop vertex 0.0 0.0 1.0 vertex 0.0 0.0 0.0 vertex 1.0 0.0 0.0 endloop endfacet facet normal 0.0 0.0 1.0 outer loop vertex 0.0 1.0 0.0 vertex 0.0 1.0 1.0 vertex 1.0 1.0 1.0 endloop endfacet facet normal 0.0 0.0 1.0 outer loop vertex 0.0 1.0 0.0 vertex 1.0 1.0 1.0 vertex 1.0 1.0 0.0 endloop endfacet facet normal -1.0 0.0 0.0 outer loop vertex 0.0 0.0 1.0 vertex 0.0 1.0 1.0 vertex 0.0 1.0 0.0 endloop endfacet facet normal -1.0 0.0 0.0 outer loop vertex 0.0 0.0 1.0 vertex 0.0 0.0 0.0 vertex 0.0 1.0 0.0 endloop endfacet facet normal 0.0 1.0 0.0 outer loop vertex 1.0 0.0 1.0 vertex 1.0 1.0 1.0 vertex 0.0 1.0 1.0 endloop endfacet facet normal 0.0 1.0 0.0 outer loop vertex 1.0 0.0 1.0 vertex 0.0 1.0 1.0 vertex 1.0 1.0 0.0 endloop endfacet endsolid有关使用
.stl文件的详细信息,请参阅“使用非代码文件”。添加附件
GitHub 支持在讨论中添加附件,要将文件附加到讨论中,请将它拖放到评论框中。 或者,您也可以单击评论框底部的栏来浏览、选择和添加计算机中的文件。
附加文件时,该文件会立即上传到 GitHub 并更新文本字段,以显示该文件的匿名 URL。 有关匿名 URL 的详细信息,请参阅“关于匿名 URL”。
最大文件大小为:
我们支持这些文件:
Photo by Ivan Rohovchenko on Unsplash
更多信息请参阅:GitHub Markdown 官方文档
Footnotes
My reference. ↩
Every new line should be prefixed with 2 spaces.
This allows you to have a footnote with multiple lines. ↩
Named footnotes will still render with numbers instead of the text but allow easier identification and linking.
This footnote also has been made with a different syntax using 4 spaces for new lines. ↩
Beta Was this translation helpful? Give feedback.
All reactions