Commit 2895bcc2 authored by chrissi^'s avatar chrissi^

flamngo: Add site-dependend HTML-Parser

The flamingo-core HTML-parser does two things:

* remove the first <h1>
* re-write the HTML with beutiful soup.

First:
We want to leave our <h1> where it is since it is
places somewhere inside out HTML.
The Template should not be able to place it there...

Second:
BS-HTML is ugly!
Signed-off-by: chrissi^'s avatarChris Fiege <chris@tinyhost.de>
parent b6ac55ed
from bs4 import BeautifulSoup
from flamingo.core.utils.html import extract_title
from flamingo.core.parser import ContentParser
class RawParser(ContentParser):
FILE_EXTENSIONS = ['html']
def parse(self, file_content, content):
markup_string = self.parse_meta_data(file_content, content)
soup = BeautifulSoup(markup_string, 'html.parser')
title = extract_title(soup)
content['content_title'] = title
content['content_body'] = markup_string
class Raw:
def parser_setup(self, context):
context.parser.add_parser(RawParser(context))
...@@ -8,8 +8,13 @@ PLUGINS = [ ...@@ -8,8 +8,13 @@ PLUGINS = [
'flamingo.plugins.rstPygments', 'flamingo.plugins.rstPygments',
'plugins/title.py::Title', 'plugins/title.py::Title',
'plugins/git.py::Git', 'plugins/git.py::Git',
'plugins/raw.py::Raw',
] ]
# remove flamingo core HTML plugin.
# we can now use our own "Raw"
DEFAULT_PLUGINS = [x for x in DEFAULT_PLUGINS if x != "flamingo.plugins.HTML"]
LAYERS = [ LAYERS = [
'static', 'static',
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment