1

When exporting a document such as:

 * Title

 Link to [[Title]]

The link text is converted to the section number. I.e.

1. Title

Link to 1

Is there a way to keep the link text e.g.:

1. Title

Link to Title

Without having to write each link as [[Title][Title]]?

1

I don't see an easy way to do this other than by copying the org-html-link function from ox-html.el. :-(

Find the text What description to use?. That's where you want to change the logic:

     ;; What description to use?
     (desc
      ;; Case 1: Headline is numbered and LINK has no
      ;; description.  Display section number.
      (if (and (org-export-numbered-headline-p destination info)
           (not desc))
          (mapconcat #'number-to-string
             (org-export-get-headline-number
              destination info) ".")
        ;; Case 2: Either the headline is un-numbered or
        ;; LINK has a custom description.  Display LINK's
        ;; description or headline's title.
        (or desc
        (org-export-data
         (org-element-property :title destination) info)))))

This is hacky but you can change this to:

     ;; What description to use?
     (desc
      ;; Case 1: Headline is numbered and LINK has no
      ;; description.  Display section number.
      (if (and nil  ; ← **note the change here**
           (org-export-numbered-headline-p destination info)
           (not desc))
          (mapconcat #'number-to-string
             (org-export-get-headline-number
              destination info) ".")
        ;; Case 2: Either the headline is un-numbered or
        ;; LINK has a custom description.  Display LINK's
        ;; description or headline's title.
        (or desc
        (org-export-data
         (org-element-property :title destination) info)))))

and then it will never use case 1 (section number) and always use case 2 (link text).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.