From c3a3eb3dd0397c2da228afc988d13323d2dd4504 Mon Sep 17 00:00:00 2001
From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
Date: Wed, 6 Dec 2023 23:12:38 +0100
Subject: [PATCH] Some fixes: - the complete ToC clause is analysed (between
 clause marks) - figura caption regexp to catch figure caption in any part of
 the line

---
 generateChangemarks/pandocFilter.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/generateChangemarks/pandocFilter.py b/generateChangemarks/pandocFilter.py
index a07b778..41b6ca5 100644
--- a/generateChangemarks/pandocFilter.py
+++ b/generateChangemarks/pandocFilter.py
@@ -65,6 +65,8 @@ def correctTOC(progress:Progress, mdLines:list[str], tocSection:str = 'Contents'
 			if matches:
 				_lines.append(f'{matches[0]}  \n')
 				continue
+			else:
+				_lines.append(line)
 		else:
 			_lines.append(line)
 
@@ -112,11 +114,10 @@ def replaceFigureCaptions(progress:Progress, mdLines:list[str]) -> list[str]:
 		if matches:
 			# Replace the previous figure markdown name with the captions
 			_idx = len(_lines) - 1
-			while _idx >= 0 and not _lines[_idx].startswith('!['):
+			while _idx >= 0 and _lines[_idx].count('![') == 0:
 				_idx -= 1
 			if _idx > 0:
-				_lines[_idx] = re.sub(r'^.*?]', f'![{matches[0]}]', _lines[_idx])
-
+				_lines[_idx] = re.sub(r'!.*]', f'![{matches[0]}]', _lines[_idx])
 		elif re.findall(nocaptionfigureregex, line):
 			_lines.append(re.sub(r'^.*?]', f'![]', line))
 		else:
-- 
GitLab