#3151 Table of Contents do not work
Closed: Fixed 5 years ago Opened 6 years ago by jflorian.

I love how Pagure can be used to create easy-to-use documentation with simple markdown or reStructureText files littered throughout a repository. I just did some playing (in a markdown file) and found that I could place a [TOC] marker in such a document to have a Table of Contents inserted automatically. Unfortunately, these are not usable links -- the hrefs look good, but the anchors they target don't exist.

Using pagure-3.13.1.


Would you have a link to the documentation you found about [TOC] and how it's rendering?

I have no idea how relevant this[0] is as I had simply Googled for pagure table of contents and also markdown table of contents but it was so easy to try, I didn't bother with any formal check to see what Pagure used for rendering beyond already knowing that Pagure is written in Python.

[0] https://python-markdown.github.io/extensions/toc/

As for my example, here's the headings from a file:

$ grep '^#' GIT-BRANCHES.md
# confd - Git branching policy (version: DOC-1.0.0)
## Rationale
## Scope
## Typography
## Branch naming policy
### Production branches
### Development branches
#### Primary integration branch
#### Topic integration branches
#### Author branches
#### Author topic branches
## Branch life cycle policy
### Production branches
### Development branches
#### Primary integration branch
#### Topic integration branches
#### Author branches
#### Author topic branches

Here is a source fragment of the rendering:

<div class="toc">
<ul>
<li><a href="#confd-git-branching-policy-version-doc-100">confd - Git branching policy (version: DOC-1.0.0)</a><ul>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#scope">Scope</a></li>
<li><a href="#typography">Typography</a></li>
<li><a href="#branch-naming-policy">Branch naming policy</a><ul>
<li><a href="#production-branches">Production branches</a></li>
<li><a href="#development-branches">Development branches</a><ul>
<li><a href="#primary-integration-branch">Primary integration branch</a></li>
<li><a href="#topic-integration-branches">Topic integration branches</a></li>
<li><a href="#author-branches">Author branches</a></li>
<li><a href="#author-topic-branches">Author topic branches</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#branch-life-cycle-policy">Branch life cycle policy</a><ul>
<li><a href="#production-branches_1">Production branches</a></li>
<li><a href="#development-branches_1">Development branches</a><ul>
<li><a href="#primary-integration-branch_1">Primary integration branch</a></li>
<li><a href="#topic-integration-branches_1">Topic integration branches</a></li>
<li><a href="#author-branches_1">Author branches</a></li>
<li><a href="#author-topic-branches_1">Author topic branches</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

Lastly, here is what my browser shows:
Screenshot_20180411_153901.png

Turns out, this is simply because we currently only enable that extensions on README files:
https://pagure.io/pagure/blob/master/f/pagure/lib/__init__.py#_3749-3753

Metadata Update from @pingou:
- Issue tagged with: RFE, easyfix

6 years ago

That explains the behavior. Do you have any explanation for the intent? Why the conditional behavior? (I'm not questioning the wisdom; I just don't understand.)

I think I just originally didn't think this would be useful outside README files. I am ok with changing this :)

Ok that seems easy enough. Should any of the plugins remain conditional? I'm thinking only nl2br should be an exception, if any. Consistency is simpler code and UX, but "devil in the details..." and all that.

Metadata Update from @pingou:
- Issue assigned to pingou

5 years ago

Login to comment on this ticket.

Metadata
Attachments 1
Related Pull Requests
  • #3354 Merged 5 years ago