Remove marked sections from pages
Project description
mkdocs-remove-sections-plugin
Remove marked sections from pages. For example to remove private information from a public version of a web site.
Installation
You can install it with pip:
pip install mkdocs-remove-sections-plugin
Usage
Add the plugin to your mkdocs.yml:
plugins:
- search
- remove_sections
To remove a section and its subsections, you can begin its title with Private: like ## Private: My section.
If you need a more precise removal, you can also manually set start and end points for the removal.
Any content on pages between <!-- remove:start --> and <!-- remove:end --> is replaced by the plugin with the text Some content has been redacted in this version.
If there are uncertanities (start and end tags do not propperly match up), then this plugin will default to cutting too much rather than too little.
In addition a warning is shown during the build.
Configuration
You can configure the plugin with the following options. The information shown below shows the default values:
plugins:
- search
- remove_sections:
section_start_pattern: "<!--\\s*remove:start\\s*-->"
section_end_pattern: "<!--\\s*remove:end\\s*-->"
section_heading_pattern: "^Private: "
section_replace_with: "\n\n> Some content has been redacted in this version.\n\n"
regex_case_sensitive: false
section_start_pattern
Regular expression pattern that marks the start of a section that should be removed.
section_end_pattern
Regular expression pattern that marks the end of a section that should be removed.
section_heading_pattern
Regular expression for a section heading (h1 through h6) that marks a section to be removed.
Any subsections are removed as well.
You can use it like this:
## Private: Section to remove
section_replace_with
The removed content will be replaced with this text. You can set an empty string to remove it entirely. By default a placeholder is shown, so that you see that something was removed.
regex_case_sensitive
This controls, whether the patterns you defined with the other options should be case sensitive or insensitive. It defaults to case insensitive.
Notable changes
Version 0.1.0
- Added removing sections by title
Version 0.0.1
- Initial version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_remove_sections_plugin-0.1.0.tar.gz.
File metadata
- Download URL: mkdocs_remove_sections_plugin-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f30c1aaeb9be406e4ab04b29bfa79c0bff0d1eb547071e3fa181f72dc9b2348
|
|
| MD5 |
db3c90b8303a866ae70231260524a4a5
|
|
| BLAKE2b-256 |
21079df297a013b4c263c143425be9ff06b2f78346ccedffda8141187d10429a
|
File details
Details for the file mkdocs_remove_sections_plugin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_remove_sections_plugin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d12176be26dfc4c6e87827ae5a4eca14c7e2b758f9b64c3bd6fb90c68026d91
|
|
| MD5 |
a863320d56a59771993fcf5f2cf501c8
|
|
| BLAKE2b-256 |
31ff31d9c2e6ebc6b8f237d5babbc1c45134071b634ee0c8e9219697ab68071a
|