Skip to content

Commit

Permalink
prevent invalid XSL-FO when rendering mermaid warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshalm committed Nov 11, 2024
1 parent fd37607 commit 7a10dab
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,24 @@ private[helium] object HeliumRenderOverrides {
)
}

private def mermaidWarning(format: String): Block = {
val msg = s"Mermaid diagrams are not supported for $format output"
Paragraph(RuntimeMessage(MessageLevel.Warning, msg))
}

def forPDF: PartialFunction[(TagFormatter, Element), String] = {
case (fmt, b @ BlockSequence(content, opt)) if opt.styles.contains("callout") =>
fmt.blockContainer(b, SpanSequence(icon(opt).toSeq, Styles("icon")) +: content)
case (fmt, CodeBlock("mermaid", _, _, _)) =>
fmt.child(
RuntimeMessage(MessageLevel.Warning, "Mermaid diagrams are not supported for PDF output")
)
fmt.child(mermaidWarning("PDF"))
}

def forEPUB: PartialFunction[(TagFormatter, Element), String] = {
case (fmt, BlockSequence(content, opt)) if opt.styles.contains("callout") =>
val callout = icon(opt).map(SpanSequence(_)).toSeq ++ content
fmt.indentedElement("div", BlockSequence(callout).withOptions(opt))
case (fmt, CodeBlock("mermaid", _, _, _)) =>
fmt.child(
RuntimeMessage(MessageLevel.Warning, "Mermaid diagrams are not supported for EPUB output")
)
fmt.child(mermaidWarning("EPUB"))
}

}

0 comments on commit 7a10dab

Please sign in to comment.