HTML files as page inputs

This commit is contained in:
octospacc 2022-07-24 16:47:12 +02:00
parent 0c56516f89
commit 70bf67586e
4 changed files with 7 additions and 9 deletions

View File

@ -42,5 +42,5 @@ Feel free to experiment with all of this stuff!
- [x] Generation of titles in right sidebar with clickable links
- [x] Detections of titles in a page
- [x] Custom static page parts by template
- [x] Extended Markdown + Pug support for pages
- [x] _HTML_, _Extended Markdown_, and _Pug_ supported for input page files
- [x] Ready for use

View File

@ -20,4 +20,5 @@ def PugCompileList(Pages):
Path = 'public/{}'.format(File)
WriteFile(Path, Content)
Paths += '"{}" '.format(Path)
os.system('pug -P {} > /dev/null'.format(Paths))
if Paths:
os.system('pug -P {} > /dev/null'.format(Paths))

View File

@ -117,6 +117,7 @@ def Preprocessor(Path, SiteRoot):
'Style': '',
'Type': '',
'Index': 'True',
'Feed': 'True',
'Title': '',
'HTMLTitle': '',
'Description': '',
@ -129,7 +130,7 @@ def Preprocessor(Path, SiteRoot):
ls = l.lstrip()
if ls.startswith('// '):
lss = ls[3:]
for Item in ('Template', 'Type', 'Index', 'Title', 'HTMLTitle', 'Description', 'Image', 'CreatedOn', 'EditedOn'):
for Item in ('Template', 'Type', 'Index', 'Feed', 'Title', 'HTMLTitle', 'Description', 'Image', 'CreatedOn', 'EditedOn'):
ItemText = '{}: '.format(Item)
if lss.startswith(ItemText):
Meta[Item] = lss[len(ItemText):]
@ -147,7 +148,6 @@ def Preprocessor(Path, SiteRoot):
if Path.endswith('.html') and not HTMLTitlesFound:
Soup = BeautifulSoup(File, 'html.parser')
Tags = Soup.find_all()
#for t in Soup.find_all(Headings):
for t in Tags:
if t.name in Headings:
Title = '#'*int(t.name[1]) + ' ' + str(t.text)
@ -155,9 +155,7 @@ def Preprocessor(Path, SiteRoot):
DashyTitles += [DashTitle]
Titles += [Title]
t.replace_with(MakeLinkableTitle(None, Title, DashTitle, 'md'))
print(Titles)
Content = str(Soup)
print(Content)
Content = str(Soup.prettify(formatter=None))
HTMLTitlesFound = True
elif Path.endswith('.md'):
if ls.startswith('#'):
@ -399,7 +397,7 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu,
PagePath = 'public/{}.html'.format(StripExt(File))
if File.endswith('.md'):
Content = markdown(Content, extensions=MarkdownExts)
elif File.endswith(('.html','.pug')):
elif File.endswith(('.pug')):
Content = ReadFile(PagePath)
HTML, ContentHTML, SlimHTML, Description, Image = PatchHTML(
File=File,

1
TODO
View File

@ -1,3 +1,2 @@
- Fix arguments - some are only callable from CLI and not Site.ini
- Accept HTML files as input pages
- Optionally disabling nesting and folder listing for page lists