{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE PatternGuards #-}
module Text.CSL.Output.Pandoc
( renderPandoc
, renderPandoc'
, headInline
, initInline
, lastInline
, tailInline
, tailFirstInlineStr
, toCapital
) where
import Prelude
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Text.CSL.Style
import Text.CSL.Util (headInline, initInline, lastInline,
proc, proc', tailFirstInlineStr,
tailInline, toCapital)
import Text.Pandoc.Definition
import Text.Pandoc.XML (fromEntities)
renderPandoc :: Style -> Formatted -> [Inline]
renderPandoc :: Style -> Formatted -> [Inline]
renderPandoc sty :: Style
sty
= ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall a b. (Typeable a, Data b) => (a -> a) -> b -> b
proc (Style -> [Inline] -> [Inline]
convertQuoted Style
sty) ([Inline] -> [Inline])
-> (Formatted -> [Inline]) -> Formatted -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall a b. (Typeable a, Data b) => (a -> a) -> b -> b
proc' (Style -> [Inline] -> [Inline]
clean' Style
sty) ([Inline] -> [Inline])
-> (Formatted -> [Inline]) -> Formatted -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> [Inline]
flipFlop ([Inline] -> [Inline])
-> (Formatted -> [Inline]) -> Formatted -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Inline] -> [Inline]
fixBreaks ([Inline] -> [Inline])
-> (Formatted -> [Inline]) -> Formatted -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Formatted -> [Inline]
unFormatted
fixBreaks :: [Inline] -> [Inline]
fixBreaks :: [Inline] -> [Inline]
fixBreaks =
(Inline -> Bool) -> [Inline] -> [Inline]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Inline -> Inline -> Bool
forall a. Eq a => a -> a -> Bool
== Inline
LineBreak) ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> [Inline]
forall a. [a] -> [a]
reverse ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> Bool) -> [Inline] -> [Inline]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Inline -> Inline -> Bool
forall a. Eq a => a -> a -> Bool
== Inline
LineBreak) ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> [Inline]
forall a. [a] -> [a]
reverse
renderPandoc' :: Style -> (Formatted, String) -> Block
renderPandoc' :: Style -> (Formatted, String) -> Block
renderPandoc' sty :: Style
sty (form :: Formatted
form, citId :: String
citId) = Attr -> [Block] -> Block
Div (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ "ref-" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
citId, [], []) [[Inline] -> Block
Para ([Inline] -> Block) -> [Inline] -> Block
forall a b. (a -> b) -> a -> b
$ Style -> Formatted -> [Inline]
renderPandoc Style
sty Formatted
form]
clean' :: Style -> [Inline] -> [Inline]
clean' :: Style -> [Inline] -> [Inline]
clean' _ [] = []
clean' sty :: Style
sty (i :: Inline
i:is :: [Inline]
is) =
case Inline
iInline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
:[Inline]
is of
(Str "" : rest :: [Inline]
rest) -> Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
rest
(Str xs :: Text
xs : Str ys :: Text
ys : rest :: [Inline]
rest) -> Style -> [Inline] -> [Inline]
clean' Style
sty ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall a b. (a -> b) -> a -> b
$ Text -> Inline
Str (Text
xs Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ys) Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline]
rest
(Link a1 :: Attr
a1 lab1 :: [Inline]
lab1 (Text -> Maybe (Char, Text)
T.uncons -> Just ('#',r1 :: Text
r1), "")
: Str "\8211" : Link a2 :: Attr
a2 lab2 :: [Inline]
lab2 (Text -> Maybe (Char, Text)
T.uncons -> Just ('#',r2 :: Text
r2), "") : rest :: [Inline]
rest)
| Text
r1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
r2, Attr
a1 Attr -> Attr -> Bool
forall a. Eq a => a -> a -> Bool
== Attr
a2 ->
Attr -> [Inline] -> Target -> Inline
Link Attr
a1 ([Inline]
lab1 [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [Text -> Inline
Str "\8211"] [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [Inline]
lab2) (Char -> Text -> Text
T.cons '#' Text
r1, "") Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
rest
(Span ("",[],[]) inls :: [Inline]
inls : _) -> [Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
is
(Span ("",["csl-inquote"],kvs :: [Target]
kvs) inls :: [Inline]
inls : _) ->
let isOuter :: Bool
isOuter = Text -> [Target] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup "position" [Target]
kvs Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just "outer"
in case [Inline] -> String
headInline [Inline]
is of
[x :: Char
x] -> if Char
x Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (".," :: String) Bool -> Bool -> Bool
&& Style -> Bool
isPunctuationInQuote Style
sty
then if [Inline] -> String
lastInline [Inline]
inls String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [".",",",";",":","!","?"]
then Bool -> [Inline] -> [Inline]
quoted Bool
isOuter [Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++
Style -> [Inline] -> [Inline]
clean' Style
sty ([Inline] -> [Inline]
tailInline [Inline]
is)
else Bool -> [Inline] -> [Inline]
quoted Bool
isOuter ([Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [Text -> Inline
Str (Char -> Text
T.singleton Char
x)]) [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++
Style -> [Inline] -> [Inline]
clean' Style
sty ([Inline] -> [Inline]
tailInline [Inline]
is)
else Bool -> [Inline] -> [Inline]
quoted Bool
isOuter [Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
is
_ -> Bool -> [Inline] -> [Inline]
quoted Bool
isOuter [Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
is
(Quoted t :: QuoteType
t inls :: [Inline]
inls : _) -> Bool -> [Inline] -> [Inline]
quoted (QuoteType
t QuoteType -> QuoteType -> Bool
forall a. Eq a => a -> a -> Bool
== QuoteType
DoubleQuote) [Inline]
inls [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
is
_ -> if [Inline] -> String
lastInline [Inline
i] String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== [Inline] -> String
headInline [Inline]
is Bool -> Bool -> Bool
&& Bool
isPunct
then Inline
i Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: Style -> [Inline] -> [Inline]
clean' Style
sty ([Inline] -> [Inline]
tailInline [Inline]
is)
else Inline
i Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: Style -> [Inline] -> [Inline]
clean' Style
sty [Inline]
is
where
isPunct :: Bool
isPunct = (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (".,;:!? " :: String)) (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ [Inline] -> String
headInline [Inline]
is
locale :: Locale
locale = case Style -> [Locale]
styleLocale Style
sty of
(x :: Locale
x:_) -> Locale
x
[] -> String -> String -> [Option] -> [CslTerm] -> [Element] -> Locale
Locale [] [] [] [] []
getQuote :: String -> Text -> Inline
getQuote s :: String
s d :: Text
d = case [CslTerm
term | CslTerm
term <- Locale -> [CslTerm]
localeTerms Locale
locale, CslTerm -> String
cslTerm CslTerm
term String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
s] of
(x :: CslTerm
x:_) -> Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ CslTerm -> String
termSingular CslTerm
x
_ -> Text -> Inline
Str Text
d
openQuoteOuter :: Inline
openQuoteOuter = String -> Text -> Inline
getQuote "open-quote" "“"
openQuoteInner :: Inline
openQuoteInner = String -> Text -> Inline
getQuote "open-inner-quote" "‘"
closeQuoteOuter :: Inline
closeQuoteOuter = String -> Text -> Inline
getQuote "close-quote" "”"
closeQuoteInner :: Inline
closeQuoteInner = String -> Text -> Inline
getQuote "close-inner-quote" "’"
quoted :: Bool -> [Inline] -> [Inline]
quoted True ils :: [Inline]
ils = Inline
openQuoteOuter Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline]
ils [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [Inline
closeQuoteOuter]
quoted False ils :: [Inline]
ils = Inline
openQuoteInner Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline]
ils [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [Inline
closeQuoteInner]
convertQuoted :: Style -> [Inline] -> [Inline]
convertQuoted :: Style -> [Inline] -> [Inline]
convertQuoted s :: Style
s = [Inline] -> [Inline]
convertQuoted'
where
locale :: Locale
locale = let l :: [Locale]
l = Style -> [Locale]
styleLocale Style
s in case [Locale]
l of [x :: Locale
x] -> Locale
x; _ -> String -> String -> [Option] -> [CslTerm] -> [Element] -> Locale
Locale [] [] [] [] []
getQuote :: String -> String -> Text
getQuote x :: String
x y :: String
y = Text -> Text
fromEntities (Text -> Text) -> (Locale -> Text) -> Locale -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (Locale -> String) -> Locale -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CslTerm -> String
termSingular (CslTerm -> String) -> (Locale -> CslTerm) -> Locale -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CslTerm -> Maybe CslTerm -> CslTerm
forall a. a -> Maybe a -> a
fromMaybe CslTerm
newTerm {termSingular :: String
termSingular = String
x} (Maybe CslTerm -> CslTerm)
-> (Locale -> Maybe CslTerm) -> Locale -> CslTerm
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> Form -> [CslTerm] -> Maybe CslTerm
findTerm String
y Form
Long ([CslTerm] -> Maybe CslTerm)
-> (Locale -> [CslTerm]) -> Locale -> Maybe CslTerm
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Locale -> [CslTerm]
localeTerms (Locale -> Text) -> Locale -> Text
forall a b. (a -> b) -> a -> b
$ Locale
locale
doubleQuotesO :: Text
doubleQuotesO = String -> String -> Text
getQuote "\"" "open-quote"
doubleQuotesC :: Text
doubleQuotesC = String -> String -> Text
getQuote "\"" "close-quote"
singleQuotesO :: Text
singleQuotesO = String -> String -> Text
getQuote "'" "open-inner-quote"
singleQuotesC :: Text
singleQuotesC = String -> String -> Text
getQuote "'" "close-inner-quote"
convertQuoted' :: [Inline] -> [Inline]
convertQuoted' o :: [Inline]
o
| (Quoted DoubleQuote t :: [Inline]
t:xs :: [Inline]
xs) <- [Inline]
o = Text -> Inline
Str Text
doubleQuotesO Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline]
t [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Text -> Inline
Str Text
doubleQuotesC Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline] -> [Inline]
convertQuoted' [Inline]
xs
| (Quoted SingleQuote t :: [Inline]
t:xs :: [Inline]
xs) <- [Inline]
o = Text -> Inline
Str Text
singleQuotesO Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline]
t [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ Text -> Inline
Str Text
singleQuotesC Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline] -> [Inline]
convertQuoted' [Inline]
xs
| (x :: Inline
x :xs :: [Inline]
xs) <- [Inline]
o = Inline
x Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
: [Inline] -> [Inline]
convertQuoted' [Inline]
xs
| Bool
otherwise = []
data FlipFlopState = FlipFlopState
{ FlipFlopState -> Bool
inEmph :: Bool
, FlipFlopState -> Bool
inStrong :: Bool
, FlipFlopState -> Bool
inSmallCaps :: Bool
, FlipFlopState -> Bool
inOuterQuotes :: Bool
}
flipFlop :: [Inline] -> [Inline]
flipFlop :: [Inline] -> [Inline]
flipFlop = (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' (FlipFlopState -> Inline -> Inline)
-> FlipFlopState -> Inline -> Inline
forall a b. (a -> b) -> a -> b
$ Bool -> Bool -> Bool -> Bool -> FlipFlopState
FlipFlopState Bool
False Bool
False Bool
False Bool
False)
flipFlop' :: FlipFlopState -> Inline -> Inline
flipFlop' :: FlipFlopState -> Inline -> Inline
flipFlop' st :: FlipFlopState
st (Emph ils :: [Inline]
ils) =
(if FlipFlopState -> Bool
inEmph FlipFlopState
st then Attr -> [Inline] -> Inline
Span ("",["csl-no-emph"],[]) else [Inline] -> Inline
Emph)
([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st{ inEmph :: Bool
inEmph = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ FlipFlopState -> Bool
inEmph FlipFlopState
st }) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Strong ils :: [Inline]
ils) =
(if FlipFlopState -> Bool
inStrong FlipFlopState
st then Attr -> [Inline] -> Inline
Span ("",["csl-no-strong"],[]) else [Inline] -> Inline
Strong)
([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st{ inStrong :: Bool
inStrong = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ FlipFlopState -> Bool
inStrong FlipFlopState
st }) [Inline]
ils
flipFlop' st :: FlipFlopState
st (SmallCaps ils :: [Inline]
ils) =
(if FlipFlopState -> Bool
inSmallCaps FlipFlopState
st then Attr -> [Inline] -> Inline
Span ("",["csl-no-smallcaps"],[]) else [Inline] -> Inline
SmallCaps)
([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st{ inSmallCaps :: Bool
inSmallCaps = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ FlipFlopState -> Bool
inSmallCaps FlipFlopState
st }) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Strikeout ils :: [Inline]
ils) =
[Inline] -> Inline
Strikeout ([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Superscript ils :: [Inline]
ils) =
[Inline] -> Inline
Superscript ([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Subscript ils :: [Inline]
ils) =
[Inline] -> Inline
Subscript ([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Quoted _ ils :: [Inline]
ils) =
QuoteType -> [Inline] -> Inline
Quoted (if FlipFlopState -> Bool
inOuterQuotes FlipFlopState
st then QuoteType
SingleQuote else QuoteType
DoubleQuote)
([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st{ inOuterQuotes :: Bool
inOuterQuotes = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ FlipFlopState -> Bool
inOuterQuotes FlipFlopState
st }) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Span (_, ["csl-inquote"], _) ils :: [Inline]
ils) =
Attr -> [Inline] -> Inline
Span ("", ["csl-inquote"], [("position", if FlipFlopState -> Bool
inOuterQuotes FlipFlopState
st then "inner" else "outer")])
([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st{ inOuterQuotes :: Bool
inOuterQuotes = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ FlipFlopState -> Bool
inOuterQuotes FlipFlopState
st }) [Inline]
ils
flipFlop' st :: FlipFlopState
st (Span (id' :: Text
id',classes :: [Text]
classes,kvs :: [Target]
kvs) ils :: [Inline]
ils)
| "nodecor" Text -> [Text] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text]
classes = Attr -> [Inline] -> Inline
Span (Text
id',[Text]
classes',[Target]
kvs) ([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils
| Bool
otherwise = Attr -> [Inline] -> Inline
Span (Text
id',[Text]
classes,[Target]
kvs) ([Inline] -> Inline) -> [Inline] -> Inline
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils
where classes' :: [Text]
classes' = (Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
filter (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= "nodecor") [Text]
classes [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
["csl-no-emph" | FlipFlopState -> Bool
inEmph FlipFlopState
st] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
["csl-no-strong" | FlipFlopState -> Bool
inStrong FlipFlopState
st] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
["csl-no-smallcaps" | FlipFlopState -> Bool
inSmallCaps FlipFlopState
st]
flipFlop' st :: FlipFlopState
st (Link attr :: Attr
attr ils :: [Inline]
ils t :: Target
t) =
Attr -> [Inline] -> Target -> Inline
Link Attr
attr ((Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils) Target
t
flipFlop' st :: FlipFlopState
st (Note [Para ils :: [Inline]
ils]) =
[Block] -> Inline
Note [[Inline] -> Block
Para ([Inline] -> Block) -> [Inline] -> Block
forall a b. (a -> b) -> a -> b
$ (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. (a -> b) -> [a] -> [b]
map (FlipFlopState -> Inline -> Inline
flipFlop' FlipFlopState
st) [Inline]
ils]
flipFlop' _ il :: Inline
il = Inline
il