space-workshop/extensions/slide_meta/directive.py
Kai Vogelgesang 489ddd75b9
Init
2025-09-18 18:33:58 +02:00

17 lines
430 B
Python

from sphinx.util.docutils import SphinxDirective
from docutils import nodes
class CellMetaNode(nodes.Element):
def html(self):
metadata = self["metadata"]
return f'<script type="application/json" data-cell-meta="">{metadata}</script>'
class CellMetaDirective(SphinxDirective):
has_content = True
def run(self):
joined = "".join(self.content)
return [CellMetaNode(metadata=joined)]