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

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

8 statements  

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