filters ¤
This module contains Jinja filters.
Functions:
- console_width –
Return current console width.
- do_body –
Get the body of a text.
- do_escape –
Escape (HTML) given text.
- do_firstline –
Get the first line of a text.
- do_firstword –
Get the first word of a string.
- do_format –
Override Jinja's format filter to use format method instead of % operator.
- do_groffauto –
Convert a string to the Groff format.
- do_groffautoemphasis –
Automatically mark uppercase words as Groff emphasis.
- do_groffautoescape –
Automatically Groff-escape dashes, single/double quotes, dots and dollar signs in a string.
- do_groffautostrong –
Automatically mark words starting with
-
or--
as Groff strong. - do_groffemphasis –
Mark a string as Groff emphasis.
- do_groffstrong –
Mark a string as Groff strong.
- do_groupby –
Override Jinja's groupby filter to add un(sort) option.
- do_smartwrap –
Smartly wrap the given text.
console_width ¤
Return current console width.
Parameters:
- default (
int
, default:80
) –The default value if width cannot be retrieved.
Returns:
-
int
–The console width.
Source code in src/shellman/templates/filters.py
148 149 150 151 152 153 154 155 156 157 158 159 |
|
do_body ¤
Get the body of a text.
Parameters:
Returns:
-
str | None
–The text's body.
Source code in src/shellman/templates/filters.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
do_escape ¤
Escape (HTML) given text.
Parameters:
- except_starts_with (
list[str] | None
, default:None
) –Each line starting with at least one of the prefixes listed in this parameter will not be escaped.
Returns:
-
str
–The escaped text.
Source code in src/shellman/templates/filters.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
do_firstline ¤
Get the first line of a text.
Parameters:
Returns:
-
str | None
–The text's first line.
Source code in src/shellman/templates/filters.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
do_firstword ¤
Get the first word of a string.
Parameters:
Returns:
-
str
–The string's first word.
Source code in src/shellman/templates/filters.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
do_format ¤
Override Jinja's format filter to use format method instead of % operator.
Parameters:
- string (
str
) –The string to format.
- *args (
Any
, default:()
) –Arguments passed to
str.format
. - **kwargs (
Any
, default:{}
) –Keyword arguments passed to
str.format
.
Returns:
-
str
–The formatted string.
Source code in src/shellman/templates/filters.py
227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
do_groffauto ¤
Convert a string to the Groff format.
Parameters:
Returns:
-
str
–A Groff string.
Source code in src/shellman/templates/filters.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
do_groffautoemphasis ¤
Automatically mark uppercase words as Groff emphasis.
Parameters:
- string (
str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/templates/filters.py
55 56 57 58 59 60 61 62 63 64 |
|
do_groffautoescape ¤
Automatically Groff-escape dashes, single/double quotes, dots and dollar signs in a string.
Parameters:
- string (
str
) –The string to escape.
Returns:
-
str
–The escaped string.
Source code in src/shellman/templates/filters.py
19 20 21 22 23 24 25 26 27 28 |
|
do_groffautostrong ¤
Automatically mark words starting with -
or --
as Groff strong.
Parameters:
- string (
str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/templates/filters.py
67 68 69 70 71 72 73 74 75 76 |
|
do_groffemphasis ¤
Mark a string as Groff emphasis.
Parameters:
- string (
str
) –The string to convert
Returns:
-
str
–The updated string.
Source code in src/shellman/templates/filters.py
43 44 45 46 47 48 49 50 51 52 |
|
do_groffstrong ¤
Mark a string as Groff strong.
Parameters:
- string (
str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/templates/filters.py
31 32 33 34 35 36 37 38 39 40 |
|
do_groupby ¤
do_groupby(
environment: Environment,
value: Sequence[Any],
attribute: str,
*,
sort: bool = True
) -> list[tuple[str, list[Any]]]
Override Jinja's groupby filter to add un(sort) option.
Parameters:
- environment (
Environment
) –Passed by Jinja.
- value (
Sequence[Any]
) –The value to group.
- attribute (
str
) –The attribute to use for grouping/sorting.
Returns:
Source code in src/shellman/templates/filters.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
do_smartwrap ¤
do_smartwrap(
text: str,
indent: int = 4,
width: int | None = None,
*,
indentfirst: bool = True
) -> str
Smartly wrap the given text.
Parameters:
- text (
str
) –The text to wrap.
- indent (
int
, default:4
) –The indentation to use (number of spaces).
- width (
int | None
, default:None
) –The desired text width.
- indentfirst (
bool
, default:True
) –Whether to indent the first line too.
Returns:
-
str
–The wrapped text.
Source code in src/shellman/templates/filters.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|