aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs3
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs93
-rw-r--r--src/Text/Pandoc/Readers/Docx/Combine.hs101
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs3
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse/Styles.hs18
-rw-r--r--src/Text/Pandoc/Readers/Ipynb.hs3
-rw-r--r--src/Text/Pandoc/Readers/RST.hs7
-rw-r--r--src/Text/Pandoc/Writers/Ipynb.hs7
-rw-r--r--src/Text/Pandoc/Writers/Jira.hs22
-rw-r--r--src/Text/Pandoc/Writers/Ms.hs14
10 files changed, 127 insertions, 144 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index ae319b372..b04952c27 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -360,7 +360,7 @@ List of all DocBook tags, with [x] indicating implemented,
[x] refsectioninfo - Meta-information for a refsection
[ ] refsynopsisdiv - A syntactic synopsis of the subject of the reference page
[ ] refsynopsisdivinfo - Meta-information for a RefSynopsisDiv
-[x] releaseinfo - Information about a particular release of a document
+[ ] releaseinfo - Information about a particular release of a document
[ ] remark - A remark (or comment) intended for presentation in a draft
manuscript
[x] replaceable - Content that may or must be replaced by the user
@@ -608,6 +608,7 @@ addMetadataFromElement e = do
addMetaField "author" e
addMetaField "date" e
addMetaField "release" e
+ addMetaField "releaseinfo" e
return mempty
where addMetaField fieldname elt =
case filterChildren (named fieldname) elt of
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index ddec0bdf8..c9aa2f7c5 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -261,46 +261,43 @@ resolveDependentRunStyle rPr
| otherwise = return rPr
runStyleToTransform :: PandocMonad m => RunStyle -> DocxContext m (Inlines -> Inlines)
-runStyleToTransform rPr
- | Just sn <- getStyleName <$> rParentStyle rPr
- , sn `elem` spansToKeep = do
- transform <- runStyleToTransform rPr{rParentStyle = Nothing}
- return $ spanWith ("", [normalizeToClassName sn], []) . transform
- | Just s <- rParentStyle rPr = do
- ei <- extraInfo spanWith s
- transform <- runStyleToTransform rPr{rParentStyle = Nothing}
- return $ ei . transform
- | Just True <- isItalic rPr = do
- transform <- runStyleToTransform rPr{isItalic = Nothing}
- return $ emph . transform
- | Just True <- isBold rPr = do
- transform <- runStyleToTransform rPr{isBold = Nothing}
- return $ strong . transform
- | Just True <- isSmallCaps rPr = do
- transform <- runStyleToTransform rPr{isSmallCaps = Nothing}
- return $ smallcaps . transform
- | Just True <- isStrike rPr = do
- transform <- runStyleToTransform rPr{isStrike = Nothing}
- return $ strikeout . transform
- | Just True <- isRTL rPr = do
- transform <- runStyleToTransform rPr{isRTL = Nothing}
- return $ spanWith ("",[],[("dir","rtl")]) . transform
- | Just False <- isRTL rPr = do
- transform <- runStyleToTransform rPr{isRTL = Nothing}
- inBidi <- asks docxInBidi
- return $ if inBidi
- then spanWith ("",[],[("dir","ltr")]) . transform
- else transform
- | Just SupScrpt <- rVertAlign rPr = do
- transform <- runStyleToTransform rPr{rVertAlign = Nothing}
- return $ superscript . transform
- | Just SubScrpt <- rVertAlign rPr = do
- transform <- runStyleToTransform rPr{rVertAlign = Nothing}
- return $ subscript . transform
- | Just "single" <- rUnderline rPr = do
- transform <- runStyleToTransform rPr{rUnderline = Nothing}
- return $ Pandoc.underline . transform
- | otherwise = return id
+runStyleToTransform rPr' = do
+ opts <- asks docxOptions
+ inBidi <- asks docxInBidi
+ let styles = isEnabled Ext_styles opts
+ ctl = (Just True == isRTL rPr') || (Just True == isForceCTL rPr')
+ italic rPr | ctl = isItalicCTL rPr
+ | otherwise = isItalic rPr
+ bold rPr | ctl = isBoldCTL rPr
+ | otherwise = isBold rPr
+ go rPr
+ | Just sn <- getStyleName <$> rParentStyle rPr
+ , sn `elem` spansToKeep =
+ spanWith ("", [normalizeToClassName sn], [])
+ . go rPr{rParentStyle = Nothing}
+ | styles, Just s <- rParentStyle rPr =
+ spanWith (extraAttr s) . go rPr{rParentStyle = Nothing}
+ | Just True <- italic rPr =
+ emph . go rPr{isItalic = Nothing, isItalicCTL = Nothing}
+ | Just True <- bold rPr =
+ strong . go rPr{isBold = Nothing, isBoldCTL = Nothing}
+ | Just True <- isSmallCaps rPr =
+ smallcaps . go rPr{isSmallCaps = Nothing}
+ | Just True <- isStrike rPr =
+ strikeout . go rPr{isStrike = Nothing}
+ | Just True <- isRTL rPr =
+ spanWith ("",[],[("dir","rtl")]) . go rPr{isRTL = Nothing}
+ | inBidi, Just False <- isRTL rPr =
+ spanWith ("",[],[("dir","ltr")]) . go rPr{isRTL = Nothing}
+ | Just SupScrpt <- rVertAlign rPr =
+ superscript . go rPr{rVertAlign = Nothing}
+ | Just SubScrpt <- rVertAlign rPr = do
+ subscript . go rPr{rVertAlign = Nothing}
+ | Just "single" <- rUnderline rPr = do
+ Pandoc.underline . go rPr{rUnderline = Nothing}
+ | otherwise = id
+ return $ go rPr'
+
runToInlines :: PandocMonad m => Run -> DocxContext m Inlines
runToInlines (Run rs runElems)
@@ -512,13 +509,8 @@ trimSps (Many ils) = Many $ Seq.dropWhileL isSp $Seq.dropWhileR isSp ils
isSp LineBreak = True
isSp _ = False
-extraInfo :: (Eq (StyleName a), PandocMonad m, HasStyleName a)
- => (Attr -> i -> i) -> a -> DocxContext m (i -> i)
-extraInfo f s = do
- opts <- asks docxOptions
- return $ if isEnabled Ext_styles opts
- then f ("", [], [("custom-style", fromStyleName $ getStyleName s)])
- else id
+extraAttr :: (Eq (StyleName a), HasStyleName a) => a -> Attr
+extraAttr s = ("", [], [("custom-style", fromStyleName $ getStyleName s)])
parStyleToTransform :: PandocMonad m => ParagraphStyle -> DocxContext m (Blocks -> Blocks)
parStyleToTransform pPr = case pStyle pPr of
@@ -534,8 +526,11 @@ parStyleToTransform pPr = case pStyle pPr of
| otherwise -> do
let pPr' = pPr { pStyle = cs }
transform <- parStyleToTransform pPr'
- ei <- extraInfo divWith c
- return $ ei . (if isBlockQuote c then blockQuote else id) . transform
+ styles <- asks (isEnabled Ext_styles . docxOptions)
+ return $
+ (if styles then divWith (extraAttr c) else id)
+ . (if isBlockQuote c then blockQuote else id)
+ . transform
[]
| Just left <- indentation pPr >>= leftParIndent -> do
let pPr' = pPr { indentation = Nothing }
diff --git a/src/Text/Pandoc/Readers/Docx/Combine.hs b/src/Text/Pandoc/Readers/Docx/Combine.hs
index 54736cd0e..427a73dbe 100644
--- a/src/Text/Pandoc/Readers/Docx/Combine.hs
+++ b/src/Text/Pandoc/Readers/Docx/Combine.hs
@@ -1,10 +1,9 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE OverloadedStrings #-}
{- |
Module : Text.Pandoc.Readers.Docx.Combine
Copyright : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,
- 2014-2020 John MacFarlane <jgm@berkeley.edu>
+ 2014-2020 John MacFarlane <jgm@berkeley.edu>,
+ 2020 Nikolay Yakimov <root@livid.pp.ru>
License : GNU GPL, version 2 or above
Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
@@ -59,79 +58,61 @@ module Text.Pandoc.Readers.Docx.Combine ( smushInlines
where
import Data.List
-import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr, (><), (|>))
-import qualified Data.Sequence as Seq (null)
+import Data.Bifunctor
+import Data.Sequence ( ViewL (..), ViewR (..), viewl, viewr, spanr, spanl
+ , (><), (|>) )
import Text.Pandoc.Builder
data Modifier a = Modifier (a -> a)
| AttrModifier (Attr -> a -> a) Attr
- | NullModifier
spaceOutInlinesL :: Inlines -> (Inlines, Inlines)
spaceOutInlinesL ms = (l, stackInlines fs (m' <> r))
- where (l, m, r) = spaceOutInlines ms
- (fs, m') = unstackInlines m
+ where (l, (fs, m'), r) = spaceOutInlines ms
spaceOutInlinesR :: Inlines -> (Inlines, Inlines)
spaceOutInlinesR ms = (stackInlines fs (l <> m'), r)
- where (l, m, r) = spaceOutInlines ms
- (fs, m') = unstackInlines m
+ where (l, (fs, m'), r) = spaceOutInlines ms
-spaceOutInlines :: Inlines -> (Inlines, Inlines, Inlines)
+spaceOutInlines :: Inlines -> (Inlines, ([Modifier Inlines], Inlines), Inlines)
spaceOutInlines ils =
let (fs, ils') = unstackInlines ils
- contents = unMany ils'
- left = case viewl contents of
- (Space :< _) -> space
- _ -> mempty
- right = case viewr contents of
- (_ :> Space) -> space
- _ -> mempty in
- (left, stackInlines fs $ trimInlines . Many $ contents, right)
+ (left, (right, contents')) = second (spanr isSpace) $ spanl isSpace $ unMany ils'
+ -- NOTE: spanr counterintuitively returns suffix as the FIRST tuple element
+ in (Many left, (fs, Many contents'), Many right)
+
+isSpace :: Inline -> Bool
+isSpace Space = True
+isSpace SoftBreak = True
+isSpace _ = False
stackInlines :: [Modifier Inlines] -> Inlines -> Inlines
stackInlines [] ms = ms
-stackInlines (NullModifier : fs) ms = stackInlines fs ms
stackInlines (Modifier f : fs) ms =
- if isEmpty ms
+ if null ms
then stackInlines fs ms
else f $ stackInlines fs ms
stackInlines (AttrModifier f attr : fs) ms = f attr $ stackInlines fs ms
unstackInlines :: Inlines -> ([Modifier Inlines], Inlines)
-unstackInlines ms = case ilModifier ms of
- NullModifier -> ([], ms)
- _ -> (f : fs, ms') where
- f = ilModifier ms
- (fs, ms') = unstackInlines $ ilInnards ms
-
-ilModifier :: Inlines -> Modifier Inlines
-ilModifier ils = case viewl (unMany ils) of
- (x :< xs) | Seq.null xs -> case x of
- (Emph _) -> Modifier emph
- (Strong _) -> Modifier strong
- (SmallCaps _) -> Modifier smallcaps
- (Strikeout _) -> Modifier strikeout
- (Superscript _) -> Modifier superscript
- (Subscript _) -> Modifier subscript
- (Link attr _ tgt) -> Modifier $ linkWith attr (fst tgt) (snd tgt)
- (Span attr _) -> AttrModifier spanWith attr
- _ -> NullModifier
- _ -> NullModifier
-
-ilInnards :: Inlines -> Inlines
-ilInnards ils = case viewl (unMany ils) of
- (x :< xs) | Seq.null xs -> case x of
- (Emph lst) -> fromList lst
- (Strong lst) -> fromList lst
- (SmallCaps lst) -> fromList lst
- (Strikeout lst) -> fromList lst
- (Superscript lst) -> fromList lst
- (Subscript lst) -> fromList lst
- (Link _ lst _) -> fromList lst
- (Span _ lst) -> fromList lst
- _ -> ils
- _ -> ils
+unstackInlines ms = case ilModifierAndInnards ms of
+ Nothing -> ([], ms)
+ Just (f, inner) -> first (f :) $ unstackInlines inner
+
+ilModifierAndInnards :: Inlines -> Maybe (Modifier Inlines, Inlines)
+ilModifierAndInnards ils = case viewl $ unMany ils of
+ x :< xs | null xs -> second fromList <$> case x of
+ Emph lst -> Just (Modifier emph, lst)
+ Strong lst -> Just (Modifier strong, lst)
+ SmallCaps lst -> Just (Modifier smallcaps, lst)
+ Strikeout lst -> Just (Modifier strikeout, lst)
+ Underline lst -> Just (Modifier underline, lst)
+ Superscript lst -> Just (Modifier superscript, lst)
+ Subscript lst -> Just (Modifier subscript, lst)
+ Link attr lst tgt -> Just (Modifier $ linkWith attr (fst tgt) (snd tgt), lst)
+ Span attr lst -> Just (AttrModifier spanWith attr, lst)
+ _ -> Nothing
+ _ -> Nothing
inlinesL :: Inlines -> (Inlines, Inlines)
inlinesL ils = case viewl $ unMany ils of
@@ -161,12 +142,12 @@ combineSingletonInlines x y =
y_rem_attr = filter isAttrModifier y_remaining
in
case null shared of
- True | isEmpty xs && isEmpty ys ->
- stackInlines (x_rem_attr ++ y_rem_attr) mempty
- | isEmpty xs ->
+ True | null xs && null ys ->
+ stackInlines (x_rem_attr <> y_rem_attr) mempty
+ | null xs ->
let (sp, y') = spaceOutInlinesL y in
stackInlines x_rem_attr mempty <> sp <> y'
- | isEmpty ys ->
+ | null ys ->
let (x', sp) = spaceOutInlinesR x in
x' <> sp <> stackInlines y_rem_attr mempty
| otherwise ->
@@ -193,12 +174,8 @@ combineBlocks bs cs = bs <> cs
instance (Monoid a, Eq a) => Eq (Modifier a) where
(Modifier f) == (Modifier g) = f mempty == g mempty
(AttrModifier f attr) == (AttrModifier g attr') = f attr mempty == g attr' mempty
- NullModifier == NullModifier = True
_ == _ = False
-isEmpty :: (Monoid a, Eq a) => a -> Bool
-isEmpty x = x == mempty
-
isAttrModifier :: Modifier a -> Bool
isAttrModifier (AttrModifier _ _) = True
isAttrModifier _ = False
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 199ca6d03..eab4f4e0d 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -259,10 +259,13 @@ newtype Cell = Cell [BodyPart]
leftBiasedMergeRunStyle :: RunStyle -> RunStyle -> RunStyle
leftBiasedMergeRunStyle a b = RunStyle
{ isBold = isBold a <|> isBold b
+ , isBoldCTL = isBoldCTL a <|> isBoldCTL b
, isItalic = isItalic a <|> isItalic b
+ , isItalicCTL = isItalicCTL a <|> isItalicCTL b
, isSmallCaps = isSmallCaps a <|> isSmallCaps b
, isStrike = isStrike a <|> isStrike b
, isRTL = isRTL a <|> isRTL b
+ , isForceCTL = isForceCTL a <|> isForceCTL b
, rVertAlign = rVertAlign a <|> rVertAlign b
, rUnderline = rUnderline a <|> rUnderline b
, rParentStyle = rParentStyle a
diff --git a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs
index bfbc65cb0..236167187 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs
@@ -44,7 +44,6 @@ module Text.Pandoc.Readers.Docx.Parse.Styles (
) where
import Codec.Archive.Zip
import Control.Applicative ((<|>))
-import Control.Monad.Except
import Data.Function (on)
import Data.String (IsString(..))
import qualified Data.Map as M
@@ -101,10 +100,13 @@ data CharStyle = CharStyle { cStyleId :: CharStyleId
} deriving (Show)
data RunStyle = RunStyle { isBold :: Maybe Bool
+ , isBoldCTL :: Maybe Bool
, isItalic :: Maybe Bool
+ , isItalicCTL :: Maybe Bool
, isSmallCaps :: Maybe Bool
, isStrike :: Maybe Bool
, isRTL :: Maybe Bool
+ , isForceCTL :: Maybe Bool
, rVertAlign :: Maybe VertAlign
, rUnderline :: Maybe String
, rParentStyle :: Maybe CharStyle
@@ -121,10 +123,13 @@ data ParStyle = ParStyle { headingLev :: Maybe (ParaStyleName, Int)
defaultRunStyle :: RunStyle
defaultRunStyle = RunStyle { isBold = Nothing
+ , isBoldCTL = Nothing
, isItalic = Nothing
+ , isItalicCTL = Nothing
, isSmallCaps = Nothing
, isStrike = Nothing
, isRTL = Nothing
+ , isForceCTL = Nothing
, rVertAlign = Nothing
, rUnderline = Nothing
, rParentStyle = Nothing
@@ -240,20 +245,21 @@ elemToCharStyle :: NameSpaces
elemToCharStyle ns element parentStyle
= CharStyle <$> (CharStyleId <$> findAttrTextByName ns "w" "styleId" element)
<*> getElementStyleName ns element
- <*> (Just $ elemToRunStyle ns element parentStyle)
+ <*> Just (elemToRunStyle ns element parentStyle)
elemToRunStyle :: NameSpaces -> Element -> Maybe CharStyle -> RunStyle
elemToRunStyle ns element parentStyle
| Just rPr <- findChildByName ns "w" "rPr" element =
RunStyle
{
- isBold = checkOnOff ns rPr (elemName ns "w" "b") `mplus`
- checkOnOff ns rPr (elemName ns "w" "bCs")
- , isItalic = checkOnOff ns rPr (elemName ns "w" "i") `mplus`
- checkOnOff ns rPr (elemName ns "w" "iCs")
+ isBold = checkOnOff ns rPr (elemName ns "w" "b")
+ , isBoldCTL = checkOnOff ns rPr (elemName ns "w" "bCs")
+ , isItalic = checkOnOff ns rPr (elemName ns "w" "i")
+ , isItalicCTL = checkOnOff ns rPr (elemName ns "w" "iCs")
, isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps")
, isStrike = checkOnOff ns rPr (elemName ns "w" "strike")
, isRTL = checkOnOff ns rPr (elemName ns "w" "rtl")
+ , isForceCTL = checkOnOff ns rPr (elemName ns "w" "cs")
, rVertAlign =
findChildByName ns "w" "vertAlign" rPr >>=
findAttrByName ns "w" "val" >>=
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
index 056fa431c..a245bdad3 100644
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -79,8 +79,7 @@ cellToBlocks opts lang c = do
case cellType c of
Ipynb.Markdown -> do
Pandoc _ bs <- walk fixImage <$> readMarkdown opts source
- let kvs' = ("source", source) : kvs
- return $ B.divWith ("",["cell","markdown"],kvs')
+ return $ B.divWith ("",["cell","markdown"],kvs)
$ B.fromList bs
Ipynb.Heading lev -> do
Pandoc _ bs <- readMarkdown opts
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index e558836a1..7c25be486 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -223,7 +223,8 @@ rawFieldListItem minIndent = try $ do
first <- anyLine
rest <- option "" $ try $ do lookAhead (count indent (char ' ') >> spaceChar)
indentedBlock
- let raw = (if T.null first then "" else first <> "\n") <> rest <> "\n"
+ let raw = (if T.null first then "" else first <> "\n") <> rest <>
+ (if T.null first && T.null rest then "" else "\n")
return (name, raw)
fieldListItem :: PandocMonad m => Int -> RSTParser m (Inlines, [Blocks])
@@ -484,7 +485,7 @@ includeDirective top fields body = do
Just patt -> drop 1 .
dropWhile (not . (patt `T.isInfixOf`))
Nothing -> id) $ contentLines'
- let contents' = T.unlines contentLines'' <> "\n"
+ let contents' = T.unlines contentLines''
case lookup "code" fields of
Just lang -> do
let classes = maybe [] T.words (lookup "class" fields)
@@ -494,7 +495,7 @@ includeDirective top fields body = do
Just _ -> return $ B.rawBlock "rst" contents'
Nothing -> do
setPosition $ newPos (T.unpack f) 1 1
- setInput contents'
+ setInput $ contents' <> "\n"
bs <- optional blanklines >>
(mconcat <$> many block)
setInput oldInput
diff --git a/src/Text/Pandoc/Writers/Ipynb.hs b/src/Text/Pandoc/Writers/Ipynb.hs
index 86e2abbdf..d01d5a7e5 100644
--- a/src/Text/Pandoc/Writers/Ipynb.hs
+++ b/src/Text/Pandoc/Writers/Ipynb.hs
@@ -102,13 +102,10 @@ extractCells _ [] = return []
extractCells opts (Div (_id,classes,kvs) xs : bs)
| "cell" `elem` classes
, "markdown" `elem` classes = do
- let meta = pairsToJSONMeta [(k,v) | (k,v) <- kvs, k /= "source"]
+ let meta = pairsToJSONMeta kvs
(newdoc, attachments) <-
runStateT (walkM addAttachment (Pandoc nullMeta xs)) mempty
- source <- case lookup "source" kvs of
- Just s -> return s
- Nothing -> writeMarkdown opts{ writerTemplate = Nothing }
- newdoc
+ source <- writeMarkdown opts{ writerTemplate = Nothing } newdoc
(Ipynb.Cell{
cellType = Markdown
, cellSource = Source $ breakLines $ T.stripEnd source
diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs
index 12348f62b..4f12667d4 100644
--- a/src/Text/Pandoc/Writers/Jira.hs
+++ b/src/Text/Pandoc/Writers/Jira.hs
@@ -194,7 +194,7 @@ toJiraInlines inlines = do
Jira.Monospaced (escapeSpecialChars cs)
Emph xs -> styled Jira.Emphasis xs
Underline xs -> styled Jira.Insert xs
- Image attr _ tgt -> imageToJira attr (fst tgt) (snd tgt)
+ Image attr cap tgt -> imageToJira attr cap (fst tgt) (snd tgt)
LineBreak -> pure . singleton $ Jira.Linebreak
Link attr xs tgt -> toJiraLink attr tgt xs
Math mtype cs -> mathToJira mtype cs
@@ -233,16 +233,18 @@ escapeSpecialChars t = case plainText t of
Left _ -> singleton $ Jira.Str t
imageToJira :: PandocMonad m
- => Attr -> Text -> Text
+ => Attr -> [Inline] -> Text -> Text
-> JiraConverter m [Jira.Inline]
-imageToJira (_, classes, kvs) src title =
- let imgParams = if "thumbnail" `elem` classes
- then [Jira.Parameter "thumbnail" ""]
- else map (uncurry Jira.Parameter) kvs
- imgParams' = if T.null title
- then imgParams
- else Jira.Parameter "title" title : imgParams
- in pure . singleton $ Jira.Image imgParams' (Jira.URL src)
+imageToJira (_, classes, kvs) caption src title =
+ let imageWithParams ps = Jira.Image ps (Jira.URL src)
+ alt = stringify caption
+ in pure . singleton . imageWithParams $
+ if "thumbnail" `elem` classes
+ then [Jira.Parameter "thumbnail" ""]
+ else map (uncurry Jira.Parameter)
+ . (if T.null title then id else (("title", title):))
+ . (if T.null alt then id else (("alt", alt):))
+ $ kvs
-- | Creates a Jira Link element.
toJiraLink :: PandocMonad m
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index 81de40045..561053c88 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -204,7 +204,9 @@ blockToMs opts (CodeBlock attr str) = do
literal ".IP" $$
literal ".nf" $$
literal "\\f[C]" $$
- hlCode $$
+ ((case T.uncons str of
+ Just ('.',_) -> literal "\\&"
+ _ -> mempty) <> hlCode) $$
literal "\\f[]" $$
literal ".fi"
blockToMs opts (LineBlock ls) = do
@@ -517,11 +519,11 @@ toMacro sty toktype =
msFormatter :: WriterOptions -> FormatOptions -> [SourceLine] -> Doc Text
msFormatter opts _fmtopts =
- vcat . map fmtLine
- where fmtLine = hcat . map fmtToken
- fmtToken (toktype, tok) = literal "\\*" <>
- brackets (literal (tshow toktype) <> literal " \""
- <> literal (escapeStr opts tok) <> literal "\"")
+ literal . T.intercalate "\n" . map fmtLine
+ where
+ fmtLine = mconcat . map fmtToken
+ fmtToken (toktype, tok) =
+ "\\*[" <> (tshow toktype) <> " \"" <> (escapeStr opts tok) <> "\"]"
highlightCode :: PandocMonad m => WriterOptions -> Attr -> Text -> MS m (Doc Text)
highlightCode opts attr str =