-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathnotion.py
More file actions
33 lines (24 loc) · 764 Bytes
/
notion.py
File metadata and controls
33 lines (24 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""A directive to generate an iframe with a Notion page."""
from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx.application import Sphinx
from sphinx.util import logging
logger = logging.getLogger(__name__)
TEMPLATE: str = """
<iframe src="{url}" width="100%" height="1200" frameborder="0" allowfullscreen />
"""
class Notion(Directive):
has_content = True
final_argument_whitespace = False
def run(self):
para = nodes.raw(
"", TEMPLATE.format(url=self.content[0]), format="html"
)
return [para]
def setup(app: Sphinx):
app.add_directive("notion",Notion)
return {
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}