all2md.options.dokuwiki
Configuration options for DokuWiki parsing and rendering.
This module defines options for parsing DokuWiki markup to AST and rendering AST to DokuWiki format.
- class all2md.options.dokuwiki.DokuWikiOptions
Bases:
BaseRendererOptionsConfiguration options for DokuWiki rendering.
This dataclass contains settings for rendering AST documents as DokuWiki markup, suitable for DokuWiki-based wikis.
- Parameters:
use_html_for_unsupported (bool, default True) – Whether to use HTML tags as fallback for unsupported elements. When True, unsupported formatting uses HTML tags (e.g.,
<del>strikethrough</del>). When False, unsupported formatting is stripped.monospace_fence (bool, default False) – Whether to use fence syntax for monospace text. When True, inline code uses
<code>text</code>. When False, inline code uses double single quotes (DokuWiki native).html_passthrough_mode ({"pass-through", "escape", "drop", "sanitize"}, default "pass-through") – How to handle HTMLBlock and HTMLInline nodes: - “pass-through”: Pass through unchanged (use only with trusted content) - “escape”: HTML-escape the content - “drop”: Remove HTML content entirely - “sanitize”: Remove dangerous elements/attributes (requires bleach for best results)
comment_mode ({"html", "visible", "ignore"}, default "html") – How to render Comment and CommentInline AST nodes: - “html”: Use HTML/C-style comments (default) - “visible”: Render as visible text - “ignore”: Skip comments entirely
Examples
- Basic DokuWiki rendering:
>>> from all2md.ast import Document, Heading, Text >>> from all2md.renderers.dokuwiki import DokuWikiRenderer >>> from all2md.options.dokuwiki import DokuWikiOptions >>> doc = Document(children=[ ... Heading(level=1, content=[Text(content="Title")]) ... ]) >>> options = DokuWikiOptions() >>> renderer = DokuWikiRenderer(options) >>> wiki_text = renderer.render_to_string(doc)
- use_html_for_unsupported: bool = True
- monospace_fence: bool = False
- html_passthrough_mode: Literal['pass-through', 'escape', 'drop', 'sanitize'] = 'escape'
- comment_mode: Literal['html', 'visible', 'ignore'] = 'html'
- __init__(fail_on_resource_errors: bool = False, max_asset_size_bytes: int = 52428800, metadata_policy: MetadataRenderPolicy = <factory>, creator: str | None = 'all2md', use_html_for_unsupported: bool = True, monospace_fence: bool = False, html_passthrough_mode: HtmlPassthroughMode = 'escape', comment_mode: DokuWikiCommentMode = 'html') None
- class all2md.options.dokuwiki.DokuWikiParserOptions
Bases:
BaseParserOptionsConfiguration options for DokuWiki-to-AST parsing.
This dataclass contains settings specific to parsing DokuWiki markup documents into AST representation using custom regex-based parsing.
- Parameters:
parse_plugins (bool, default False) – Whether to parse plugin syntax (e.g.,
<WRAP>,<button>) or strip them. When True, plugin tags are converted to HTMLInline/HTMLBlock nodes. When False, plugin tags are completely removed from the output.strip_comments (bool, default True) – Whether to strip comments from the output. Strips both C-style (
/* ... */) and HTML (<!-- ... -->) comments. When True, comments are removed completely. When False, comments are preserved as HTMLInline nodes.parse_interwiki (bool, default True) – Whether to parse interwiki links (e.g.,
[[wp>Article]]). When True, interwiki links are preserved in Link nodes. When False, interwiki syntax is treated as regular internal links.html_passthrough_mode ({"pass-through", "escape", "drop", "sanitize"}, default "escape") – How to handle inline HTML in DokuWiki markup: - “pass-through”: Preserve HTML unchanged (use only with trusted content) - “escape”: HTML-escape the content to display as text - “drop”: Remove HTML content entirely - “sanitize”: Remove dangerous elements/attributes
Examples
- Basic usage:
>>> options = DokuWikiParserOptions() >>> parser = DokuWikiParser(options)
- Parse plugin syntax as HTML:
>>> options = DokuWikiParserOptions(parse_plugins=True) >>> parser = DokuWikiParser(options)
- parse_plugins: bool = False
- strip_comments: bool = True
- parse_interwiki: bool = True
- html_passthrough_mode: Literal['pass-through', 'escape', 'drop', 'sanitize'] = 'escape'
- __init__(extract_metadata: bool = False, parse_plugins: bool = False, strip_comments: bool = True, parse_interwiki: bool = True, html_passthrough_mode: Literal['pass-through', 'escape', 'drop', 'sanitize'] = 'escape') None