- Add\Rework UI - Add Split Table and Listing - Add Support Customazeble schems
This commit is contained in:
@@ -15,12 +15,13 @@ from .renderable.list import List
|
||||
from .renderable.toc import ToC
|
||||
from .renderable.diagram import DiagramFigure
|
||||
from .label_pass import resolve_reference
|
||||
from .diagram_renderer import DIAGRAM_LANGS
|
||||
from .diagram_renderer import is_diagram_lang
|
||||
|
||||
|
||||
class RenderableFactory:
|
||||
def __init__(self, parent: Parented):
|
||||
def __init__(self, parent: Parented, hr_pagebreak: bool = False):
|
||||
self._parent = parent
|
||||
self._hr_pagebreak = hr_pagebreak
|
||||
|
||||
@singledispatchmethod
|
||||
def create(self, marko_element: extended_markdown.BlockElement,
|
||||
@@ -43,7 +44,12 @@ class RenderableFactory:
|
||||
elif isinstance(child, extended_markdown.CodeSpan):
|
||||
paragraph_or_link.add_run(child.children, is_italic=True)
|
||||
elif isinstance(child, extended_markdown.Image):
|
||||
caption = CaptionInfo(child.unique_name, child.title)
|
||||
caption = CaptionInfo(
|
||||
child.unique_name,
|
||||
child.title,
|
||||
getattr(child, "with_listing", False),
|
||||
getattr(child, "landscape", False),
|
||||
)
|
||||
paragraph_or_link.add_image(child.dest, caption)
|
||||
elif isinstance(child, extended_markdown.LineBreak):
|
||||
pass
|
||||
@@ -82,7 +88,7 @@ class RenderableFactory:
|
||||
def _(self, marko_code_block: extended_markdown.FencedCode, caption_info: CaptionInfo):
|
||||
lang = (marko_code_block.lang or "").strip().lower()
|
||||
source = marko_code_block.children[0].children
|
||||
if lang in DIAGRAM_LANGS:
|
||||
if is_diagram_lang(lang):
|
||||
return DiagramFigure(
|
||||
self._parent,
|
||||
lang,
|
||||
@@ -98,7 +104,7 @@ class RenderableFactory:
|
||||
def _(self, marko_code_block: extended_markdown.CodeBlock, caption_info: CaptionInfo):
|
||||
lang = (getattr(marko_code_block, "lang", "") or "").strip().lower()
|
||||
source = marko_code_block.children[0].children
|
||||
if lang in DIAGRAM_LANGS:
|
||||
if is_diagram_lang(lang):
|
||||
return DiagramFigure(
|
||||
self._parent,
|
||||
lang,
|
||||
@@ -161,3 +167,16 @@ class RenderableFactory:
|
||||
def _(self, marko_toc: extended_markdown.TOC, caption_info: CaptionInfo):
|
||||
toc = ToC(self._parent)
|
||||
return toc
|
||||
|
||||
@create.register
|
||||
def _(self, marko_hr: extended_markdown.ThematicBreak, caption_info: CaptionInfo):
|
||||
if self._hr_pagebreak:
|
||||
from .renderable.page_break import PageBreak
|
||||
return PageBreak(self._parent)
|
||||
paragraph = Paragraph(self._parent)
|
||||
paragraph.add_run(
|
||||
"ThematicBreak is not supported",
|
||||
color=RGBColor.from_string("ff0000"),
|
||||
)
|
||||
logging.warning("ThematicBreak is not supported")
|
||||
return paragraph
|
||||
|
||||
Reference in New Issue
Block a user