html: Rewrite local links to .org files to .html
emacs rewrites links to `.org` files to corresponding links with `.html` extension in the html export.
This commit is contained in:
parent
1b68e209ac
commit
84d56e9562
4 changed files with 20 additions and 12 deletions
|
@ -342,6 +342,9 @@ func (w *HTMLWriter) WriteRegularLink(l RegularLink) {
|
|||
if l.Protocol == "file" {
|
||||
url = url[len("file:"):]
|
||||
}
|
||||
if (l.Protocol == "file" || l.Protocol == "") && strings.HasSuffix(url, ".org") {
|
||||
url = strings.TrimSuffix(url, ".org") + ".html"
|
||||
}
|
||||
if prefix := w.document.Links[l.Protocol]; prefix != "" {
|
||||
url = html.EscapeString(prefix) + strings.TrimPrefix(url, l.Protocol+":")
|
||||
}
|
||||
|
|
3
org/testdata/inline.html
vendored
3
org/testdata/inline.html
vendored
|
@ -67,6 +67,9 @@ not emphasized/</p>
|
|||
<p>regular link to a file (image) <img src="my-img.png" alt="my-img.png" title="my-img.png" /></p>
|
||||
</li>
|
||||
<li>
|
||||
<p>regular link to an org file (extension replaced with html) <a href="inline.html">inline.html</a> / <a href="../testdata/inline.html">../testdata/inline.html</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p>regular link to a file (video) <video src="my-video.mp4" title="my-video.mp4">my-video.mp4</video></p>
|
||||
</li>
|
||||
<li>
|
||||
|
|
13
org/testdata/inline.org
vendored
13
org/testdata/inline.org
vendored
|
@ -25,12 +25,13 @@
|
|||
1. regular link [[https://example.com]] link without description
|
||||
2. regular link [[https://example.com][example.com]] link with description
|
||||
3. regular link to a file (image) [[file:my-img.png]]
|
||||
4. regular link to a file (video) [[my-video.mp4]]
|
||||
5. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
6. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
7. regular link with image as description [[https://placekitten.com][https://placekitten.com/200/200#.png]]
|
||||
8. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
9. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
4. regular link to an org file (extension replaced with html) [[file:inline.org]] / [[../testdata/inline.org]]
|
||||
5. regular link to a file (video) [[my-video.mp4]]
|
||||
6. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
7. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
8. regular link with image as description [[https://placekitten.com][https://placekitten.com/200/200#.png]]
|
||||
9. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
10. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
- timestamps
|
||||
- <2019-01-06>
|
||||
- <2019-01-06 Sun>
|
||||
|
|
13
org/testdata/inline.pretty_org
vendored
13
org/testdata/inline.pretty_org
vendored
|
@ -25,12 +25,13 @@
|
|||
1. regular link [[https://example.com]] link without description
|
||||
2. regular link [[https://example.com][example.com]] link with description
|
||||
3. regular link to a file (image) [[file:my-img.png]]
|
||||
4. regular link to a file (video) [[my-video.mp4]]
|
||||
5. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
6. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
7. regular link with image as description [[https://placekitten.com][https://placekitten.com/200/200#.png]]
|
||||
8. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
9. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
4. regular link to an org file (extension replaced with html) [[file:inline.org]] / [[../testdata/inline.org]]
|
||||
5. regular link to a file (video) [[my-video.mp4]]
|
||||
6. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
7. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
8. regular link with image as description [[https://placekitten.com][https://placekitten.com/200/200#.png]]
|
||||
9. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
10. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
- timestamps
|
||||
- <2019-01-06 Sun>
|
||||
- <2019-01-06 Sun>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue