Loading generateChangemarks/pandocFilter.py +11 −2 Original line number Diff line number Diff line Loading @@ -132,14 +132,23 @@ def replaceLineBreaks(progress: Progress, mdLines: list[str]) -> list[str]: """ _taskID = progress.add_task('[blue]Replacing linebreaks', start=False, total=0) # progress.update() linebreaksregex = re.compile('<br />') linebreaksregex = re.compile('<br\s*/?\s*>') _lines: list[str] = [] _inCodeBlock = False for line in mdLines: # Check if we are in a code block if line.strip().startswith('```'): _inCodeBlock = not _inCodeBlock if _inCodeBlock: _lines.append(line) continue # Replace linebreaks matches = re.findall(linebreaksregex, line) if matches: # Replace the linebreak with "\(newline)" _lines.append(re.sub(r'<br />', f'\\\n', line)) _lines.append(re.sub(linebreaksregex, f'\\\n', line)) else: _lines.append(line) Loading Loading
generateChangemarks/pandocFilter.py +11 −2 Original line number Diff line number Diff line Loading @@ -132,14 +132,23 @@ def replaceLineBreaks(progress: Progress, mdLines: list[str]) -> list[str]: """ _taskID = progress.add_task('[blue]Replacing linebreaks', start=False, total=0) # progress.update() linebreaksregex = re.compile('<br />') linebreaksregex = re.compile('<br\s*/?\s*>') _lines: list[str] = [] _inCodeBlock = False for line in mdLines: # Check if we are in a code block if line.strip().startswith('```'): _inCodeBlock = not _inCodeBlock if _inCodeBlock: _lines.append(line) continue # Replace linebreaks matches = re.findall(linebreaksregex, line) if matches: # Replace the linebreak with "\(newline)" _lines.append(re.sub(r'<br />', f'\\\n', line)) _lines.append(re.sub(linebreaksregex, f'\\\n', line)) else: _lines.append(line) Loading