kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
885 stars 132 forks source link

Headings with links get weird slugs #750

Open justinabrahms opened 1 day ago

justinabrahms commented 1 day ago

Actual Behavior

Source:

* [[id:3834647D-14EC-41E5-BCD6-B6480636DAF8][Accelerate]] capabilities

Generated

## [Accelerate]({{< relref "../../Dropbox/docs/roam/20220122112355-accelerate.md" >}}) capabilities {#accelerate--dot-dot-dot-dot-dropbox-docs-roam-20220122112355-accelerate-dot-md--capabilities}

Expected Behavior

Generated

## [Accelerate]({{< relref "20220122112355-accelerate.md" >}}) capabilities {#accelerate-capabilities}

How to Reproduce the Issue

I believe that this is an interaction specifically with the id: link type from org-roam b/c doing a file: based link works just fine.

Example Org File

* [[id:3834647D-14EC-41E5-BCD6-B6480636DAF8][Accelerate]] capabilities
1. Use version control for prod artifacts
* [[file:bin/python][Another]]

Generated Markdown File or Error

---
author: ["Justin Abrahms"]
lastmod: 2024-12-02T20:59:33-08:00
draft: false
---

## [Accelerate]({{< relref "../Users/justinabrahms/Dropbox/docs/roam/20220122112355-accelerate.md" >}}) capabilities {#accelerate--dot-dot-users-justinabrahms-dropbox-docs-roam-20220122112355-accelerate-dot-md--capabilities}

1.  Use version control for prod artifacts

## [Another](/usr/bin/python3) {#another}

Ox-Hugo Debug Information

Debug Info # Debug information for `ox-hugo` ## Emacs Version GNU Emacs 29.4 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-08-02 ## Org Version Org mode version 9.8-pre (release_9.7.10-127-g07dd3b @ /Users/justinabrahms/.emacs.d/straight/build/org/) ## Hugo Version =hugo= binary not found in PATH ### Org `load-path` shadows **Warning**: Possible mixed installation of Org /Users/justinabrahms/.emacs.d/straight/build/org/ob-exp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-exp /Users/justinabrahms/.emacs.d/straight/build/org/ob-emacs-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp /Users/justinabrahms/.emacs.d/straight/build/org/oc hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc /Users/justinabrahms/.emacs.d/straight/build/org/ob-css hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-css /Users/justinabrahms/.emacs.d/straight/build/org/ob-lob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lob /Users/justinabrahms/.emacs.d/straight/build/org/ol-irc hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-irc /Users/justinabrahms/.emacs.d/straight/build/org/ob-forth hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-forth /Users/justinabrahms/.emacs.d/straight/build/org/org-macs hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-macs /Users/justinabrahms/.emacs.d/straight/build/org/ob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob /Users/justinabrahms/.emacs.d/straight/build/org/org-version hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-version /Users/justinabrahms/.emacs.d/straight/build/org/ob-scheme hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-scheme /Users/justinabrahms/.emacs.d/straight/build/org/ox hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox /Users/justinabrahms/.emacs.d/straight/build/org/ob-C hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-C /Users/justinabrahms/.emacs.d/straight/build/org/org-capture hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-capture /Users/justinabrahms/.emacs.d/straight/build/org/ob-ref hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ref /Users/justinabrahms/.emacs.d/straight/build/org/ob-clojure hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-clojure /Users/justinabrahms/.emacs.d/straight/build/org/org-mouse hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mouse /Users/justinabrahms/.emacs.d/straight/build/org/org-persist hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-persist /Users/justinabrahms/.emacs.d/straight/build/org/org-ctags hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-ctags /Users/justinabrahms/.emacs.d/straight/build/org/org-entities hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-entities /Users/justinabrahms/.emacs.d/straight/build/org/org-archive hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-archive /Users/justinabrahms/.emacs.d/straight/build/org/ob-screen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-screen /Users/justinabrahms/.emacs.d/straight/build/org/ol-bibtex hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-bibtex /Users/justinabrahms/.emacs.d/straight/build/org/ob-haskell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-haskell /Users/justinabrahms/.emacs.d/straight/build/org/org-loaddefs hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-loaddefs /Users/justinabrahms/.emacs.d/straight/build/org/org-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-table /Users/justinabrahms/.emacs.d/straight/build/org/ol-eww hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-eww /Users/justinabrahms/.emacs.d/straight/build/org/ol-man hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-man /Users/justinabrahms/.emacs.d/straight/build/org/ox-org hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-org /Users/justinabrahms/.emacs.d/straight/build/org/org-num hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-num /Users/justinabrahms/.emacs.d/straight/build/org/org-plot hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-plot /Users/justinabrahms/.emacs.d/straight/build/org/ol-rmail hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-rmail /Users/justinabrahms/.emacs.d/straight/build/org/ob-awk hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-awk /Users/justinabrahms/.emacs.d/straight/build/org/ob-groovy hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-groovy /Users/justinabrahms/.emacs.d/straight/build/org/ob-octave hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-octave /Users/justinabrahms/.emacs.d/straight/build/org/org-faces hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-faces /Users/justinabrahms/.emacs.d/straight/build/org/oc-biblatex hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc-biblatex /Users/justinabrahms/.emacs.d/straight/build/org/org-colview hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-colview /Users/justinabrahms/.emacs.d/straight/build/org/ob-R hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-R /Users/justinabrahms/.emacs.d/straight/build/org/org-refile hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-refile /Users/justinabrahms/.emacs.d/straight/build/org/org-timer hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-timer /Users/justinabrahms/.emacs.d/straight/build/org/org-mobile hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mobile /Users/justinabrahms/.emacs.d/straight/build/org/ob-fortran hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-fortran /Users/justinabrahms/.emacs.d/straight/build/org/ob-shell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-shell /Users/justinabrahms/.emacs.d/straight/build/org/ob-perl hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-perl /Users/justinabrahms/.emacs.d/straight/build/org/ob-sqlite hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sqlite /Users/justinabrahms/.emacs.d/straight/build/org/oc-basic hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc-basic /Users/justinabrahms/.emacs.d/straight/build/org/ob-sed hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sed /Users/justinabrahms/.emacs.d/straight/build/org/org-list hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-list /Users/justinabrahms/.emacs.d/straight/build/org/ob-ruby hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ruby /Users/justinabrahms/.emacs.d/straight/build/org/ob-eval hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-eval /Users/justinabrahms/.emacs.d/straight/build/org/org-habit hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-habit /Users/justinabrahms/.emacs.d/straight/build/org/org-clock hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-clock /Users/justinabrahms/.emacs.d/straight/build/org/org-goto hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-goto /Users/justinabrahms/.emacs.d/straight/build/org/ox-html hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-html /Users/justinabrahms/.emacs.d/straight/build/org/org-src hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-src /Users/justinabrahms/.emacs.d/straight/build/org/ob-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lisp /Users/justinabrahms/.emacs.d/straight/build/org/ol-eshell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-eshell /Users/justinabrahms/.emacs.d/straight/build/org/ob-ditaa hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ditaa /Users/justinabrahms/.emacs.d/straight/build/org/org-pcomplete hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-pcomplete /Users/justinabrahms/.emacs.d/straight/build/org/org-lint hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-lint /Users/justinabrahms/.emacs.d/straight/build/org/ox-latex hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-latex /Users/justinabrahms/.emacs.d/straight/build/org/ob-sass hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sass /Users/justinabrahms/.emacs.d/straight/build/org/ob-tangle hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-tangle /Users/justinabrahms/.emacs.d/straight/build/org/ob-calc hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-calc /Users/justinabrahms/.emacs.d/straight/build/org/ob-java hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-java /Users/justinabrahms/.emacs.d/straight/build/org/ox-icalendar hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-icalendar /Users/justinabrahms/.emacs.d/straight/build/org/ol-mhe hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-mhe /Users/justinabrahms/.emacs.d/straight/build/org/org-attach-git hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-attach-git /Users/justinabrahms/.emacs.d/straight/build/org/ox-md hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-md /Users/justinabrahms/.emacs.d/straight/build/org/ox-beamer hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-beamer /Users/justinabrahms/.emacs.d/straight/build/org/org-element hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-element /Users/justinabrahms/.emacs.d/straight/build/org/oc-natbib hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc-natbib /Users/justinabrahms/.emacs.d/straight/build/org/org-protocol hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-protocol /Users/justinabrahms/.emacs.d/straight/build/org/ob-gnuplot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot /Users/justinabrahms/.emacs.d/straight/build/org/org-tempo hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-tempo /Users/justinabrahms/.emacs.d/straight/build/org/ob-latex hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-latex /Users/justinabrahms/.emacs.d/straight/build/org/ol-w3m hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-w3m /Users/justinabrahms/.emacs.d/straight/build/org/org-id hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-id /Users/justinabrahms/.emacs.d/straight/build/org/ox-man hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-man /Users/justinabrahms/.emacs.d/straight/build/org/ol-doi hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-doi /Users/justinabrahms/.emacs.d/straight/build/org/org-feed hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-feed /Users/justinabrahms/.emacs.d/straight/build/org/org-fold-core hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-fold-core /Users/justinabrahms/.emacs.d/straight/build/org/ob-julia hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-julia /Users/justinabrahms/.emacs.d/straight/build/org/ob-lua hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lua /Users/justinabrahms/.emacs.d/straight/build/org/ob-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-table /Users/justinabrahms/.emacs.d/straight/build/org/ob-ocaml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ocaml /Users/justinabrahms/.emacs.d/straight/build/org/oc-csl hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc-csl /Users/justinabrahms/.emacs.d/straight/build/org/ol-gnus hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-gnus /Users/justinabrahms/.emacs.d/straight/build/org/org-indent hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-indent /Users/justinabrahms/.emacs.d/straight/build/org/ob-lilypond hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lilypond /Users/justinabrahms/.emacs.d/straight/build/org/ob-matlab hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-matlab /Users/justinabrahms/.emacs.d/straight/build/org/org-datetree hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-datetree /Users/justinabrahms/.emacs.d/straight/build/org/ol-docview hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-docview /Users/justinabrahms/.emacs.d/straight/build/org/oc-bibtex hides /Applications/Emacs.app/Contents/Resources/lisp/org/oc-bibtex /Users/justinabrahms/.emacs.d/straight/build/org/ob-python hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-python /Users/justinabrahms/.emacs.d/straight/build/org/ob-makefile hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-makefile /Users/justinabrahms/.emacs.d/straight/build/org/org-duration hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-duration /Users/justinabrahms/.emacs.d/straight/build/org/org-agenda hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-agenda /Users/justinabrahms/.emacs.d/straight/build/org/ob-dot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-dot /Users/justinabrahms/.emacs.d/straight/build/org/ob-js hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-js /Users/justinabrahms/.emacs.d/straight/build/org/ox-publish hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-publish /Users/justinabrahms/.emacs.d/straight/build/org/org-inlinetask hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-inlinetask /Users/justinabrahms/.emacs.d/straight/build/org/ob-org hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-org /Users/justinabrahms/.emacs.d/straight/build/org/org-keys hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-keys /Users/justinabrahms/.emacs.d/straight/build/org/ob-core hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-core /Users/justinabrahms/.emacs.d/straight/build/org/org-compat hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-compat /Users/justinabrahms/.emacs.d/straight/build/org/ol hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol /Users/justinabrahms/.emacs.d/straight/build/org/ox-odt hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-odt /Users/justinabrahms/.emacs.d/straight/build/org/ol-info hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-info /Users/justinabrahms/.emacs.d/straight/build/org/ob-plantuml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-plantuml /Users/justinabrahms/.emacs.d/straight/build/org/ob-eshell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-eshell /Users/justinabrahms/.emacs.d/straight/build/org/ox-ascii hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-ascii /Users/justinabrahms/.emacs.d/straight/build/org/ox-koma-letter hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-koma-letter /Users/justinabrahms/.emacs.d/straight/build/org/ob-maxima hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-maxima /Users/justinabrahms/.emacs.d/straight/build/org/org hides /Applications/Emacs.app/Contents/Resources/lisp/org/org /Users/justinabrahms/.emacs.d/straight/build/org/ol-bbdb hides /Applications/Emacs.app/Contents/Resources/lisp/org/ol-bbdb /Users/justinabrahms/.emacs.d/straight/build/org/org-macro hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-macro /Users/justinabrahms/.emacs.d/straight/build/org/org-fold hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-fold /Users/justinabrahms/.emacs.d/straight/build/org/ob-sql hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sql /Users/justinabrahms/.emacs.d/straight/build/org/org-attach hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-attach /Users/justinabrahms/.emacs.d/straight/build/org/org-cycle hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-cycle /Users/justinabrahms/.emacs.d/straight/build/org/ob-processing hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-processing /Users/justinabrahms/.emacs.d/straight/build/org/ox-texinfo hides /Applications/Emacs.app/Contents/Resources/lisp/org/ox-texinfo /Users/justinabrahms/.emacs.d/straight/build/org/org-crypt hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-crypt /Users/justinabrahms/.emacs.d/straight/build/org/org-footnote hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-footnote /Users/justinabrahms/.emacs.d/straight/build/org/ob-comint hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-comint Study the output of `M-x list-load-path-shadows`. ## `ox-hugo` defcustoms
org-hugo-section "posts"
org-hugo-use-code-for-kbd nil
org-hugo-preserve-filling t
org-hugo-delete-trailing-ws t
org-hugo-prefer-hyphen-in-tags t
org-hugo-allow-spaces-in-tags t
org-hugo-tag-processing-functions (org-hugo–tag-processing-fn-replace-with-spaces-maybe org-hugo–tag-processing-fn-replace-with-hyphens-maybe)
org-hugo-auto-set-lastmod t
org-hugo-export-with-toc nil
org-hugo-export-with-section-numbers nil
org-hugo-front-matter-format "yaml"
org-hugo-default-static-subdirectory-for-externals "ox-hugo"
org-hugo-external-file-extensions-allowed-for-copying ("jpg" "jpeg" "tiff" "png" "svg" "gif" "bmp" "mp4" "pdf" "odt" "doc" "ppt" "xls" "docx" "pptx" "xlsx")
org-hugo-date-format "%Y-%m-%dT%T%z"
org-hugo-paired-shortcodes ""
org-hugo-suppress-lastmod-period 0.0
org-hugo-front-matter-format "yaml"
justinabrahms commented 1 day ago

To fix this temporarily, I'm just pre-processing the title to strip the link parts.

(defun org-hugo-get-heading-slug (element info)
  "Return the slug string derived from an Org heading ELEMENT."
  (let* ((title (org-export-data-with-backend
                 (org-element-property :title element) 'md info))
         ;; Strip markdown links, keeping just the link text
         (plain-title (replace-regexp-in-string "\\[\\([^]]+\\)\\]([^)]+)" "\\1" title)))
    (org-string-nw-p (org-hugo-slug plain-title :allow-double-hyphens))))