GitHub MarkDown:宏和变量是否可能?

pha*_*ace 38 github github-flavored-markdown

我一直在学习github markdown,我有一个关于变量和宏的问题.

是否可以定义变量或宏来防止重复打印文本块?

用例是我有一个表格生成一个大的超链接网格 - 链接如下所示.

http://www.a-big-long-big-big-long-hyperlink/more-long-stuff?id=1234
Run Code Online (Sandbox Code Playgroud)

如果我能做一次类似下面的事情会很好:

$link=http://www.a-big-long-big-big-long-hyperlink/more-long-stuff?id
Run Code Online (Sandbox Code Playgroud)

然后在表中的每个单元格中,我可以说出类似的内容

$link=1234
Run Code Online (Sandbox Code Playgroud)

其他一些细胞

$link=2345
Run Code Online (Sandbox Code Playgroud)

这个想法是这样的:

  • 该表(有10列和~10行)在普通屏幕上看起来更容易一些,目前链接的前缀太长,看起来很难看,因为链接包裹到下一行
  • 如果我想更改根链接,我可以在一个地方更改它(是的,我知道我可以在编辑器中进行搜索和替换!)

干杯.

小智 7

您可以使用 Markdown 的一项称为“参考样式链接”的功能。

[link text][id]或者只是[link text]链接文本是唯一的并且仅由字母、数字、空格和标点符号组成。它们不区分大小写。

然后在文档中的某处定义什么id是:

[id]: http://example.com/whatever

请参阅 https://github.com/biserkov/markdown-playground/blob/master/README.md

https://raw.githubusercontent.com/biserkov/markdown-playground/master/README.md

  • 这很好,但没有回答问题 (19认同)

Adi*_*Adi 7

以下是编写参考链接的几种方法

[I'm an inline-style link](https://www.somewebsite.com)

[I'm an inline-style link with title](https://www.somewebsite.com "somewebsite's Homepage")

[I'm a reference-style link][Arbitrary case-insensitive reference text]

[I'm a relative reference to a repository file](../blob/master/LICENSE)

[You can use numbers for reference-style link definitions][1]

Or leave it empty and use the [link text itself]

Some text to show that the reference links can follow later.

[arbitrary case-insensitive reference text]: https://www.somewebsite.org
[1]: http://somewebsite.org
[link text itself]: http://www.somewebsite.com
Run Code Online (Sandbox Code Playgroud)

  • 我不确定这如何回答问题。Op不想定义一个变量,例如url的根,并在许多只提供变化部分(ID)的位置使用该变量。 (23认同)
  • 文本的上下文可以以某种方式进入链接吗?例如,“[FOO-11](JIRA)”扩展到“https://jira.example.net/browse/FOO-11”? (2认同)