-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.4.0a2: demote_headers filter (w/ example template changes)
- Loading branch information
Showing
6 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
################################################################################ | ||
## Demote Headers filter ## | ||
## Author: Rome Reginelli ## | ||
## Copyright: Ripple Labs, Inc. 2017 ## | ||
## ## | ||
## Demote all headers one level. This can be useful to make PDF docs render ## | ||
## a nice link hierarchy if your templates provide category headers at h1 but ## | ||
## your docs individually start at the h1 level. ## | ||
################################################################################ | ||
|
||
DEMOTE_FIELD = "demote_headers_pdf_only" | ||
|
||
def filter_html(html, mode="html", target={}, **kwargs): | ||
if (mode == "html" and | ||
DEMOTE_FIELD in target and | ||
target[DEMOTE_FIELD]): | ||
# Don't bother then | ||
return html | ||
|
||
html = html.replace("<h5", "<h6") | ||
html = html.replace("<h4", "<h5") | ||
html = html.replace("<h3", "<h4") | ||
html = html.replace("<h2", "<h3") | ||
html = html.replace("<h1", "<h2") | ||
return html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.4.0a1' | ||
__version__ = '0.4.0a2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters