• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rafalp / Misago / 14252691788

03 Apr 2025 09:01PM UTC coverage: 97.097% (-0.08%) from 97.173%
14252691788

push

github

web-flow
Replace default parser with `markdown-it-py` (#1901)

1902 of 1969 new or added lines in 66 files covered. (96.6%)

20 existing lines in 7 files now uncovered.

68959 of 71021 relevant lines covered (97.1%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/misago/parser/plugins/hrbbcode.py
1
import re
1✔
2

3
from markdown_it import MarkdownIt
1✔
4
from markdown_it.rules_block.state_block import StateBlock
1✔
5

6

7
def hr_bbcode_plugin(md: MarkdownIt):
1✔
8
    md.block.ruler.before(
1✔
9
        "paragraph",
10
        "hr_bbcode",
11
        hr_bbcode_rule,
12
        {"alt": ["paragraph"]},
13
    )
14

15

16
HR = re.compile(r"^ *\[hr\]( *\[hr\])* *$", re.IGNORECASE)
1✔
17

18

19
def hr_bbcode_rule(
1✔
20
    state: StateBlock, startLine: int, endLine: int, silent: bool
21
) -> bool:
22
    if state.is_code_block(startLine):
1✔
NEW
23
        return False
×
24

25
    start = state.bMarks[startLine] + state.tShift[startLine]
1✔
26
    maximum = state.eMarks[startLine]
1✔
27

28
    line = state.src[start:maximum]
1✔
29

30
    if not HR.match(line):
1✔
31
        return False
1✔
32

33
    if silent:
1✔
34
        return True
1✔
35

36
    state.line = startLine + 1
1✔
37

38
    if not state.tokens or state.tokens[-1].type not in ("hr", "hr_bbcode"):
1✔
39
        token = state.push("hr_bbcode", "hr", 0)
1✔
40
        token.map = [startLine, state.line]
1✔
41
        token.markup = "[hr]"
1✔
42

43
    return True
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc