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

earwig / mwparserfromhell / 7405738327

04 Jan 2024 05:05AM UTC coverage: 99.202% (+0.1%) from 99.069%
7405738327

push

github

earwig
run-tests: with-extension env var must be set when building project

2984 of 3008 relevant lines covered (99.2%)

9.9 hits per line

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

100.0
/src/mwparserfromhell/nodes/heading.py
1
# Copyright (C) 2012-2020 Ben Kurtovic <ben.kurtovic@gmail.com>
2
#
3
# Permission is hereby granted, free of charge, to any person obtaining a copy
4
# of this software and associated documentation files (the "Software"), to deal
5
# in the Software without restriction, including without limitation the rights
6
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
# copies of the Software, and to permit persons to whom the Software is
8
# furnished to do so, subject to the following conditions:
9
#
10
# The above copyright notice and this permission notice shall be included in
11
# all copies or substantial portions of the Software.
12
#
13
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
# SOFTWARE.
20

21

22
from ._base import Node
10✔
23
from ..utils import parse_anything
10✔
24

25
__all__ = ["Heading"]
10✔
26

27

28
class Heading(Node):
10✔
29
    """Represents a section heading in wikicode, like ``== Foo ==``."""
30

31
    def __init__(self, title, level):
10✔
32
        super().__init__()
10✔
33
        self.title = title
10✔
34
        self.level = level
10✔
35

36
    def __str__(self):
10✔
37
        return ("=" * self.level) + str(self.title) + ("=" * self.level)
10✔
38

39
    def __children__(self):
10✔
40
        yield self.title
10✔
41

42
    def __strip__(self, **kwargs):
10✔
43
        return self.title.strip_code(**kwargs)
10✔
44

45
    def __showtree__(self, write, get, mark):
10✔
46
        write("=" * self.level)
10✔
47
        get(self.title)
10✔
48
        write("=" * self.level)
10✔
49

50
    @property
10✔
51
    def title(self):
10✔
52
        """The title of the heading, as a :class:`.Wikicode` object."""
53
        return self._title
10✔
54

55
    @property
10✔
56
    def level(self):
10✔
57
        """The heading level, as an integer between 1 and 6, inclusive."""
58
        return self._level
10✔
59

60
    @title.setter
10✔
61
    def title(self, value):
10✔
62
        self._title = parse_anything(value)
10✔
63

64
    @level.setter
10✔
65
    def level(self, value):
10✔
66
        value = int(value)
10✔
67
        if value < 1 or value > 6:
10✔
68
            raise ValueError(value)
10✔
69
        self._level = value
10✔
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

© 2026 Coveralls, Inc