Buckets:
firestryker/ubuntu / LTX2.3-Studio /env /lib /python3.12 /site-packages /docutils /transforms /writer_aux.py
| # $Id: writer_aux.py 10136 2025-05-20 15:48:27Z milde $ | |
| # Author: Lea Wiemann <LeWiemann@gmail.com> | |
| # Copyright: This module has been placed in the public domain. | |
| """ | |
| Auxiliary transforms mainly to be used by Writer components. | |
| This module is called "writer_aux" because otherwise there would be | |
| conflicting imports like this one:: | |
| from docutils import writers | |
| from docutils.transforms import writers | |
| """ | |
| from __future__ import annotations | |
| __docformat__ = 'reStructuredText' | |
| from docutils import nodes, languages | |
| from docutils.transforms import Transform | |
| class Admonitions(Transform): | |
| """ | |
| Transform specific admonitions, like this: | |
| <note> | |
| <paragraph> | |
| Note contents ... | |
| into generic admonitions, like this:: | |
| <admonition classes="note"> | |
| <title> | |
| Note | |
| <paragraph> | |
| Note contents ... | |
| The admonition title is localized. | |
| """ | |
| default_priority = 920 | |
| def apply(self) -> None: | |
| language = languages.get_language(self.document.settings.language_code, | |
| self.document.reporter) | |
| for node in self.document.findall(nodes.Admonition): | |
| node_name = node.__class__.__name__ | |
| # Set class, so that we know what node this admonition came from. | |
| node['classes'].append(node_name) | |
| if not isinstance(node, nodes.admonition): | |
| # Specific admonition. Transform into a generic admonition. | |
| admonition = nodes.admonition(node.rawsource, *node.children, | |
| **node.attributes) | |
| title = nodes.title('', language.labels[node_name]) | |
| admonition.insert(0, title) | |
| node.replace_self(admonition) | |
Xet Storage Details
- Size:
- 1.83 kB
- Xet hash:
- 59784a55a9551e56d0662ac1398514ae6e3b0160e807c6911110f089d8faf25c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.