ignorantshr / mkdocs-add-number-plugin Goto Github PK
View Code? Open in Web Editor NEWMkDocs plugin to automatically number the headings (h1-h6) in each markdown page and the nav.
License: MIT License
MkDocs plugin to automatically number the headings (h1-h6) in each markdown page and the nav.
License: MIT License
I tried setting:
- mkdocs-add-number-plugin:
excludes:
- TMD/
But all the files is the folder still have the heading numbers added.
Did this functionality work for you?
I could submit another PR to fix it (after first finishing #4)
Hi @ignorantshr, thanks for the plugin! I was actually thinking of building the exact same thing, but found yours!
I'd like to add numbering not only to the table of contents, but also to the headings in the page itself. Like so:
Could this be added? I'm also prepared to provide a PR if you want.
When within one page you have multiple headers, you need to account for that in the sequential pages.
# Header 1 page 1
# Second Heading 1 page 2
# Header 1 page 2
Will render as
# 1. Header 1 page 1
# 2. Second Heading 1 page 2
# 2. Header 1 page 2
But "2. Header 1 page 2" Should be "3. Header 1 page 2"
I have not implemented that logic yet..
Shall we update to
MkDocs plugin to automatically number the headings (h1-h6) in each markdown page.
?
I noticed you wrote
The following is an English description that using Google Translate
If you want I can help write a nice README.md
in English?
Hi @ignorantshr ,
So I found some time to continue work on this. I ended up rewriting the entire plugin to fit my own needs and making some different choices like:
strict
include
and exclude
increment_pages
(always use this)order
<span>
elements around numbers for CSS stylingI would also like to publish my plugin and call mkdocs-enumerate-headings-plugin
(I think the name better reflects the functionality). I wanted to check first if you would be OK with that?
Hi @ignorantshr,
My team uses MkDocs
to both publish a site and export a report as PDF (using mkdocs-pdf-export-plugin).
I would like to have the numbering increment for each main page. That way, you can refer to specific sections in the PDF report.
Happy to work on a PR if you're interested in adding this feature?
MkDocs plugin have the naming convention mkdocs-<name>-plugin
but for entrypoint, leave out the "mkdocs-" and "-plugin".
We can add another entrypoint to setup.py
, e.g. from:
entry_points={
'mkdocs.plugins': [
'mkdocs-add-number-plugin=mkdocs_add_number_plugin.plugin:AddIndexPlugin'
]
}
to:
entry_points={
'mkdocs.plugins': [
'mkdocs-add-number-plugin=mkdocs_add_number_plugin.plugin:AddIndexPlugin',
'add-number=mkdocs_add_number_plugin.plugin:AddIndexPlugin'
]
}
And then update the README.md
appriopriately.
Hi, i need the configuration option "increment_topnav", but still get an error.
mkdocs.yml:
site_name: GitLab MkDocs Example
plugins:
- add-number:
increment_topnav: True
error:
~\AppData\Roaming\Python\Python39\site-packages\mkdocs_add_number_plugin\plugin.py", line 51, in on_nav nav.items[index].title = str(index + 1) + '. ' + \ TypeError: can only concatenate str (not "NoneType") to str
When we write markdown file, someone want to use link to a heading like:
refer to [section a](#section-a)
## section a
foo bar
This plugin will update the heading and add number, but it will not update the link to the heading.
Therefore, the link will be a dead link.
(In above example, ## section a
will be ## 1. section a
, but the link to this heading [section a](#section-a)
will not be updated.)
Is it possible to update the link automatically?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.