File: codeblock-python.md

package info (click to toggle)
python-sybil 9.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: python: 4,510; makefile: 90
file content (22 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
% invisible-code-block: python
%
%  # This could be some state setup needed to demonstrate things
% initialized = True

This fenced code block defines a function:

```python

    def prefix(text: str) -> str:
        return 'prefix: '+text
```

This MyST `code-block` directive then uses it:

```{code-block} python
    prefixed = prefix('some text')
```

<!--- invisible-code-block: python
assert prefixed == 'prefix: some text', prefixed
--->