module Emanote.Pandoc.Markdown.Syntax.Highlight ( highlightSpec, ) where import Commonmark qualified as CM import Commonmark.Inlines qualified as CM import Commonmark.Pandoc qualified as CP import Relude import Text.Pandoc.Builder qualified as B highlightSpec :: (Monad m, CM.IsInline il, HasHighlight il) => CM.SyntaxSpec m il bl highlightSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsInline il, HasHighlight il) => SyntaxSpec m il bl highlightSpec = forall a. Monoid a => a mempty { syntaxFormattingSpecs :: [FormattingSpec il] CM.syntaxFormattingSpecs = [ forall il. Char -> Bool -> Bool -> Maybe (il -> il) -> Maybe (il -> il) -> Char -> FormattingSpec il CM.FormattingSpec Char '=' Bool True Bool True forall a. Maybe a Nothing (forall a. a -> Maybe a Just forall a. HasHighlight a => a -> a highlight) Char '=' ] } class HasHighlight a where highlight :: a -> a instance HasHighlight (CP.Cm a B.Inlines) where highlight :: Cm a Inlines -> Cm a Inlines highlight Cm a Inlines il = Attr -> Inlines -> Inlines B.spanWith forall {a}. (Text, [Text], [a]) attr forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b <$> Cm a Inlines il where attr :: (Text, [Text], [a]) attr = (Text "", forall x. One x => OneItem x -> x one OneItem [Text] "highlight-inline", [])