text
SpacedText
Representation of text with newlines before or after.
Source code in mkreports/md/text.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
__init__(text='', req_nl=(0, 0))
Initialize the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
Text
|
The text to print. |
''
|
req_nl |
Tuple[int, int]
|
Number of newlines before and after to ensure. |
(0, 0)
|
Source code in mkreports/md/text.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
__str__()
Return a formatted str.
We assume that 3 newlines are before and after. That should be enough.
Source code in mkreports/md/text.py
55 56 57 58 59 60 61 |
|
_needed_nl_between(first, second)
Calculates the number of newlines needed between two text objects.
Source code in mkreports/md/text.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
count_newlines(x, before=True)
Count the number of newlines from front or back.
Here all newlines are counted while ignoring whitespace. Stop at first character that is not newline or whitespace. If there are no non-newline or whitespace characters, return infinite number of newlines.
Source code in mkreports/md/text.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|