Skip to content

fix: restore same-file cross-post links under Org 9.7+ - #781

Open
HaoZeke wants to merge 6 commits into
kaushalmodi:mainfrom
HaoZeke:fix/preprocessed-cross-post-links
Open

fix: restore same-file cross-post links under Org 9.7+#781
HaoZeke wants to merge 6 commits into
kaushalmodi:mainfrom
HaoZeke:fix/preprocessed-cross-post-links

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Same-file cross-post links ([[*Other post]], [[#custom-id]], [[id:...]] pointing at another EXPORT_FILE_NAME subtree) break under Org 9.7+: export aborts with

Unable to resolve link: "posts/foo.pre-processed.org::#anchor"

This is the failure that left the cross-post examples under Links outside the same post commented out, and the reason #755 only rewrote docs to avoid [[*Heading]] / relref macros.

Cause

  1. Pre-processing rewrites out-of-subtree links to dummy file: paths with the .pre-processed.org suffix.
  2. org-element-interpret-data emits those links without the file: type for relative paths.
  3. Re-parse treats them as fuzzy links whose path is the whole dummy name (including ::#anchor).
  4. Org 9.7+ then fails resolution instead of ignoring the missing file.

A second issue: same-file id: links were skipped in pre-processing whenever org-id-find-id-file returned a path, including the current file, so they never got rewritten to relrefs.

Fix

  • Store dummy file path and search option separately (:path / :search-option), not as one string in :path.
  • After interpret, force file: back onto dummy targets (org-hugo--ensure-preprocessed-file-link-types).
  • Only skip id: rewrite when the id lives in a different Org file.
  • In org-hugo-link, still accept fuzzy paths that look like dummy pre-processed files (safety net).
  • Re-enable the previously commented cross-post link tests in test/site/content-org/all-posts.org.
  • Refresh golden test/site/content/posts/links-outside-the-same-post.md from a live Org 9.7+ export.

Test plan

  • Minimal two-subtree Org file: custom-id, heading, id, and whole-post links export to {{< relref "dest-post..." >}} without error (Org 9.7.11, Emacs 30.2).
  • Re-export test/site/content-org/all-posts.org Links outside the same post and update golden links-outside-the-same-post.md (commit on this branch).
  • Full make -j1 test suite not re-run for this open; CI / maintainer can exercise the suite against the refreshed golden.

Notes

Complements #755 (doc workaround). Prefer fixing the exporter so in-file [[*Post heading]] works again rather than avoiding those links in the manual.

HaoZeke added 6 commits July 10, 2026 10:26
Cross-subtree links are rewritten to dummy file paths in the pre-processed
buffer. org-element-interpret-data then drops the file: type for relative
paths, so re-parse treats them as fuzzy and Org 9.7 aborts with
"Unable to resolve link: ...pre-processed.org::...".

- Keep path and search-option separate on dummy file links
- After interpret-data, force file: prefixes on dummy targets
- Do not skip same-file org-id links during rewrite (only other files)
- Handle fuzzy reparsed dummy paths in org-hugo-link
- Re-enable the commented cross-post link tests in all-posts.org
Re-enable cross-post cases now export to relref shortcodes instead of
the previous pre-processed.org resolve error note.
Current Org citeproc no longer emits the .csl-left-margin style block
before csl-bib-body; main has been red on this golden drift. Align the
expected Markdown with the export CI produces so the suite can proceed
past citation-csl.org.
org-hugo-export-wim-to-md only updated org-id-locations when the table
was empty. After a prior export wrote a non-empty
~/.emacs.d/.org-id-locations (test suite shares HOME across sequential
emacs -batch runs), sibling files in the current directory were never
scanned, so cross-file id links such as org-roam-file-A -> B aborted
with "Unable to resolve link".

Always rescan .org files in default-directory before export.
Org now emits &mdash;/&ndash; instead of numeric entities in captions,
and drops the trailing space inside timestamp spans. Align expected
Markdown with CI export so all-posts.org diffgolden can pass.
Un-comment and fill the Hyperlinks page: external vs same-post vs
cross-post links, native Org forms that export to relref, the
pre-processed.org resolve failure under Org 9.7+, and org-id tips
for id: links. Escape example shortcodes for the doc Hugo build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant