diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 027af3f..57c2f0b 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -87,7 +87,7 @@ headers = ( # [6] = Check content differently. 't' = startswith #------------------------------------------------------------- words_tags = [ -('>_', '_<', '', 'anchors', 'w'), +('>_', '_<', '', '', 'anchors', 'w'), ('*_', '_*', '', '', 'strongs', 'w'), ('+_', '_+', '', '', 'bolds', 'w'), ('/_', '_/', '', '', 'emphasis', 'w'), diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 0c3df8b..5ea5bb3 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -199,10 +199,17 @@ def wip_single_tags(): def wip_words_tags(): global article_bottom - # Strongs, italics... (8 tags) + # Strongs, italics... + # (Stop after 8 tags) + # For anchor (0), must do it differently m = 0 for tag in tyto.words_tags: - if m > 8: break + if m == 0: + m += 1 + # Close anchor (generic) + article_bottom = article_bottom.replace(tag[1], tag[3]) + continue + elif m > 8: break # Open tag article_bottom = article_bottom.replace(tag[0], tag[2]) @@ -210,8 +217,9 @@ def wip_words_tags(): article_bottom = article_bottom.replace(tag[1], tag[3]) m += 1 - # Paragraphs + for ln, line in enumerate(article_bottom.rsplit('\n')): + # Paragraphs # Open tag if line.startswith(tyto.words_tags[10][0]): set_css = tyto.get_css(line) @@ -220,12 +228,20 @@ def wip_words_tags(): tyto.words_tags[10][2]%set_css ) # Close tag - if line.startswith(tyto.words_tags[10][1]): + elif line.startswith(tyto.words_tags[10][1]): article_bottom = article_bottom.replace( line, tyto.words_tags[10][3] ) - + # Open anchors + anchor_links = re.findall(r'>_(.+?):', line) + for item in anchor_links: + anchor_id = '%s%s:'%(tyto.words_tags[0][0], item) + print(anchor_id) + article_bottom = article_bottom.replace( + anchor_id, tyto.words_tags[0][2]%item + ) + #=======================# # Convert links from DB # @@ -632,7 +648,7 @@ def wip_raws(target): global article_bottom - for i in range(1, db.uniq_raws + 1): + for i in range(1, db.xtuniq_raws + 1): raw = 'db.raw_%s'%i raw_file = open( '%s%s'%(