Gitea doesn’t create proper anchor links for headings specified as <hX> in the source #489

Open
opened 4 months ago by deterenkelt · 2 comments

Normally a header within article is converted to an <hX> HTML tag containing an <a>. The href attribute would contain the header title shaped to be conformant as an URL string. Like this:

## Second-level heading

<h2 id="user-content-second-level-heading">          ← id attribute is present
    <a href="#second-level-heading">                 ← anchor is in place
        Second-level heading
    </a>
</h2>

However, if we’d use HTML markup in the source file, e.g. to put the heading at the centre, the href attribute will contain only the hash sign, #.

<h2 align="center">
   Second-level heading
</h2>

<h2 align="center">                                  ← id attribute is missing!
    <a href="#">                                     ← anchor is empty!
        Second-level heading
    </a>
</h2>

It breaks cross-references between articles, making them much less useful, and breaks compatibility with at least Github, where it works.

The issue template asked to mention, whether I have a Github account, and I actually don’t have one since this year.

Normally a header within article is converted to an `<hX>` HTML tag containing an `<a>`. The `href` attribute would contain the header title shaped to be conformant as an URL string. Like this: `## Second-level heading` ↓ ``` <h2 id="user-content-second-level-heading"> ← id attribute is present <a href="#second-level-heading"> ← anchor is in place Second-level heading </a> </h2> ``` However, if we’d use HTML markup in the source file, e.g. to put the heading at the centre, the href attribute will contain only the hash sign, `#`. ``` <h2 align="center"> Second-level heading </h2> ``` ↓ ``` <h2 align="center"> ← id attribute is missing! <a href="#"> ← anchor is empty! Second-level heading </a> </h2> ``` It breaks cross-references between articles, making them much less useful, and breaks compatibility with at least Github, where it works. The issue template asked to mention, whether I have a Github account, and I actually don’t have one since this year.
6543 added the
gitea-related
label 4 months ago
Collaborator

I'm not sure at what point this is a feature/enhancement-request or a bug ...

Need to dig into it a bit
ps: @deterenkelt you mentiond a repo do you have a link for me?

I'm not sure at what point this is a feature/enhancement-request or a bug ... Need to dig into it a bit ps: @deterenkelt you mentiond a repo do you have a link for me?
Poster

I’m currently trying to migrate two repositories, one with code and one with the wiki. On the latter you can see the bug in action on basically any page there.

Take for example one of the pages with tips: there’s a table of contents at the top, and the links aren’t working, because the headings have an empty href (sans the hash sign).

I’m currently trying to migrate two repositories, one with code and [one with the wiki](https://codeberg.org/deterenkelt/Nadeshiko/wiki). On the latter you can see the bug in action on basically any page there. Take for example [one of the pages with tips](https://codeberg.org/deterenkelt/Nadeshiko/wiki/Tips-for-Nadeshiko): there’s a table of contents at the top, and the links aren’t working, because the headings have an empty `href` (sans the hash sign).
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.