summaryrefslogtreecommitdiff
path: root/Pancake/Rendering.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-11-07 21:37:54 +0300
committerdefanor <defanor@uberspace.net>2017-11-07 22:17:34 +0300
commit1d8a5140e3ce03d9fa6b9c63a6621ab3ab64eb4c (patch)
treecd3f131567cc0ac9c86b752f22f25e3cd319ce45 /Pancake/Rendering.hs
parent5301bb027cf56a0e1148808f11510e7fcc298b86 (diff)
Let Emacs to render subscripts, superscripts, strikethrough
That is, add `Styled` constructors for those.
Diffstat (limited to 'Pancake/Rendering.hs')
-rw-r--r--Pancake/Rendering.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs
index 7b219b9..e88a9ad 100644
--- a/Pancake/Rendering.hs
+++ b/Pancake/Rendering.hs
@@ -44,6 +44,9 @@ data Styled = Plain String
| Underline Styled
| Bold Styled
| Emph Styled
+ | Strikethrough Styled
+ | Subscript Styled
+ | Superscript Styled
| Fg Color Styled
| Denote Denotation Styled
deriving (Show, Eq)
@@ -178,6 +181,9 @@ unstyled = concatMap unstyled'
unstyled' (Underline s) = unstyled' s
unstyled' (Bold s) = unstyled' s
unstyled' (Emph s) = unstyled' s
+ unstyled' (Strikethrough s) = unstyled' s
+ unstyled' (Subscript s) = unstyled' s
+ unstyled' (Superscript s) = unstyled' s
unstyled' (Fg _ s) = unstyled' s
unstyled' (Denote _ s) = unstyled' s
@@ -199,6 +205,9 @@ fitLines maxLen inlineBits = concatMap (map reverse . fitWords [] 0) inlineBits
splitStyled (Underline s) = map Underline $ splitStyled s
splitStyled (Bold s) = map Bold $ splitStyled s
splitStyled (Emph s) = map Emph $ splitStyled s
+ splitStyled (Strikethrough s) = map Strikethrough $ splitStyled s
+ splitStyled (Subscript s) = map Subscript $ splitStyled s
+ splitStyled (Superscript s) = map Superscript $ splitStyled s
splitStyled (Fg c s) = map (Fg c) $ splitStyled s
splitStyled (Denote d s) = map (Denote d) $ splitStyled s
fitWords :: [Styled] -> Int -> [Styled] -> [StyledLine]
@@ -248,9 +257,9 @@ readInline (P.Str s)
| otherwise = pure [fromString s]
readInline (P.Emph s) = concatMap (map Emph) <$> mapM readInline s
readInline (P.Strong s) = concatMap (map Bold) <$> mapM readInline s
-readInline (P.Strikeout s) = wrappedInlines "-" "-" s
-readInline (P.Superscript s) = wrappedInlines "^{" "}" s
-readInline (P.Subscript s) = wrappedInlines "_{" "}" s
+readInline (P.Strikeout s) = concatMap (map Strikethrough) <$> mapM readInline s
+readInline (P.Superscript s) = concatMap (map Superscript) <$> mapM readInline s
+readInline (P.Subscript s) = concatMap (map Subscript) <$> mapM readInline s
readInline (P.SmallCaps s) = wrappedInlines "\\sc{" "}" s
readInline (P.Quoted P.SingleQuote s) = wrappedInlines "‘" "’" s
readInline (P.Quoted P.DoubleQuote s) = wrappedInlines "“" "”" s