Indev for quotes

This commit is contained in:
Cyrille L 2022-12-19 12:35:54 +01:00
parent 61a27495ea
commit 4ea481bbf1
2 changed files with 38 additions and 16 deletions

View File

@ -140,9 +140,20 @@ single_tags = [
markers_lists = ('+', '=', ' ')
# Tags used for titles
#---------------------
titles_tags = ('#1 ', '#2 ', '#3 ', '#4 ', '#5 ', '#6 ')
# Tags for quote
quote_tags = [
('_cite:', 'author'),
('_date:', 'date'),
('_link:', 'link'),
('_book:', 'book'),
('_lang:', 'lang')
]
#=======#
# TOOLS #
#=======#--------------------------------------------------------------

View File

@ -277,11 +277,21 @@ def wip_images():
)
#============================================#
# Get parameters for quote (author, date...) #
#--------------------------------------------#
def quote_params(qline):
for tag in tyto.quote_tags:
if qline.startswith(tag[0]):
globals()[tag[1]] = qline.rsplit(' ',1)[1].lstrip()
return(True)
#
# INDEV: convert quote in article
#
def wip_quotes() :
global article_bottom
global author, link, lang, book, date
for ln, line in enumerate(article_bottom.rsplit('\n')):
if line.startswith('Q64'):
@ -291,25 +301,13 @@ def wip_quotes() :
# Read the quote. Get parameters
author = date = lang = book = link = quote_html = ''
for qline in quote:
if qline.startswith(tyto.words_tags[11][0]):
set_css = tyto.get_css(qline)
continue
if qline.startswith('_cite:'):
author = qline.rsplit('_cite:')[1].lstrip()
continue
if qline.startswith('_date:'):
date = qline.rsplit('_date:')[1].lstrip()
continue
if qline.startswith('_book:'):
book = qline.rsplit('_book:')[1].lstrip()
continue
if qline.startswith('_lang:'):
lang = qline.rsplit('_lang:')[1].lstrip()
continue
if qline.startswith('_link:'):
lang = qline.rsplit('_link:')[1].lstrip()
continue
if quote_params(qline): continue
# paragraphs
# Construct quote_html
@ -333,4 +331,17 @@ def wip_quotes() :
if quote_html: quote_html = '%s\n%s'%(quote_html,qline)
else: quote_html = qline
print('>>>>', quote_html)
if author:
quote_html = '<figure class="%s">\n'%set_css + \
'<blockquote>\n' + \
'%s\n'%quote_html + \
'</blockquote>\n' + \
'</figure>'
else:
quote_html = '<blockquote class="%s">\n'%set_css + \
'%s\n'%quote_html + \
'</blockquote>'
print(quote_html)