mdoc-0.2.0.0: src/Mdoc/Syntax/TroffMacro.hs
-- |
--
-- Module : Mdoc.Syntax.TroffMacro
-- Copyright : (c) 2026 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Mdoc.Syntax.TroffMacro
( TroffMacro (..)
-- * Pretty
, prettyTroffMacro
) where
import Mdoc.Prelude
import Mdoc.Pretty
data TroffMacro
= TroffMacroDefineS Text (Maybe Text)
| TroffMacroDefine Text (Maybe Text)
| TroffMacroCall Text [Text]
| TroffMacroEnd Text
deriving stock (Eq, Show)
prettyTroffMacro :: TroffMacro -> Doc Ann
prettyTroffMacro = \case
TroffMacroDefineS name mValue ->
annotate AnnKeyword ".ds"
<+> pretty name
<> maybe "" ((" " <>) . pretty) mValue
TroffMacroDefine name mEnd ->
annotate AnnKeyword ".de"
<+> pretty name
<> maybe "" ((" " <>) . pretty) mEnd
TroffMacroCall name args ->
annotate AnnKeyword (pretty $ "." <> name)
<> hsep (punctuate " " (map pretty args))
TroffMacroEnd t -> pretty t
instance Pretty TroffMacro where
pretty = unAnnotate . prettyTroffMacro