add <mark> syntax *hello*

This commit is contained in:
Rhiannon Morris 2023-10-30 09:43:05 +01:00
parent abd27eebe9
commit 1136cff702

View file

@ -13,20 +13,22 @@ import qualified Data.Text as Text
spans :: Vars => Inline -> IO Inline
spans = \case
Code attrs txt
| Just ('\\', txt') <- Text.uncons txt -> pure $ Code attrs txt'
| Just ('\\', txt') <- Text.uncons txt -> pure $ Code attrs txt'
| Just txt' <- enclosed "" "" txt -> pure $ ipaA txt'
| Just txt' <- enclosed "//" "//" txt -> pure $ ipaA txt'
| Just _ <- enclosed "/" "/" txt -> pure $ ipaB txt
| Just _ <- enclosed "[" "]" txt -> pure $ ipaN txt
| Just txt' <- enclosed "{" "}" txt -> lang txt'
| Just txt' <- enclosed "!" "!" txt -> pure $ abbr txt'
| Just txt' <- enclosed "*" "*" txt -> pure $ mark txt'
i -> pure i
ipaA, ipaB, ipaN, abbr :: Text -> Inline
ipaA, ipaB, ipaN, abbr, mark :: Text -> Inline
ipaA = Span (cls ["ipa", "ipa-arch"]) . text' . surround ""
ipaB = Span (cls ["ipa", "ipa-broad"]) . text'
ipaN = Span (cls ["ipa", "ipa-narrow"]) . text'
abbr = Span (cls ["abbr"]) . text' . endash
mark txt = RawInline "html" $ "<mark>" <> txt <> "</mark>"
surround :: Text -> Text -> Text
surround s txt = s <> txt <> s