diff --git a/markdown_it/port.yaml b/markdown_it/port.yaml index c0a4d70b..a553fe1a 100644 --- a/markdown_it/port.yaml +++ b/markdown_it/port.yaml @@ -1,7 +1,7 @@ - package: markdown-it/markdown-it - version: 12.3.1 - commit: 76469e83dc1a1e3ed943b483b554003a666bddf7 - date: Jan 7, 2022 + version: 12.3.2 + commit: d72c68b520cedacae7878caa92bf7fe32e3e0e6f + date: Jan 8, 2022 notes: - Rename variables that use python built-in names, e.g. - `max` -> `maximum` diff --git a/markdown_it/rules_inline/newline.py b/markdown_it/rules_inline/newline.py index dede7251..ca8f1db0 100644 --- a/markdown_it/rules_inline/newline.py +++ b/markdown_it/rules_inline/newline.py @@ -1,11 +1,7 @@ -# Proceess '\n' -import re - +"""Proceess '\n'.""" from ..common.utils import charStrAt, isStrSpace from .state_inline import StateInline -endSpace = re.compile(r" +$") - def newline(state: StateInline, silent: bool) -> bool: pos = state.pos @@ -23,7 +19,12 @@ def newline(state: StateInline, silent: bool) -> bool: if not silent: if pmax >= 0 and charStrAt(state.pending, pmax) == " ": if pmax >= 1 and charStrAt(state.pending, pmax - 1) == " ": - state.pending = endSpace.sub("", state.pending) + # Find whitespaces tail of pending chars. + ws = pmax - 1 + while ws >= 1 and charStrAt(state.pending, ws - 1) == " ": + ws -= 1 + state.pending = state.pending[:ws] + state.push("hardbreak", "br", 0) else: state.pending = state.pending[:-1]