181 | | The default, coding highlighting and MIME-type processors support the argument `lineno` for adding line numbering to the code block. When a value is specified, as in `lineno=3`, the numbering will start at the specified value. When used in combination with the `lineno` argument, the `marks` argument is also supported for highlighting lines. A single line number, set of line numbers and range of line numbers are allowed. For example, `marks=3`, `marks=3-6`, `marks=3,5,7` and `marks=3-5,7` are all allowed. The specified values are relative to the numbered lines, so if `lineno=2` is specified to start the line numbering at 2, `marks=2` will result in the first line being highlighted. |
| 181 | Since 1.1.2 the default, coding highlighting and MIME-type processors support the argument `lineno` for adding line numbering to the code block. When a value is specified, as in `lineno=3`, the numbering will start at the specified value. When used in combination with the `lineno` argument, the `marks` argument is also supported for highlighting lines. A single line number, set of line numbers and range of line numbers are allowed. For example, `marks=3`, `marks=3-6`, `marks=3,5,7` and `marks=3-5,7` are all allowed. The specified values are relative to the numbered lines, so if `lineno=2` is specified to start the line numbering at 2, `marks=2` will result in the first line being highlighted. |
| 249 | {{{#!comment |
| 250 | Uncomment for Trac 1.2 release. |
| 251 | {{{ |
| 252 | {{{#!python lineno=3 marks=3,5-6,8 |
| 253 | def expand_markup(stream, ctxt=None): |
| 254 | """A Genshi stream filter for expanding `genshi.Markup` events. |
| 255 | |
| 256 | Note: Expansion may not be possible if the fragment is badly |
| 257 | formed, or partial. |
| 258 | """ |
| 259 | for event in stream: |
| 260 | if isinstance(event[1], Markup): |
| 261 | try: |
| 262 | for subevent in HTML(event[1]): |
| 263 | yield subevent |
| 264 | except ParseError: |
| 265 | yield event |
| 266 | else: |
| 267 | yield event |
| 268 | }}} |
| 269 | }}} |
| 270 | Line numbers can be added to code blocks and lines can be highlighted //(since 1.1.2)//. |
| 271 | {{{#!python lineno=3 marks=3,5-6,8 |
| 272 | def expand_markup(stream, ctxt=None): |
| 273 | """A Genshi stream filter for expanding `genshi.Markup` events. |
| 274 | |
| 275 | Note: Expansion may not be possible if the fragment is badly |
| 276 | formed, or partial. |
| 277 | """ |
| 278 | for event in stream: |
| 279 | if isinstance(event[1], Markup): |
| 280 | try: |
| 281 | for subevent in HTML(event[1]): |
| 282 | yield subevent |
| 283 | except ParseError: |
| 284 | yield event |
| 285 | else: |
| 286 | yield event |
| 287 | }}} |
| 288 | }}} |