From 5821040c1910a8f75de2f4426fc80726ee5ff16d Mon Sep 17 00:00:00 2001 From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org> Date: Fri, 1 Dec 2023 13:13:29 +0100 Subject: [PATCH] Remove figure caption when there's no figure caption --- generateChangemarks/pandocFilter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generateChangemarks/pandocFilter.py b/generateChangemarks/pandocFilter.py index 6adddf4..a07b778 100644 --- a/generateChangemarks/pandocFilter.py +++ b/generateChangemarks/pandocFilter.py @@ -104,6 +104,7 @@ def replaceFigureCaptions(progress:Progress, mdLines:list[str]) -> list[str]: _taskID = progress.add_task('[blue]Replacing figure captions', start=False, total=0) # progress.update() figureregex = re.compile('^\*\*(Figure .*)\*\*') + nocaptionfigureregex = re.compile('!\[~~CAPTION~~\].*') _lines:list[str] = [] for line in mdLines: @@ -116,6 +117,8 @@ def replaceFigureCaptions(progress:Progress, mdLines:list[str]) -> list[str]: if _idx > 0: _lines[_idx] = re.sub(r'^.*?]', f'![{matches[0]}]', _lines[_idx]) + elif re.findall(nocaptionfigureregex, line): + _lines.append(re.sub(r'^.*?]', f'![]', line)) else: _lines.append(line) -- GitLab