[0.10.2]
This commit is contained in:
parent
49adf951ef
commit
1b13f8e1df
|
@ -6,6 +6,11 @@ Tyto - Littérateur
|
||||||
- Changelog: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/CHANGELOG.md
|
- Changelog: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/CHANGELOG.md
|
||||||
- License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE
|
- License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE
|
||||||
|
|
||||||
|
## [0.10.2]
|
||||||
|
- Citer dans un texte > `[_` + `_]`
|
||||||
|
- Italique `<em>` > `;_` + `_;`
|
||||||
|
- Italique `<i>` > {_:_` + `_:`
|
||||||
|
|
||||||
## [0.10.1]
|
## [0.10.1]
|
||||||
- Fix with try in check for static page
|
- Fix with try in check for static page
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@ Vous pouvez avoir un Nom identique pour les marqueurs `file:` et `link:`
|
||||||
```
|
```
|
||||||
*_très gras_* # <strong>
|
*_très gras_* # <strong>
|
||||||
+_gras léger_+ # <b>
|
+_gras léger_+ # <b>
|
||||||
/_en italique_/ # <em>
|
;_en italique_; # <em>
|
||||||
:_en italique_: # <i>
|
:_en italique_: # <i>
|
||||||
~_texte barré_~ # <del>
|
~_texte barré_~ # <del>
|
||||||
@_Citation rapide_@ # <cite>
|
[_Citation rapide_] # <cite>
|
||||||
%_Classe personnalisée_% >>> <span class="custom">
|
%_Classe personnalisée_% >>> <span class="custom">
|
||||||
._Souligné_. # <u>
|
._Souligné_. # <u>
|
||||||
{_Code_} # <code>
|
{_Code_} # <code>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Package: tyto
|
Package: tyto
|
||||||
Version: 0.10.1
|
Version: 0.10.2
|
||||||
Section: custom
|
Section: custom
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: all
|
Architecture: all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Version: 0.10.1
|
# Version: 0.10.2
|
||||||
# Tyto - Littérateur
|
# Tyto - Littérateur
|
||||||
#
|
#
|
||||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||||
|
|
|
@ -343,19 +343,19 @@ def if_icodes_bcodes_quotes(post_bottom):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# quotes
|
# quotes
|
||||||
elif line.startswith(tyto.words_tags[11][0]) and not in_bcode:
|
elif line.startswith(tyto.block_tags[1][0]) and not in_bcode:
|
||||||
quote = in_quote = in_bq = True
|
quote = in_quote = in_bq = True
|
||||||
continue
|
continue
|
||||||
elif line.startswith(tyto.words_tags[11][1]):
|
elif line.startswith(tyto.block_tags[1][1]):
|
||||||
in_quote = False
|
in_quote = False
|
||||||
nbr_quotes += 1
|
nbr_quotes += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# bcode
|
# bcode
|
||||||
elif line.startswith(tyto.words_tags[12][0]) and not in_quote:
|
elif line.startswith(tyto.block_tags[2][0]) and not in_quote:
|
||||||
bcode = in_bcode = in_bq = True
|
bcode = in_bcode = in_bq = True
|
||||||
continue
|
continue
|
||||||
elif line.startswith(tyto.words_tags[12][1]):
|
elif line.startswith(tyto.block_tags[2][1]):
|
||||||
in_bcode = False
|
in_bcode = False
|
||||||
nbr_bcodes += 1
|
nbr_bcodes += 1
|
||||||
continue
|
continue
|
||||||
|
@ -781,13 +781,28 @@ def check_content(post_bottom):
|
||||||
for tag in tyto.words_tags:
|
for tag in tyto.words_tags:
|
||||||
c_opened = c_closed = 0
|
c_opened = c_closed = 0
|
||||||
|
|
||||||
if tag[5] == 'w':
|
|
||||||
c_opened = post_bottom.count(tag[0])
|
c_opened = post_bottom.count(tag[0])
|
||||||
c_closed = post_bottom.count(tag[1])
|
c_closed = post_bottom.count(tag[1])
|
||||||
# Useless tag now, replace
|
# Useless tag now, replace
|
||||||
post_bottom = post_bottom.replace(tag[0], '')
|
post_bottom = post_bottom.replace(tag[0], '')
|
||||||
post_bottom = post_bottom.replace(tag[1], '')
|
post_bottom = post_bottom.replace(tag[1], '')
|
||||||
elif tag[5] == 't':
|
|
||||||
|
if c_opened != c_closed:
|
||||||
|
logs.out("8", '%s "%s" + "%s" > %s'%(
|
||||||
|
tag[4], tag[0], tag[1], db.uri_file
|
||||||
|
), False)
|
||||||
|
post_err = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
globals()['post_%s'%tag[4]] = int(c_opened)
|
||||||
|
|
||||||
|
|
||||||
|
# Check block tags paragraphs, qyotes...)
|
||||||
|
# Set stats for each one
|
||||||
|
#-------------------------------------------
|
||||||
|
for tag in tyto.block_tags:
|
||||||
|
c_opened = c_closed = 0
|
||||||
|
|
||||||
for line in post_bottom.rsplit('\n'):
|
for line in post_bottom.rsplit('\n'):
|
||||||
if line.startswith(tag[0]): c_opened += 1
|
if line.startswith(tag[0]): c_opened += 1
|
||||||
if line.startswith(tag[1]): c_closed += 1
|
if line.startswith(tag[1]): c_closed += 1
|
||||||
|
@ -797,7 +812,7 @@ def check_content(post_bottom):
|
||||||
tag[4], tag[0], tag[1], db.uri_file
|
tag[4], tag[0], tag[1], db.uri_file
|
||||||
), False)
|
), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
return # Useless and could code errors to check nexts
|
|
||||||
else:
|
else:
|
||||||
globals()['post_%s'%tag[4]] = int(c_opened)
|
globals()['post_%s'%tag[4]] = int(c_opened)
|
||||||
|
|
||||||
|
@ -813,10 +828,10 @@ def check_content(post_bottom):
|
||||||
if post_lists > 0:
|
if post_lists > 0:
|
||||||
inlist = False
|
inlist = False
|
||||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||||
if line.startswith(tyto.words_tags[13][0]):
|
if line.startswith(tyto.block_tags[3][0]):
|
||||||
inlist = True
|
inlist = True
|
||||||
continue
|
continue
|
||||||
elif line.startswith(tyto.words_tags[13][1]):
|
elif line.startswith(tyto.block_tags[3][1]):
|
||||||
inlist = False
|
inlist = False
|
||||||
|
|
||||||
if not inlist:
|
if not inlist:
|
||||||
|
@ -825,7 +840,7 @@ def check_content(post_bottom):
|
||||||
if inlist and not line or not line[0] in tyto.markers_lists:
|
if inlist and not line or not line[0] in tyto.markers_lists:
|
||||||
logs.out("3", 'L=%s. %s %s > %s'%(
|
logs.out("3", 'L=%s. %s %s > %s'%(
|
||||||
ln + ln_header,
|
ln + ln_header,
|
||||||
tyto.words_tags[13][4],
|
tyto.block_tags[3][4],
|
||||||
tyto.markers_lists,
|
tyto.markers_lists,
|
||||||
db.uri_file
|
db.uri_file
|
||||||
), False)
|
), False)
|
||||||
|
|
|
@ -105,21 +105,29 @@ headers = \
|
||||||
# [6] = Check content differently. 't' = startswith
|
# [6] = Check content differently. 't' = startswith
|
||||||
#-------------------------------------------------------------
|
#-------------------------------------------------------------
|
||||||
words_tags = [
|
words_tags = [
|
||||||
('>_', '_<', '<a class="anchor_link" href="#%s">', '</a>', 'anchors', 'w'),
|
('>_', '_<',
|
||||||
|
'<a class="anchor_link" href="#%s">',
|
||||||
|
'</a>', 'anchors', 'w'
|
||||||
|
),
|
||||||
('*_', '_*', '<strong class="strong">', '</strong>', 'strongs', 'w'),
|
('*_', '_*', '<strong class="strong">', '</strong>', 'strongs', 'w'),
|
||||||
('+_', '_+', '<b class="bold">', '</b>', 'bolds', 'w'),
|
('+_', '_+', '<b class="bold">', '</b>', 'bolds', 'w'),
|
||||||
('/_', '_/', '<em class="em">', '</em>', 'emphasis', 'w'),
|
(';_', '_;', '<em class="em">', '</em>', 'emphasis', 'w'),
|
||||||
(':_', '_:', '<i class="italic">', '</i>', 'italics', 'w'),
|
(':_', '_:', '<i class="italic">', '</i>', 'italics', 'w'),
|
||||||
('~_', '_~', '<del class="del">', '</del>', 'dels', 'w'),
|
('~_', '_~', '<del class="del">', '</del>', 'dels', 'w'),
|
||||||
('._', '_.', '<u class="underline">', '</u>', 'underlines', 'w'),
|
('._', '_.', '<u class="underline">', '</u>', 'underlines', 'w'),
|
||||||
('@_', '_@', '<cite class="cite">', '</cite>', 'cites', 'w'),
|
('[_', '_]', '<cite class="cite">', '</cite>', 'cites', 'w'),
|
||||||
('%_', '_%', '<span class="custom">', '</span>', 'customs', 'w'),
|
('%_', '_%', '<span class="custom">', '</span>', 'customs', 'w'),
|
||||||
('{_', '_}', '<code class="icode">', '</code>', 'codes', 'w'),
|
('{_', '_}', '<code class="icode">', '</code>', 'codes', 'w'),
|
||||||
('((', '))', '<p class="%s">', '</p>', 'paragraphs', 't'),
|
]
|
||||||
('[[', ']]', '[[', ']]', 'quotes', 't'),
|
|
||||||
('{{', '}}', '{{', '}}', 'bcodes', 't'),
|
# At begining line, create block contents
|
||||||
('-(', '-)', '-(', '-)', 'lists', 't'),
|
block_tags = \
|
||||||
('<<', '>>', '<div class="%s">', '</div>', 'div', 't')
|
[
|
||||||
|
('((', '))', '<p class="%s">', '</p>', 'paragraphs'),
|
||||||
|
('[[', ']]', '[[', ']]', 'quotes'),
|
||||||
|
('{{', '}}', '{{', '}}', 'bcodes'),
|
||||||
|
('-(', '-)', '-(', '-)', 'lists'),
|
||||||
|
('<<', '>>', '<div class="%s">', '</div>', 'div'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Tags that do not need to be paired
|
# Tags that do not need to be paired
|
||||||
|
@ -132,10 +140,10 @@ single_tags = [
|
||||||
# When counting words, do no count line starting with:
|
# When counting words, do no count line starting with:
|
||||||
nolinewords = \
|
nolinewords = \
|
||||||
(
|
(
|
||||||
words_tags[10][0], words_tags[10][1], # paragraphs
|
block_tags[0][0], block_tags[0][1], # paragraphs
|
||||||
words_tags[11][0], words_tags[11][1], # quotes
|
block_tags[1][0], block_tags[1][1], # quotes
|
||||||
words_tags[12][0], words_tags[12][1], # bcodes
|
block_tags[2][0], block_tags[2][1], # bcodes
|
||||||
words_tags[13][0], words_tags[13][1], # lists
|
block_tags[3][0], block_tags[3][1], # lists
|
||||||
single_tags[0][0], single_tags[1][0], # New line, anchor
|
single_tags[0][0], single_tags[1][0], # New line, anchor
|
||||||
'_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4], # _image:, _raw:
|
'_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4], # _image:, _raw:
|
||||||
'_%s:'%opt_header_tags[5] # _code
|
'_%s:'%opt_header_tags[5] # _code
|
||||||
|
@ -328,10 +336,10 @@ def protect_bcodes_quotes(process, post_bottom):
|
||||||
#----------------------
|
#----------------------
|
||||||
# Bcode (at close, replace with base64)
|
# Bcode (at close, replace with base64)
|
||||||
if not in_quote:
|
if not in_quote:
|
||||||
if line.startswith(words_tags[12][0]): # Open
|
if line.startswith(block_tags[2][0]): # Open
|
||||||
start_bcode = True
|
start_bcode = True
|
||||||
in_bcode = True
|
in_bcode = True
|
||||||
elif line.startswith(words_tags[12][1]): # Close
|
elif line.startswith(block_tags[2][1]): # Close
|
||||||
close_bcode = True
|
close_bcode = True
|
||||||
in_bcode = False
|
in_bcode = False
|
||||||
if process == "wip":
|
if process == "wip":
|
||||||
|
@ -342,10 +350,10 @@ def protect_bcodes_quotes(process, post_bottom):
|
||||||
|
|
||||||
# Quote (at close, replace with base64)
|
# Quote (at close, replace with base64)
|
||||||
if not in_bcode:
|
if not in_bcode:
|
||||||
if line.startswith(words_tags[11][0]): # Open
|
if line.startswith(block_tags[1][0]): # Open
|
||||||
start_quote = True
|
start_quote = True
|
||||||
in_quote = True
|
in_quote = True
|
||||||
elif line.startswith(words_tags[11][1]): # Close
|
elif line.startswith(block_tags[1][1]): # Close
|
||||||
close_quote = True
|
close_quote = True
|
||||||
in_quote = False
|
in_quote = False
|
||||||
if process == "wip":
|
if process == "wip":
|
||||||
|
|
|
@ -311,27 +311,27 @@ def wip_words_tags():
|
||||||
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||||
# Paragraphs Open tag
|
# Paragraphs Open tag
|
||||||
if db.paragraphs > 0:
|
if db.paragraphs > 0:
|
||||||
if line.startswith(tyto.words_tags[10][0]):
|
if line.startswith(tyto.block_tags[0][0]):
|
||||||
set_css = tyto.get_css(line)
|
set_css = tyto.get_css(line)
|
||||||
replace_in_post(post_bottom.rsplit('\n')[ln],
|
replace_in_post(post_bottom.rsplit('\n')[ln],
|
||||||
tyto.words_tags[10][2]%set_css
|
tyto.block_tags[0][2]%set_css
|
||||||
)
|
)
|
||||||
# Close paragraph tag
|
# Close paragraph tag
|
||||||
elif line.startswith(tyto.words_tags[10][1]):
|
elif line.startswith(tyto.block_tags[0][1]):
|
||||||
replace_in_post(line,
|
replace_in_post(line,
|
||||||
tyto.words_tags[10][3]
|
tyto.block_tags[0][3]
|
||||||
)
|
)
|
||||||
|
|
||||||
# div Open tag
|
# div Open tag
|
||||||
if line.startswith(tyto.words_tags[14][0]):
|
if line.startswith(tyto.block_tags[4][0]):
|
||||||
set_css = tyto.get_css(line)
|
set_css = tyto.get_css(line)
|
||||||
replace_in_post(post_bottom.rsplit('\n')[ln],
|
replace_in_post(post_bottom.rsplit('\n')[ln],
|
||||||
tyto.words_tags[14][2]%set_css
|
tyto.block_tags[4][2]%set_css
|
||||||
)
|
)
|
||||||
# Close paragraph tag
|
# Close paragraph tag
|
||||||
elif line.startswith(tyto.words_tags[14][1]):
|
elif line.startswith(tyto.block_tags[4][1]):
|
||||||
replace_in_post(line,
|
replace_in_post(line,
|
||||||
tyto.words_tags[14][3]
|
tyto.block_tags[4][3]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Open anchors link
|
# Open anchors link
|
||||||
|
@ -541,7 +541,7 @@ def wip_quotes() :
|
||||||
|
|
||||||
for qline in quote:
|
for qline in quote:
|
||||||
# Begin marker quote [11]
|
# Begin marker quote [11]
|
||||||
if qline.startswith(tyto.words_tags[11][0]):
|
if qline.startswith(tyto.block_tags[1][0]):
|
||||||
set_css = tyto.get_css(qline)
|
set_css = tyto.get_css(qline)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ def wip_quotes() :
|
||||||
|
|
||||||
# Paragraph [10] Open
|
# Paragraph [10] Open
|
||||||
# Construct quote_html
|
# Construct quote_html
|
||||||
if qline.startswith(tyto.words_tags[10][0]):
|
if qline.startswith(tyto.block_tags[0][0]):
|
||||||
par_css = tyto.get_css(qline)
|
par_css = tyto.get_css(qline)
|
||||||
|
|
||||||
# Set tabulation for paragraphs and content
|
# Set tabulation for paragraphs and content
|
||||||
|
@ -559,7 +559,7 @@ def wip_quotes() :
|
||||||
|
|
||||||
# Replace opened paragrph with html line
|
# Replace opened paragrph with html line
|
||||||
qline_html = '%s%s'%(
|
qline_html = '%s%s'%(
|
||||||
tab_p * ' ', tyto.words_tags[10][2]%par_css
|
tab_p * ' ', tyto.block_tags[0][2]%par_css
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add line to quote_html
|
# Add line to quote_html
|
||||||
|
@ -570,16 +570,16 @@ def wip_quotes() :
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Paragraph Close
|
# Paragraph Close
|
||||||
if qline.startswith(tyto.words_tags[10][1]):
|
if qline.startswith(tyto.block_tags[0][1]):
|
||||||
# Replace closed paragrph with html line
|
# Replace closed paragrph with html line
|
||||||
qline_html = tyto.words_tags[10][3]
|
qline_html = tyto.block_tags[0][3]
|
||||||
quote_html = '%s\n%s%s'%(
|
quote_html = '%s\n%s%s'%(
|
||||||
quote_html, int(tab_p) * ' ', qline_html
|
quote_html, int(tab_p) * ' ', qline_html
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# End of marker quote
|
# End of marker quote
|
||||||
if qline.startswith(tyto.words_tags[11][1]):
|
if qline.startswith(tyto.block_tags[1][1]):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Add other lines
|
# Add other lines
|
||||||
|
@ -694,14 +694,14 @@ def wip_bcodes():
|
||||||
# Convert src_bcode
|
# Convert src_bcode
|
||||||
for line in src_bcode.rsplit('\n'):
|
for line in src_bcode.rsplit('\n'):
|
||||||
# CSS + opened marker
|
# CSS + opened marker
|
||||||
if line.startswith(tyto.words_tags[12][0]):
|
if line.startswith(tyto.block_tags[2][0]):
|
||||||
set_css = tyto.get_css(line)
|
set_css = tyto.get_css(line)
|
||||||
html_bcode = \
|
html_bcode = \
|
||||||
'<code class="%s">\n'%set_css + \
|
'<code class="%s">\n'%set_css + \
|
||||||
' <pre class="bcode">'
|
' <pre class="bcode">'
|
||||||
|
|
||||||
# closed marker
|
# closed marker
|
||||||
elif line.startswith(tyto.words_tags[12][1]):
|
elif line.startswith(tyto.block_tags[2][1]):
|
||||||
html_bcode = \
|
html_bcode = \
|
||||||
'%s\n </pre>\n'%html_bcode + \
|
'%s\n </pre>\n'%html_bcode + \
|
||||||
'</code>'
|
'</code>'
|
||||||
|
@ -829,7 +829,7 @@ def wip_lists():
|
||||||
|
|
||||||
for line in post_bottom.rsplit('\n'):
|
for line in post_bottom.rsplit('\n'):
|
||||||
# Open list
|
# Open list
|
||||||
if line.startswith(tyto.words_tags[13][0]):
|
if line.startswith(tyto.block_tags[3][0]):
|
||||||
block_list = content_list = ''
|
block_list = content_list = ''
|
||||||
css = tyto.get_css(line)
|
css = tyto.get_css(line)
|
||||||
in_list = True
|
in_list = True
|
||||||
|
@ -837,7 +837,7 @@ def wip_lists():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Close list
|
# Close list
|
||||||
elif line.startswith(tyto.words_tags[13][1]):
|
elif line.startswith(tyto.block_tags[3][1]):
|
||||||
in_list = False
|
in_list = False
|
||||||
block_list = '%s\n%s'%(block_list, line)
|
block_list = '%s\n%s'%(block_list, line)
|
||||||
html_list = convert_list(
|
html_list = convert_list(
|
||||||
|
@ -909,8 +909,8 @@ def convert_list(markdown_str):
|
||||||
work_str = ""
|
work_str = ""
|
||||||
|
|
||||||
for i in range(len(items)):
|
for i in range(len(items)):
|
||||||
if tyto.words_tags[13][0] in items[i] or \
|
if tyto.block_tags[3][0] in items[i] or \
|
||||||
tyto.words_tags[13][1] in items[i]:
|
tyto.block_tags[3][1] in items[i]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rank = cur_rank
|
rank = cur_rank
|
||||||
|
|
Loading…
Reference in New Issue