Build package using fpm. As I don't want ruby/gem in my computer, the build system creates an OCI image with Podman (at this time), and generate dist pacakges. To enhance the packages, a manpage is now generated from the documentation.
23 lines
757 B
Python
23 lines
757 B
Python
"""Called by mkdocs to preprocess files and build manpages"""
|
|
|
|
from bs4 import BeautifulSoup, Tag
|
|
|
|
|
|
def to_remove(tag: Tag) -> bool:
|
|
"""Removes images, SVGs, links containing images or SVGs, and permalinks from the BeautifulSoup object."""
|
|
if tag.name in {"img", "svg"}:
|
|
return True
|
|
# remove links containing images or SVGs
|
|
if tag.name == "a" and tag.img and to_remove(tag.img):
|
|
return True
|
|
# remove permalinks
|
|
if tag.name == "a" and "headerlink" in tag.get("class", ()):
|
|
return True
|
|
return False
|
|
|
|
|
|
def preprocess(soup: BeautifulSoup, output: str) -> None:
|
|
"""Preprocess the BeautifulSoup object to remove unwanted elements."""
|
|
for element in soup.find_all(to_remove):
|
|
element.decompose()
|