Fix included Python-Markdown; Fix replacements with escape char

This commit is contained in:
2022-08-26 19:53:47 +02:00
parent 36db6c04ae
commit 9cf3bc3e27
6 changed files with 19 additions and 25 deletions

View File

@ -177,10 +177,6 @@ def Main(Args, FeedEntries):
FullSite=FeedType, FullSite=FeedType,
Minify=Minify) Minify=Minify)
if SitemapOut:
print("[I] Generating Sitemap")
MakeSitemap(OutputDir, Pages, SiteDomain)
if ActivityPub and MastodonURL and MastodonToken and SiteDomain: if ActivityPub and MastodonURL and MastodonToken and SiteDomain:
print("[I] Mastodon Stuff") print("[I] Mastodon Stuff")
MastodonPosts = MastodonShare( MastodonPosts = MastodonShare(
@ -217,6 +213,10 @@ def Main(Args, FeedEntries):
print("[I] Cleaning Temporary Files") print("[I] Cleaning Temporary Files")
DelTmp(OutputDir) DelTmp(OutputDir)
if SitemapOut:
print("[I] Generating Sitemap")
MakeSitemap(OutputDir, Pages, SiteDomain)
print("[I] Copying Assets") print("[I] Copying Assets")
os.system(f"cp -R Assets/* {OutputDir}/") os.system(f"cp -R Assets/* {OutputDir}/")

View File

@ -133,21 +133,15 @@ class Markdown:
""" """
Build extension from a string name, then return an instance. Build extension from a string name, then return an instance.
First attempt to load an entry point. The string name must be registered as an entry point in the Don't attempt to load any entrypoint,
`markdown.extensions` group which points to a subclass of the `markdown.extensions.Extension` class. as it conflicts with an already installed Python-Markdown.
If multiple distributions have registered the same name, the first one found is returned. Assume dot notation (`path.to.module:ClassName`).
Load the specified class and return an instance. If no class is specified,
If no entry point is found, assume dot notation (`path.to.module:ClassName`). Load the specified class and import the module and call a `makeExtension` function
return an instance. If no class is specified, import the module and call a `makeExtension` function and return and return the Extension instance returned by that function.
the Extension instance returned by that function.
""" """
configs = dict(configs) configs = dict(configs)
entry_points = [ep for ep in util.INSTALLED_EXTENSIONS if ep.name == ext_name]
if entry_points:
ext = entry_points[0].load()
return ext(**configs)
# Get class name (if provided): `path.to.module:ClassName` # Get class name (if provided): `path.to.module:ClassName`
ext_name, class_name = ext_name.split(':', 1) if ':' in ext_name else (ext_name, '') ext_name, class_name = ext_name.split(':', 1) if ':' in ext_name else (ext_name, '')

View File

@ -7,11 +7,7 @@
| Copyright (C) 2022, OctoSpacc | | Copyright (C) 2022, OctoSpacc |
| ================================= """ | ================================= """
# Our local Markdown patches conflict if the module is installed on the system, so first try to import from system from Libs.markdown import markdown
try:
from markdown import markdown
except ModuleNotFoundError:
from Libs.markdown import markdown
MarkdownExtsDefault = ('attr_list', 'def_list', 'footnotes', 'md_in_html', 'tables') MarkdownExtsDefault = ('attr_list', 'def_list', 'footnotes', 'md_in_html', 'tables')

View File

@ -22,10 +22,10 @@ def DashifyTitle(Title, Done=[]):
def MakeLinkableTitle(Line, Title, DashTitle, Type): def MakeLinkableTitle(Line, Title, DashTitle, Type):
if Type == 'md': if Type == 'md':
Index = Title.split(' ')[0].count('#') Index = Title.split(' ')[0].count('#')
return f'<h{Index} id="{DashTitle}" class="SectionTitle"><span class="SectionLink"><a href="#{DashTitle}"><span>&gt;&gt;</span></a> </span>{Title[Index+1:]}</h{Index}>' return f'<h{Index} id="{DashTitle}" class="SectionTitle"><span class="SectionLink"><a href="#{DashTitle}"><span>»</span></a> </span>{Title[Index+1:]}</h{Index}>'
elif Type == 'pug': elif Type == 'pug':
Index = Line.find('h') Index = Line.find('h')
return f"{Line[:Index]}{Line[Index:Index+2]}(id='{DashTitle}' class='SectionTitle') #[span(class='SectionLink') #[a(href='#{DashTitle}') #[span &gt;&gt;]] ]{Line[Index+2:]}" return f"{Line[:Index]}{Line[Index:Index+2]}(id='{DashTitle}' class='SectionTitle') #[span(class='SectionLink') #[a(href='#{DashTitle}') #[span »]] ]{Line[Index+2:]}"
def GetTitle(FileName, Meta, Titles, Prefer='MetaTitle', BlogName=None): def GetTitle(FileName, Meta, Titles, Prefer='MetaTitle', BlogName=None):
if Prefer == 'BodyTitle': if Prefer == 'BodyTitle':

View File

@ -95,6 +95,7 @@ def ReplWithEsc(Str, Find, Repl, Esc='\\'):
New = New[:-1] New = New[:-1]
New += Repl + e New += Repl + e
elif Sects[i-1].endswith(Esc): elif Sects[i-1].endswith(Esc):
New = New[:-1]
New += Find + e New += Find + e
else: else:
New += Repl + e New += Repl + e

7
TODO
View File

@ -1,3 +1,6 @@
- Specify input folder(s) and files (idea is Makefile compatibility too)
- Show page size/words/time in meta line
- Add feed support for diary-like pages
- Fix excess whitespace in some section/menu titles - Fix excess whitespace in some section/menu titles
- Change staticoso service tag enclosure from [] to <> - Change staticoso service tag enclosure from [] to <>
- Investigate a strange bug with Macros - Investigate a strange bug with Macros
@ -7,7 +10,6 @@
- Accept Macros as CLI arguments - Accept Macros as CLI arguments
- Deprecate FolderRoots (Macros make it redundant) - Deprecate FolderRoots (Macros make it redundant)
- Fix ordering menu in Site.ini (not working for inner pages) - Fix ordering menu in Site.ini (not working for inner pages)
- Fix Python-Markdown is installed problem (to load our modules)
- Feed generation without native libraries - Feed generation without native libraries
- JSON feeds - JSON feeds
- Full XML sitemap - Full XML sitemap
@ -20,4 +22,5 @@
- Automatic guessing of .htm/.html extension for declarations of templates and stuff - Automatic guessing of .htm/.html extension for declarations of templates and stuff
- Exporting sites to different formats (?) (single-page HTML, PDF, EPUB, ...) - Exporting sites to different formats (?) (single-page HTML, PDF, EPUB, ...)
- Disable only ActivityPub feed for a page - Disable only ActivityPub feed for a page
- Override ActivityPub URL - Automatic redirects/symlinks for making pages work without .html suffix
- Override URL for a page / Add custom redirects for it