本文介绍了Markdown文件中的GitHub相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在一个Markdown文件中创建一个URL定位点< a> ,链接到同一个存储库和分支内的另一个文件(又名a链接相对于当前分支)?



例如,在master分支中,我有一个README.md文件,我想这样做:

 #我的项目
真的很酷。我的项目有一个名为myLib的子目录,见下文。

## myLib文档
请参阅文档[here](myLib / README.md)

这将允许我在同一分支中从一个.md链接到另一个。不必担心我在哪个分支(避免必须执行包含github.com分支的绝对URL姓名)。



以下是我的一个实际例子:


  1. GOTO ,链接不起作用。

  2. GOTO 。

    解决方案

    更新 2013年1月30日,16个月后: /github.com/blog/1395-relative-links-in-markup-filesrel =noreferrer> GitHub Blog Post 标记文件中的相对链接






    2011年12月20日更新:



    目前由 technoweenie ,附注:






    2011年10月12日:

    如果您看 Markdown本身(!),相对路径似乎不被支持。

    您会找到如下引用:

      [r2h]:http://github.com/github/markup/tree/master/lib/github/commands/rest2html 
    [r2hc]:http: //github.com/github/markup/tree/master/lib/github/markups.rb#L13


    Is there a way to create a URL anchor, <a>, link from within a Markdown file, to another file within the same repository and branch (aka a link relative to the current branch)?

    For example, in the master branch I have a README.md file, which I would like do something like:

    # My Project
    is really really cool. My Project has a subdir named myLib, see below.
    
    ## myLib documentation
    see documentation [here](myLib/README.md)
    

    This would allow me to link from one .md to another within the same branch and not have to worry about which branch I'm in (avoid having to do an absolute URL that includes the github.com branch name).

    Here is a working example of what I mean:

    1. GOTO http://github.com/rynop/testRel, link does not work.
    2. GOTO http://github.com/rynop/testRel/blob/master/README.md, link works.

    This is expected because at this point the starting URL is in the branch. Now how do I get it to pick up the current branch in the README.md at the root of the repository?

    Update: I opened an issue against GitHub for this feature request.

    解决方案

    Update 30th, January 2013, 16 months later:

    GitHub Blog Post Relative links in markup files:


    Update December 20th, 2011:

    The GitHub markup issue 84 is currently closed by technoweenie, with the comment:


    October 12th, 2011:

    If you look at the raw source of the README.md of Markdown itself(!), relative paths don't seem to be supported.
    You will find references like:

    [r2h]: http://github.com/github/markup/tree/master/lib/github/commands/rest2html
    [r2hc]: http://github.com/github/markup/tree/master/lib/github/markups.rb#L13
    

    这篇关于Markdown文件中的GitHub相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 16:20