Small fix for html generation
This commit is contained in:
parent
cf15023da5
commit
818856a585
|
@ -5,7 +5,7 @@ from pygments.lexers import PythonLexer
|
|||
from pygments.lexers import get_lexer_by_name
|
||||
from pygments.formatters import HtmlFormatter
|
||||
|
||||
def src(doc, code, cls=''):
|
||||
def src(doc, code, cls='', root=True):
|
||||
try:
|
||||
lexer = get_lexer_by_name(code.attrs.get('language', 'shell'))
|
||||
except pygments.util.ClassNotFound as e:
|
||||
|
@ -13,7 +13,7 @@ def src(doc, code, cls=''):
|
|||
|
||||
return highlight(code.value, lexer, HtmlFormatter(linenos=True))
|
||||
|
||||
def img(doc, item, cls=''):
|
||||
def img(doc, item, cls='', root=True):
|
||||
caption = doc.previous('CAPTION')
|
||||
text = ''
|
||||
if caption:
|
||||
|
@ -22,10 +22,15 @@ def img(doc, item, cls=''):
|
|||
|
||||
|
||||
def parse_text_html(doc, token, cls='', root=True):
|
||||
if not isinstance(token.value, list):
|
||||
return f'<p{cls}>{token.value}</p>'
|
||||
|
||||
print('test')
|
||||
print(token)
|
||||
# if its the start of a text body wrap html tags
|
||||
# else more complicated so return the tags
|
||||
if isinstance(token.value, str):
|
||||
if root is True:
|
||||
return f'<p{cls}>{token.value}</p>'
|
||||
return f'{token.value}'
|
||||
|
||||
|
||||
response = StringIO()
|
||||
|
||||
|
@ -37,6 +42,8 @@ def parse_text_html(doc, token, cls='', root=True):
|
|||
response.write(handle_token(doc, item, False))
|
||||
response.write(f'</p>')
|
||||
|
||||
response.seek(0)
|
||||
print(response.read())
|
||||
response.seek(0)
|
||||
return response.read()
|
||||
|
||||
|
|
Loading…
Reference in New Issue