From 817872e0c188112a67cced199775f2730e1f06a1 Mon Sep 17 00:00:00 2001 From: lhess2021 Date: Fri, 18 Mar 2022 01:19:11 -0400 Subject: [PATCH] add line num attrs --- py-scripts.d/word-tags.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py-scripts.d/word-tags.py b/py-scripts.d/word-tags.py index f75d514..b1ee6d1 100644 --- a/py-scripts.d/word-tags.py +++ b/py-scripts.d/word-tags.py @@ -4,6 +4,7 @@ import os canto_dir = os.path.abspath(os.getcwd()) print('\n\n====================' + canto_dir + '====================') + def add_tags(canto_txt_file): # Only grab 0XX-canticle from `*.txt` file names xmlfile = canto_txt_file.split('.')[0] + '.xml' @@ -64,16 +65,19 @@ def add_tags(canto_txt_file): def add_space(match): match = match.group() return re.sub('', ' ', match) + j = 1 for line in Cxmltmp: # Swap double spaces from new_word with single spaces line_spaced = re.sub(' ',' ',line) # If there's a single space at the beginning of the line, delete it line_spaced = line_spaced.lstrip(' ') # Add three tabs and opening line tags at the beginning - line_spaced = re.sub('^','\t\t\t\t\t ',line_spaced) + line_tag = '\t\t\t\t\t ' + line_spaced = re.sub('^',line_tag,line_spaced) # Add closing line tags line_spaced = re.sub('\n',' \n',line_spaced) Cxml.write(line_spaced) + j += 1 Cxmltmp.close() os.remove(tmpxmlfile) Cxml.close()