Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/markdown_it/rules_core/normalize.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:15 +0000

1"""Normalize input string.""" 

2import re 

3 

4from .state_core import StateCore 

5 

6# https://spec.commonmark.org/0.29/#line-ending 

7NEWLINES_RE = re.compile(r"\r\n?|\n") 

8NULL_RE = re.compile(r"\0") 

9 

10 

11def normalize(state: StateCore) -> None: 

12 # Normalize newlines 

13 string = NEWLINES_RE.sub("\n", state.src) 

14 

15 # Replace NULL characters 

16 string = NULL_RE.sub("\uFFFD", string) 

17 

18 state.src = string