Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: can't resolve link in TOC when exporting to html #35

Closed
deb0ch opened this issue Jan 14, 2017 · 4 comments
Closed

Bug: can't resolve link in TOC when exporting to html #35

deb0ch opened this issue Jan 14, 2017 · 4 comments

Comments

@deb0ch
Copy link

deb0ch commented Jan 14, 2017

I've been experiencing a bug lately when having a table of contents declared as :TOC: and then trying to export to html. The error is Unable to resolve link: <name-of-your-first-heading>.

Here is a minimal example:

* toc :TOC:
 - [[#foo][foo]]
 - [[#bar][bar]]
 - [[#baz][baz]]

* foo
Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat non orci
commodo lobortis. Proin neque massa, cursus ut, gravida ut, lobortis eget,
lacus. Sed diam. Praesent fermentum tempor tellus.

* bar
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis
facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta
vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum.

* baz
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis
facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta
vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum.

then when trying export to html (M-x org-export-dispatch RET h o for instance), you get the error user-error: Unable to resolve link: "foo" in *Messages* and just Unable to resolve link: "foo" in the echo area.

A simple workaround is to declare the toc as :TOC:noexport:. This way you don't get the error and the toc is still exported, it just doesn't make sense given what :noexport: is supposed to do 😕

@snosov1
Copy link
Owner

snosov1 commented Jan 25, 2017

Hey, @deb0ch !

Thx for the report.

First, please, let me put your mind into the right place with respect to :noexport: tag. Probably, the thing is - after you add :noexport: the toc is being generated by the org-html export. So, it's not a bug and it's not related to this package =) Simple way to test it is to add #+OPTIONS: toc:nil to the top of your file.

Next, to the bug with Unable to resolve link. I can also reproduce this, but it doesn't seem like a bug to me. Obviously, you use the "github-style" href format for links but then export to html (that uses a different href format) which causes issues.

There are several options to handle this:

  • If you don't want a TOC in exported HTML at all, then use :noexport: tag and #+OPTIONS: toc:nil
  • If you want a TOC in the exported HTML you can utilize the org export engine (use :noexport: tag, but no #+OPTIONS: toc:nil)
  • If you want a TOC in the exported HTML, but want to rely on toc-org to generate it, then use #+OPTIONS: toc:nil and provide a different "hrefify" function to toc-org (instead of github-style one). In the simplest cases, the org hrefify function should work. To enable it, simply use :TOC_2_org: instead of :TOC:

Does it make any sense?

@snosov1
Copy link
Owner

snosov1 commented Mar 24, 2017

Closing as "Not a bug".

@MatthewZMD
Copy link

To enable it, simply use :TOC_2_org:

I tried this, most things worked out nicely. However the generated table of contents has the :TOC_2_org: in it, which doesn't look very good.

@snosov1
Copy link
Owner

snosov1 commented Mar 18, 2019

@MatthewZMD True. Unfortunately, I'm not sure what's the cleanest way to get around it.

You can kinda make it better by adding smth like #+HTML_HEAD_EXTRA: <style> .TOC_2_org { display: none; } </style>. Though it still leaves the tag span and adds clutter to the source file.

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

No branches or pull requests

3 participants