diff --git a/Source/Modules/HTML.py b/Source/Modules/HTML.py index 32ee7c5..0818b87 100644 --- a/Source/Modules/HTML.py +++ b/Source/Modules/HTML.py @@ -8,19 +8,12 @@ | ================================= """ import html +import warnings from Libs.bs4 import BeautifulSoup from Modules.Utils import * -""" -ClosedTags = ( - 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', - 'p', 'span', 'pre', 'code', - 'a', 'b', 'i', 'del', 'strong', - 'div', 'details', 'summary', - 'ol', 'ul', 'li', 'dl', 'dt', 'dd') -OpenTags = ( - 'img') -""" +# Suppress useless bs4 warnings +warnings.filterwarnings('ignore', message='The input looks more like a filename than markup.') def MkSoup(HTML): return BeautifulSoup(HTML, 'html.parser') @@ -60,7 +53,6 @@ def AddToTagStartEnd(HTML, MatchStart, MatchEnd, AddStart, AddEnd): # This doesn break if FilterStart == MatchStart: StartPos = i - # TagName = FirstRealItem(FirstRealItem(FilterStart.split('<')).split(' ')) if AddStart: HTML = HTML[:i] + AddStart + HTML[i:] AddStart = None diff --git a/Source/Modules/Site.py b/Source/Modules/Site.py index 6ce0f1d..5574854 100644 --- a/Source/Modules/Site.py +++ b/Source/Modules/Site.py @@ -22,14 +22,10 @@ def DashifyTitle(Title, Done=[]): def MakeLinkableTitle(Line, Title, DashTitle, Type): if Type == 'md': Index = Title.split(' ')[0].count('#') - return f'{Title[Index+1:]}' + return f'>> {Title[Index+1:]}' elif Type == 'pug': - NewLine = '' Index = Line.find('h') - NewLine += Line[:Index] - NewLine += f"{Line[Index:Index+2]}(id='{DashTitle}')" - NewLine += Line[Index+2:] - return NewLine + 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): if Prefer == 'BodyTitle': @@ -180,11 +176,21 @@ def PagePreprocessor(Path, Type, SiteTemplate, SiteRoot, GlobalMacros): Content = str(Soup.prettify(formatter=None)) HTMLTitlesFound = True elif Path.endswith(FileExtensions['Markdown']): - if ll.startswith('#'): - DashTitle = DashifyTitle(l.lstrip('#'), DashyTitles) + if ll.startswith('#') or (ll.startswith('<') and ll[1:].startswith(Headings)): + if ll.startswith('#'): + Title = ll + #Index = Title.split(' ')[0].count('#') + elif ll.startswith('<'): + #Index = int(ll[2]) + Title = '#'*h + str(ll[3:]) + DashTitle = DashifyTitle(MkSoup(Title.lstrip('#')).get_text(), DashyTitles) DashyTitles += [DashTitle] - Titles += [l] - Content += MakeLinkableTitle(None, ll, DashTitle, 'md') + '\n' + Titles += [Title] + Title = MakeLinkableTitle(None, Title, DashTitle, 'md') + #Title = Title.replace(' ', '') + Title = Title.replace('> +- Investigate a strange bug with Macros - Handle file extensions with any case sensitivity, not just lowercase; currently the bulk of the issue is finding the files on disk - Test sorting by date for files not starting with date, and dated folders - Fix arguments - some are only callable from CLI and not Site.ini - make them coherent with INI categories