@@ -285,8 +285,12 @@ object LaikaCustomizations {
285285 SpanDirectives .create(" math" ) {
286286 import SpanDirectives .dsl .*
287287 rawBody.evalMap { body =>
288- KaTeX (body, false ).map(katexStr =>
289- RawContent (NonEmptySet .of(" html" , " rss" ), katexStr)
288+ (KaTeX (body, false ), KaTeX (body, false , " mathml" )).mapN(
289+ (katexStr, mathmlStr) =>
290+ SpanSequence (
291+ RawContent (NonEmptySet .of(" html" ), katexStr),
292+ RawContent (NonEmptySet .of(" rss" ), mathmlStr)
293+ )
290294 )
291295 }
292296 }
@@ -295,12 +299,16 @@ object LaikaCustomizations {
295299 BlockDirectives .create(" math" ) {
296300 import BlockDirectives .dsl .*
297301 rawBody.evalMap { body =>
298- KaTeX (body, true ).map(katexStr =>
299- RawContent (
300- NonEmptySet .of(" html" , " rss" ),
301- katexStr,
302- Styles (" bulma-has-text-centered" )
303- )
302+ (KaTeX (body, true ), KaTeX (body, true , " mathml" )).mapN(
303+ (katexStr, mathmlStr) =>
304+ BlockSequence (
305+ RawContent (
306+ NonEmptySet .of(" html" , " rss" ),
307+ katexStr,
308+ Styles (" bulma-has-text-centered" )
309+ ),
310+ RawContent (NonEmptySet .of(" rss" ), mathmlStr)
311+ )
304312 )
305313 }
306314 },
@@ -345,6 +353,13 @@ object LaikaCustomizations {
345353 val defaultRenderer = {
346354 case (fmt, Title (_, _)) =>
347355 " " // don't render title b/c it is in the RSS metadata
356+ case (fmt, RawContent (formats, content, options)) =>
357+ if (formats.contains(" rss" )) // only render content designated for RSS
358+ HTML .defaultRenderer(
359+ fmt,
360+ RawContent (NonEmptySet .of(" html" ), content, options)
361+ )
362+ else " "
348363 case (fmt, elem) => HTML .defaultRenderer(fmt, elem)
349364 }
350365
@@ -441,13 +456,16 @@ object KaTeX {
441456
442457 def apply (
443458 latex : String ,
444- displayMode : Boolean = false
459+ displayMode : Boolean = false ,
460+ output : String = " htmlAndMathml"
445461 ): Either [String , String ] =
446462 synchronized {
463+ // https://katex.org/docs/options
447464 val options = Map (
448465 " throwOnError" -> true ,
449466 " strict" -> true ,
450- " displayMode" -> displayMode
467+ " displayMode" -> displayMode,
468+ " output" -> output
451469 ).asJava
452470 try {
453471 Right (katex.invokeMember(" renderToString" , latex, options).asString)
0 commit comments