Commit 0e0d3719 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Another fix for the replacement

parent 43d2f20b
Loading
Loading
Loading
Loading
Loading
+4 −4
Changes for generateBaseline/pandocFilter.py: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -290,12 +290,12 @@ def replaceFigureCaptions(progress:Progress, mdLines:list[str]) -> list[str]:
			_lines.append(line)
			continue
		if matches:
			# Replace the previous figure markdown name with the captions
			# Stop if image reference is found, or if the line is not empty
			# Replace the previous figure markdown name with the captions.
			# Skip blank lines, then attach only if that line is an image.
			_idx = len(_lines) - 1
			while _idx >= 0 and _lines[_idx].count('![') == 0 and _lines[_idx].strip() == '':
			while _idx >= 0 and _lines[_idx].strip() == '':
				_idx -= 1
			if _idx > 0 and _lines[_idx].count('![') > 0:
			if _idx >= 0 and _lines[_idx].count('![') > 0:
				_lines[_idx] = re.sub(r'!.*]', f'![{matches[0]}]', _lines[_idx])
			else:
				_lines.append(line)