getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.98k stars 964 forks source link

Can't use table of contents when there is an emoji in the title #2181

Closed orhun closed 1 year ago

orhun commented 1 year ago

Bug Report

I'm not sure if this is a theme-related or Zola-related problem. Let me know if I need to submit this to after-dark theme.

My problem is I have the following markdown:

## some title ⚡

some content

I generate the following ToC entry:

- [some title ⚡](#some-title-)

But I can't build the site:

Error: Failed to build the site
Error: Found 1 broken internal anchor link(s)
  1. The anchor in the link `@/test.md#some-title-` in test.md does not exist.

Environment

Zola version: zola 0.17.2

Expected Behavior

Succesful site generation.

Current Behavior

Outlined above.

Step to reproduce

Outlined above.

Raymi306 commented 1 year ago

I was hoping to help fix this bug but I am not sure how to reproduce it.

I used test_site and added 2 headers to content/2018/index.md like so:

+++
title = "index page in a direction with the same name as a section"
+++

# some title ⚡
## some title ⚡

I then copy pasted the ToC templating html from the docs into templates/page.html and ran zola serve and got no errors.

When I go to the page that I edited, everything is rendered correctly, and the links read as #some-title-zap and #some-title-zap-1

orhun commented 1 year ago

Oh, it can be easily reproduced like this:

Contents of content/2018/index.md:

+++
title = "index page in a direction with the same name as a section"
+++

Table of contents:
- [some title ⚡](#some-title-)
  - [some title ⚡](#some-title--1)

# some title ⚡

## some title ⚡

Logs:

Error: Failed to build the site
Error: Found 2 broken internal anchor link(s)
  1. The anchor in the link `@/2018/index.md#some-title-` in /home/orhun/gh/zola/test_site/content/2018/index.md does not exist.
  2. The anchor in the link `@/2018/index.md#some-title--1` in /home/orhun/gh/zola/test_site/content/2018/index.md does not exist.
Raymi306 commented 1 year ago
+++
title = "index page in a direction with the same name as a section"
+++

Table of contents:
- [some title ⚡](#some-title-zap)
  - [some title ⚡](#some-title-zap-1)

# some title ⚡

## some title ⚡

The above works fine for me. I recommend reading the docs that I referenced earlier for a more idiomatic way to handle table of contents.

Raymi306 commented 1 year ago

I think this can be closed?

orhun commented 1 year ago

It still doesn't work for me for zola 0.17.2

orhun commented 1 year ago

I just tried with your example again and it worked. I guess my ToC generator was broken. Closing...