【问题标题】:Markdown link within document to heading with a period文档中的 Markdown 链接到带有句点的标题
【发布时间】:2019-01-31 19:43:56
【问题描述】:

我有一个 Markdown 文档,其中包含如下标题:

## my-script.sh

我想在this Stack Overflow 问题中创建一个命名锚。所以我希望这会奏效:

[my-script.sh](#my-script-sh)

虽然没有。 Github here here here here here 提供了我尝试过的各种示例。

我怎样才能使这项工作(不从标题中删除点)?

【问题讨论】:

    标签: markdown


    【解决方案1】:

    就 Github Flavored Markdown 而言,如上面 Nicolás Alarcón R. 的更新所示,如果您有标题:

    ## my-script.sh
    

    创建内联链接的语法是:

    [my-script.sh](#my-scriptsh)
    

    【讨论】:

    • 还有哪些字符是 id 标签的禁区?
    【解决方案2】:

    语法不正确:

    • 只引用了一个焊盘而不是两个。
    • .sh 将其作为一个文件

    解决方案

    试试以下方法:

    [my-script.sh](##`my-script.sh`)
    
    ## `my-script.sh`
    

    我们所做的是对作为文件获取的内容进行消歧,在将其放在引号中时将其转换为名称。

    更新22012019110907

    在对之前提出的为什么不起作用进行有趣的调查之前,我已经找到了一个可行的(临时)解决方案。

    解决方法是通过readme符号获取链接

    复制链接并在我们的链接中生成:

    [test.sh](https://github.com/<nameuser>/<namerepo>/<branch>/test#testsh)
    
    ## `test.sh`
    

    例如:

    [test.sh](https://github.com/user/myrepo/tree/test#testsh)
    
    ## `test.sh`
    

    试试我

    This 或代码 sn-p :

    &lt;script src="https://gist.github.com/nicolasalarconrapela/3aee67d541271b8775bc1a50f1032c00.js"&gt;&lt;/script&gt;

    【讨论】:

    • @AlexHarvey 你在哪里实现这个?
    • 我不明白你所说的它在 Visual Code 中工作的意思——你的意思是它在特定版本的 Markdown 中正确显示吗?
    • 我更新了这个问题,提供了我尝试过的 4 个版本的链接,您可以在 Github 上查看代码。
    • @AlexHarvey 我回顾了
    猜你喜欢
    • 2010-09-17
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多