-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Now supporting relative links in PDF documents - Improved logging of browser-related errors - Introduced error handling when invoking the `MkDocsExporter.render` function in the browser - Updated documentation plugins - Improved documentation
- Loading branch information
1 parent
741aa1d
commit 5100c61
Showing
12 changed files
with
143 additions
and
43 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,10 @@ | ||
import mkdocs_exporter | ||
import importlib.metadata | ||
|
||
|
||
def define_env(env): | ||
""" | ||
A hook for the MkDocs Macros plugin. | ||
""" | ||
|
||
env.variables['version'] = importlib.metadata.version(mkdocs_exporter.__name__) |
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
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 @@ | ||
from __future__ import annotations | ||
|
||
from urllib.parse import urlparse, urljoin | ||
from mkdocs_exporter.preprocessor import Preprocessor as BasePreprocessor | ||
|
||
|
||
class Preprocessor(BasePreprocessor): | ||
"""The HTML preprocessor for PDF documents.""" | ||
|
||
|
||
def rewrite_links(self, base: str, root: str) -> None: | ||
"""Rewrite links based on the documentation's URL.""" | ||
|
||
for element in self.html.find_all('a', href=True): | ||
url = urlparse(element['href']) | ||
|
||
if bool(url.netloc): | ||
continue | ||
if not url.path: | ||
continue | ||
|
||
final = urlparse(root) | ||
path = urljoin(base, url.path) | ||
|
||
element['href'] = url._replace(netloc=final.netloc, scheme=final.scheme, path=path).geturl() |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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