fix: remove newlines in link descriptions

Currently, when an orgmode link has a newline in its description, it
is passed to the description of the Gemini link. Example:

```org
[[https://example.com][This is a link with a
newline to example.com]]
```

Which exports to:

```gmi
=> https://example.com This is a link with a
newline to example.com
```

This commit fixes this by replacing newlines with a simple space. The
new output is:

```gmi
=> https://example.com This is a link with a newline to example.com
```

It also fixes a compilation error on Emacs 30 by properly escaping
quotation marks.

Signed-off-by: Lucien Cartier-Tilet <lucien@phundrak.com>
This commit is contained in:
Lucien Cartier-Tilet 2023-05-11 11:23:11 +02:00
parent 168f820ea4
commit 94dd2f4a8e
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -79,7 +79,8 @@ ITEM is the parsed-org element with all properties."
(defun org-gemini-code-inline (input _contents info) (defun org-gemini-code-inline (input _contents info)
"Generate an inline code in Gemtext from the parsed INPUT. "Generate an inline code in Gemtext from the parsed INPUT.
INPUT is either a 'src-block' or 'example-block' element. INFO is a plist." INPUT is either a \\='src-block\\=' or \\='example-block\\='
element. INFO is a plist."
;; there's a bug here where there's a trailing space in the `` ;; there's a bug here where there's a trailing space in the ``
(format "`%s`" (org-export-format-code-default input info))) (format "`%s`" (org-export-format-code-default input info)))
@ -108,9 +109,10 @@ INFO is a plist."
(concat (file-name-sans-extension (org-element-property :path link)) ".gmi") (concat (file-name-sans-extension (org-element-property :path link)) ".gmi")
raw-path)) raw-path))
(desc (org-element-contents link)) (desc (org-element-contents link))
(anchor (org-export-data (anchor (string-replace "\n" " "
(or desc (org-element-property :raw-link link)) (org-export-data
info))) (or desc (org-element-property :raw-link link))
info))))
(format "=> %s %s\n" (url-encode-url path) anchor))) (format "=> %s %s\n" (url-encode-url path) anchor)))
links "") links "")
(when (car links) (when (car links)