From 82c866487f8a70121c100efa86d6f93dcedd1056 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Dec 2023 15:38:48 -0800 Subject: [PATCH] Export alertSvgText. --- commonmark-extensions/src/Commonmark/Extensions/Alerts.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commonmark-extensions/src/Commonmark/Extensions/Alerts.hs b/commonmark-extensions/src/Commonmark/Extensions/Alerts.hs index d98d584..5c345e2 100644 --- a/commonmark-extensions/src/Commonmark/Extensions/Alerts.hs +++ b/commonmark-extensions/src/Commonmark/Extensions/Alerts.hs @@ -6,6 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} module Commonmark.Extensions.Alerts ( alertSpec + , alertSvgText , AlertType(..) , HasAlerts(..) ) @@ -22,6 +23,7 @@ import Data.Dynamic import Data.Tree import Text.Parsec import Data.Text (Text) +import qualified Data.Text.Lazy as TL alertSpec :: (Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasAlerts il bl) @@ -103,6 +105,9 @@ alertSvg alertType = addAttribute ("d", svgPath alertType) (htmlBlock "path" (Just mempty)) +alertSvgText :: AlertType -> Text +alertSvgText = TL.toStrict . renderHtml . alertSvg + svgPath :: AlertType -> Text svgPath NoteAlert = "M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z" svgPath TipAlert = "M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"