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:
Niklas Fasching 2021-01-02 18:56:35 +01:00
parent 1b68e209ac
commit 84d56e9562
4 changed files with 20 additions and 12 deletions

View file

@ -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+":")
}