Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/markdown_it/rules_inline/html_inline.py: 96%

23 statements  

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

1# Process html tags 

2from ..common.html_re import HTML_TAG_RE 

3from .state_inline import StateInline 

4 

5 

6def isLetter(ch: int): 

7 lc = ch | 0x20 # to lower case 

8 # /* a */ and /* z */ 

9 return (lc >= 0x61) and (lc <= 0x7A) 

10 

11 

12def html_inline(state: StateInline, silent: bool): 

13 pos = state.pos 

14 

15 if not state.md.options.get("html", None): 

16 return False 

17 

18 # Check start 

19 maximum = state.posMax 

20 if state.srcCharCode[pos] != 0x3C or pos + 2 >= maximum: # /* < */ 

21 return False 

22 

23 # Quick fail on second char 

24 ch = state.srcCharCode[pos + 1] 

25 if ( 

26 ch != 0x21 

27 and ch != 0x3F # /* ! */ 

28 and ch != 0x2F # /* ? */ 

29 and not isLetter(ch) # /* / */ 

30 ): 

31 return False 

32 

33 match = HTML_TAG_RE.search(state.src[pos:]) 

34 if not match: 

35 return False 

36 

37 if not silent: 

38 token = state.push("html_inline", "", 0) 

39 token.content = state.src[pos : pos + len(match.group(0))] 

40 

41 state.pos += len(match.group(0)) 

42 return True