mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-13 09:40:17 +01:00
First work on HTML to Gemtext
This commit is contained in:
parent
f6291726f6
commit
fc3c0b8be6
@ -19,16 +19,18 @@ from Libs.markdown import Markdown
|
|||||||
from Libs.markdown import markdown
|
from Libs.markdown import markdown
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from Modules.Feed import *
|
from Modules.Feed import *
|
||||||
|
from Modules.Gemini import *
|
||||||
from Modules.Utils import *
|
from Modules.Utils import *
|
||||||
|
|
||||||
Extensions = {
|
Extensions = {
|
||||||
'Pages': ('md', 'pug')}
|
'Pages': ('md', 'pug')}
|
||||||
|
|
||||||
def ResetPublic():
|
def ResetPublic():
|
||||||
try:
|
for i in ('public', 'public.gmi'):
|
||||||
shutil.rmtree('public')
|
try:
|
||||||
except FileNotFoundError:
|
shutil.rmtree(i)
|
||||||
pass
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
def GetLevels(Path, AsNum=False, Add=0, Sub=0):
|
def GetLevels(Path, AsNum=False, Add=0, Sub=0):
|
||||||
n = Path.count('/') + Add - Sub
|
n = Path.count('/') + Add - Sub
|
||||||
@ -473,6 +475,11 @@ def Main(Args):
|
|||||||
Lang=SiteLang,
|
Lang=SiteLang,
|
||||||
Minify=True if Args.Minify and Args.Minify not in ('False', 'None') else False)
|
Minify=True if Args.Minify and Args.Minify not in ('False', 'None') else False)
|
||||||
|
|
||||||
|
#HTML2Gemtext(
|
||||||
|
# Pages=Pages,
|
||||||
|
# SiteName=SiteName,
|
||||||
|
# SiteTagline=SiteTagline)
|
||||||
|
|
||||||
DelTmp()
|
DelTmp()
|
||||||
os.system("cp -R Assets/* public/")
|
os.system("cp -R Assets/* public/")
|
||||||
|
|
||||||
|
35
Source/Modules/Gemini.py
Normal file
35
Source/Modules/Gemini.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
""" ================================= |
|
||||||
|
| This file is part of |
|
||||||
|
| staticoso |
|
||||||
|
| Just a simple Static Site Generator |
|
||||||
|
| |
|
||||||
|
| Licensed under the AGPLv3 license |
|
||||||
|
| Copyright (C) 2022, OctoSpacc |
|
||||||
|
| ================================= """
|
||||||
|
|
||||||
|
from Libs.bs4 import BeautifulSoup
|
||||||
|
from Modules.Utils import *
|
||||||
|
|
||||||
|
def HTML2Gemtext(Pages, SiteName, SiteTagline):
|
||||||
|
os.mkdir('public.gmi')
|
||||||
|
for File, Content, Titles, Meta, HTMLContent, Description, Image in Pages:
|
||||||
|
Parse = BeautifulSoup(HTMLContent, 'html.parser')
|
||||||
|
# We should first get the most basic HTML elements, convert them to Gemtext, then replace the Gemtext in the original full HTML, and then removing <p> tags?
|
||||||
|
#print(File, Parse.find_all('p'), Parse.find_all('li'))
|
||||||
|
|
||||||
|
""" Gemtext:
|
||||||
|
# h1
|
||||||
|
## h2
|
||||||
|
### h3
|
||||||
|
|
||||||
|
* li
|
||||||
|
* li
|
||||||
|
|
||||||
|
=> [protocol://]URL Link Description
|
||||||
|
|
||||||
|
> Quote
|
||||||
|
|
||||||
|
```
|
||||||
|
Preformatted
|
||||||
|
```
|
||||||
|
"""
|
Loading…
x
Reference in New Issue
Block a user