Create permalinks in title using python label library

I was wondering how to create permalinks from the following markup using the python label library:

A header ======== A paragraph 

The desired result will be similar to

 <span id="a-header"></span> <h1> A header <a class="headerlink" title="Permalink to this headline" href="#a-header"></a> </h1> <p>A paragraph</p> 

Answer:

Thanks @BlaXpirit ( see answer )

Use the headerid python markdown extension and enter the following:

 # A header [¶](#a-header) {#a-header} A paragraph 

This generates the following output:

 <h1 id="a-header"> A header <a href="#a-header"></a> </h1> 

Then use some css style to get the general output, for example:

 h1 a{visibility:hidden;} h1:hover a{visibility:visible;} 
+6
source share
2 answers

Markdown in Python has an extension that does this.
It also allows you to specify the identifier that you like for the title, for example:

  A header {# a-header}
 ========
+1
source

Pandoc associates a unique identifier with each heading based on the rule that you imagine: id is the heading in lower case, and spaces are replaced by hyphens. It is used to create additional content tables for HTML and LaTeX and other output formats. In HTML, it automatically creates binding identifiers and, in particular, can be used for internal cross-references; markdown syntax:

  See the section on [header identifiers](#header-identifiers-in-html). 

as we read in the user guide http://johnmacfarlane.net/pandoc/README.html#header-identifiers-in-html

0
source

Source: https://habr.com/ru/post/885731/


All Articles