Markdown 파일의 GitHub 상대 링크
<a>
마크 다운 파일 내에서 동일한 저장소 및 브랜치 (현재 브랜치에 상대적인 링크) 내 다른 파일 로 URL 앵커, 링크 를 생성하는 방법이 있습니까?
예를 들어, 마스터 브랜치에는 README.md 파일이 있는데, 다음과 같이하고 싶습니다.
# My Project
is really really cool. My Project has a subdir named myLib, see below.
## myLib documentation
see documentation [here](myLib/README.md)
이렇게하면 동일한 브랜치 내에서 하나의 .md에서 다른 브랜치로 링크 할 수 있고 내가 속한 브랜치에 대해 걱정할 필요가 없습니다 (github.com 브랜치 이름을 포함하는 절대 URL을 수행 할 필요가 없음).
다음은 제가 의미하는 작업의 예입니다.
- GOTO http://github.com/rynop/testRel , 링크가 작동하지 않습니다.
- GOTO http://github.com/rynop/testRel/blob/master/README.md , 링크가 작동합니다.
이 시점에서 시작 URL이 분기에 있기 때문에 예상됩니다. 이제 저장소의 루트에있는 README.md에서 현재 분기를 선택하려면 어떻게해야합니까?
업데이트 : 이 기능 요청에 대해 GitHub에 대한 문제 를 열었습니다 .
16 개월 후 2013 년 1 월 30 일 업데이트 :
마크 업 파일의 GitHub 블로그 게시물 상대 링크 :
오늘부터 GitHub는 마크 업 파일의 상대 링크를 지원합니다 .
이제 GitHub 자체에서 문서를 보든 다른 마크 업 렌더러를 사용하여 로컬에서 보든 다른 문서 파일간에 직접 연결할 수 있습니다.링크 정의 및 작동 방식의 예를 원하십니까? 여기 Markdown이 있습니다.
절대 링크 대신 :[a link](https://github.com/user/repo/blob/branch/other_file.md)
… 상대 링크를 사용할 수 있습니다.
[a relative link](other_file.md)
그리고 우리는 그것이
user/repo/blob/branch/other_file.md
.와 같은 해결 방법
[a workaround link](repo/blob/master/other_file.md)
을 사용하는 경우 새 구문을 사용하도록 문서를 업데이트해야합니다.이는 또한 문서가 항상 GitHub를 가리 키지 않고서도 쉽게 독자적으로 설 수 있음을 의미 합니다 .
2011 년 12 월 20 일 업데이트 :
GitHub의 마크 업 문제 (84)는 현재에 의해 폐쇄 technoweenie 주석으로 :
이에 대한
<base>
태그를 추가하려고했지만 사이트의 다른 관련 링크에 문제가 발생합니다.
2011 년 10 월 12 일 :
Markdown 자체 (!) 의 원시 소스README.md
를 보면 상대 경로가 지원되지 않는 것 같습니다.
다음과 같은 참조를 찾을 수 있습니다.
[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
예를 들어 다음과 같은 저장소가 있습니다.
project/
text.md
subpro/
subtext.md
subsubpro/
subsubtext.md
subsubpro2/
subsubtext2.md
subtext.md
in에 대한 상대 링크 text.md
는 다음과 같습니다.
[this subtext](subpro/subtext.md)
subsubtext.md
in에 대한 상대 링크 text.md
는 다음과 같습니다.
[this subsubtext](subpro/subsubpro/subsubtext.md)
subtext.md
in에 대한 상대 링크 subsubtext.md
는 다음과 같습니다.
[this subtext](../subtext.md)
subsubtext2.md
in에 대한 상대 링크 subsubtext.md
는 다음과 같습니다.
[this subsubtext2](../subsubpro2/subsubtext2.md)
text.md
in에 대한 상대 링크 subsubtext.md
는 다음과 같습니다.
[this text](../../text.md)
2013 년 1 월 31 일부터 Github 마크 다운 은 파일에 대한 상대 링크를 지원합니다 .
[a relative link](markdown_file.md)
그러나이 댓글 스레드에서 논의 된 몇 가지 결함이 있습니다 .
대안으로 Gitdown 을 사용 하여 저장소에 대한 전체 URL을 구성하고 분기를 인식하도록 만들 수도 있습니다.
{"gitdown": "gitinfo", "name": "url"} // https://github.com/gajus/gitdown
{"gitdown": "gitinfo", "name": "branch"} // master
Gitdown is a GitHub markdown preprocessor. It streamlines common tasks associated with maintaining a documentation page for a GitHub repository, e.g. generating table of contents, including variables, generating URLs and getting information about the repository itself at the time of processing the input. Gitdown seamlessly integrates with your building scripts.
I am the author of the Gitdown library.
GitHub could make this a lot better with minimal work. Here is a work-around.
I think you want something more like
[Your Title](your-project-name/tree/master/your-subfolder)
or to point to the README itself
[README](your-project-name/blob/master/your-subfolder/README.md)
Good Luck
Just wanted to add this because none of the above solutions worked if target link is directory with spaces in it's name. If target link is a directory and it has space then even escaping space with \ doesn't render the link on Github. Only solution worked for me is using %20
for each space.
e.g.: if directory structure is this
Top_dir
|-----README.md
|-----Cur_dir1
|----Dir A
|----README.md
|----Dir B
|----README.md
To make link to Dir A
in README.md present in Top_dir
you can do this:
[Dir 1](Cur_dir1/Dir%20A)
You can link to file, but not to folders, and keep in mind that, Github will add /blob/master/
before your relative link(and folders lacks that part so they cannot be linked, neither with HTML <a>
tags or Markdown link).
So, if we have a file in myrepo/src/Test.java
, it will have a url like:
https://github.com/WesternGun/myrepo/blob/master/src/Test.java
And to link it in the readme file, we can use:
[This is a link](src/Test.java)
or: <a href="src/Test.java">This is a link</a>
.
(I guess, master
represents the master
branch and it differs when the file is in another branch.)
You can use relative URLs from the root of your repo with <a href="">
. Assuming your repo is named testRel
, put the following in testRel/README.md
:
# My Project
is really really cool. My Project has a subdir named myLib, see below.
## myLib docs
see documentation:
* <a href="testRel/myLib">myLib/</a>
* <a href="testRel/myLib/README.md">myLib/README.md</a>
This question is pretty old, but it still seems important, as it isn't easy to put relative references from readme.md to wiki pages on Github.
I played around a little bit and this relative link seems to work pretty well:
[Your wiki page](../../wiki/your-wiki-page)
The two ../
will remove /blob/master/
and use your base as a starting point. I haven't tried this on other repositories than Github, though (there may be compatibility issues).
I am not sure if I see this option here. You can just create a /folder
in your repository and use it directly:
[a relative link](/folder/myrelativefile.md)
No blob or tree or repository name is needed, and it works like a charm.
If you want a relative link to your wiki page on GitHub, use this:
Read here: [Some other wiki page](path/to/some-other-wiki-page)
If you want a link to a file in the repository, let us say, to reference some header file, and the wiki page is at the root of the wiki, use this:
Read here: [myheader.h](../tree/master/path/to/myheader.h)
The rationale for the last is to skip the "/wiki" path with "../", and go to the master branch in the repository tree without specifying the repository name, that may change in the future.
참고URL : https://stackoverflow.com/questions/7653483/github-relative-link-in-markdown-file
'programing tip' 카테고리의 다른 글
JavaScript에 제공된 범위 내에서 범위를 생성하는 "range ()"와 같은 메서드가 있습니까? (0) | 2020.09.30 |
---|---|
Android에서 지연 후 메서드를 호출하는 방법 (0) | 2020.09.30 |
std :: wstring VS std :: string (0) | 2020.09.30 |
순서를 유지하면서 목록에서 중복을 제거하는 방법은 무엇입니까? (0) | 2020.09.30 |
Git 커밋 수는 어떻게 얻습니까? (0) | 2020.09.30 |