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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

1"""Normalize input string.""" 

2 

3import re 

4 

5from .state_core import StateCore 

6 

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

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

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

10 

11 

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

13 # Normalize newlines 

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

15 

16 # Replace NULL characters 

17 string = NULL_RE.sub("\ufffd", string) 

18 

19 state.src = string