@@ -285,9 +285,9 @@ object LaikaCustomizations {
285285 SpanDirectives .create(" math" ) {
286286 import SpanDirectives .dsl .*
287287 rawBody.map { body =>
288- RawContent (
289- NonEmptySet .of(" html" , " rss " ),
290- KaTeX (body, false )
288+ SpanSequence (
289+ RawContent ( NonEmptySet .of(" html" ), KaTeX (body, false ) ),
290+ RawContent ( NonEmptySet .of( " rss " ), KaTeX (body, false , " mathml " ) )
291291 )
292292 }
293293 }
@@ -296,10 +296,13 @@ object LaikaCustomizations {
296296 BlockDirectives .create(" math" ) {
297297 import BlockDirectives .dsl .*
298298 rawBody.map { body =>
299- RawContent (
300- NonEmptySet .of(" html" , " rss" ),
301- KaTeX (body, true ),
302- Styles (" bulma-has-text-centered" )
299+ BlockSequence (
300+ RawContent (
301+ NonEmptySet .of(" html" ),
302+ KaTeX (body, true ),
303+ Styles (" bulma-has-text-centered" )
304+ ),
305+ RawContent (NonEmptySet .of(" rss" ), KaTeX (body, true , " mathml" ))
303306 )
304307 }
305308 },
@@ -344,6 +347,13 @@ object LaikaCustomizations {
344347 val defaultRenderer = {
345348 case (fmt, Title (_, _)) =>
346349 " " // don't render title b/c it is in the RSS metadata
350+ case (fmt, RawContent (formats, content, options)) =>
351+ if (formats.contains(" rss" )) // only render content designated for RSS
352+ HTML .defaultRenderer(
353+ fmt,
354+ RawContent (NonEmptySet .of(" html" ), content, options)
355+ )
356+ else " "
347357 case (fmt, elem) => HTML .defaultRenderer(fmt, elem)
348358 }
349359
@@ -438,12 +448,18 @@ object KaTeX {
438448 ctx.getBindings(" js" ).getMember(" katex" )
439449 }
440450
441- def apply (latex : String , displayMode : Boolean = false ): String =
451+ def apply (
452+ latex : String ,
453+ displayMode : Boolean = false ,
454+ output : String = " htmlAndMathml"
455+ ): String =
442456 synchronized {
457+ // https://katex.org/docs/options
443458 val options = Map (
444459 " throwOnError" -> true ,
445460 " strict" -> true ,
446- " displayMode" -> displayMode
461+ " displayMode" -> displayMode,
462+ " output" -> output
447463 )
448464 katex.invokeMember(" renderToString" , latex, options.asJava).asString
449465 }
0 commit comments