Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/markdown_it/rules_block/paragraph.py: 100%
40 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:07 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:07 +0000
1"""Paragraph."""
2import logging
4from ..ruler import Ruler
5from .state_block import StateBlock
7LOGGER = logging.getLogger(__name__)
10def paragraph(state: StateBlock, startLine: int, endLine: int, silent: bool = False):
11 LOGGER.debug(
12 "entering paragraph: %s, %s, %s, %s", state, startLine, endLine, silent
13 )
15 nextLine = startLine + 1
16 ruler: Ruler = state.md.block.ruler
17 terminatorRules = ruler.getRules("paragraph")
18 endLine = state.lineMax
20 oldParentType = state.parentType
21 state.parentType = "paragraph"
23 # jump line-by-line until empty one or EOF
24 while nextLine < endLine:
25 if state.isEmpty(nextLine):
26 break
27 # this would be a code block normally, but after paragraph
28 # it's considered a lazy continuation regardless of what's there
29 if state.sCount[nextLine] - state.blkIndent > 3:
30 nextLine += 1
31 continue
33 # quirk for blockquotes, this line should already be checked by that rule
34 if state.sCount[nextLine] < 0:
35 nextLine += 1
36 continue
38 # Some tags can terminate paragraph without empty line.
39 terminate = False
40 for terminatorRule in terminatorRules:
41 if terminatorRule(state, nextLine, endLine, True):
42 terminate = True
43 break
45 if terminate:
46 break
48 nextLine += 1
50 content = state.getLines(startLine, nextLine, state.blkIndent, False).strip()
52 state.line = nextLine
54 token = state.push("paragraph_open", "p", 1)
55 token.map = [startLine, state.line]
57 token = state.push("inline", "", 0)
58 token.content = content
59 token.map = [startLine, state.line]
60 token.children = []
62 token = state.push("paragraph_close", "p", -1)
64 state.parentType = oldParentType
66 return True