"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Text/Pandoc/Writers/Docx.hs" between
pandoc-2.14.0.3.tar.gz and pandoc-2.14.1.tar.gz

About: Pandoc converts files from one markup format into another.

Docx.hs  (pandoc-2.14.0.3):Docx.hs  (pandoc-2.14.1)
skipping to change at line 39 skipping to change at line 39
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe (fromMaybe, isNothing, mapMaybe, maybeToList) import Data.Maybe (fromMaybe, isNothing, mapMaybe, maybeToList)
import qualified Data.Set as Set import qualified Data.Set as Set
import qualified Data.Text as T import qualified Data.Text as T
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy as TL
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX
import Data.Digest.Pure.SHA (sha1, showDigest) import Data.Digest.Pure.SHA (sha1, showDigest)
import Skylighting import Skylighting
import Text.Collate.Lang (renderLang) import Text.Collate.Lang (renderLang)
import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang) import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang, translateTerm
)
import qualified Text.Pandoc.Translations as Term
import qualified Text.Pandoc.Class.PandocMonad as P import qualified Text.Pandoc.Class.PandocMonad as P
import Data.Time import Data.Time
import Text.Pandoc.UTF8 (fromTextLazy) import Text.Pandoc.UTF8 (fromTextLazy)
import Text.Pandoc.Definition import Text.Pandoc.Definition
import Text.Pandoc.Generic import Text.Pandoc.Generic
import Text.Pandoc.Highlighting (highlight) import Text.Pandoc.Highlighting (highlight)
import Text.Pandoc.Error import Text.Pandoc.Error
import Text.Pandoc.ImageSize import Text.Pandoc.ImageSize
import Text.Pandoc.Logging import Text.Pandoc.Logging
import Text.Pandoc.MIME (extensionFromMimeType, getMimeType, getMimeTypeDef) import Text.Pandoc.MIME (extensionFromMimeType, getMimeType, getMimeTypeDef)
skipping to change at line 851 skipping to change at line 852
isInTable <- gets stInTable isInTable <- gets stInTable
isInList <- gets stInList isInList <- gets stInList
let block = blockToOpenXML opts (Para lst) let block = blockToOpenXML opts (Para lst)
prop <- pStyleM "Compact" prop <- pStyleM "Compact"
if isInTable || isInList if isInTable || isInList
then withParaProp prop block then withParaProp prop block
else block else block
-- title beginning with fig: indicates that the image is a figure -- title beginning with fig: indicates that the image is a figure
blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit )]) = do blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit )]) = do
setFirstPara setFirstPara
fignum <- gets stNextFigureNum
unless (null alt) $ modify $ \st -> st{ stNextFigureNum = fignum + 1 }
let figid = "fig" <> tshow fignum
figname <- translateTerm Term.Figure
prop <- pStyleM $ prop <- pStyleM $
if null alt if null alt
then "Figure" then "Figure"
else "Captioned Figure" else "Captioned Figure"
paraProps <- local (\env -> env { envParaProperties = EnvProps (Just prop) [] <> envParaProperties env }) (getParaProps False) paraProps <- local (\env -> env { envParaProperties = EnvProps (Just prop) [] <> envParaProperties env }) (getParaProps False)
contents <- inlinesToOpenXML opts [Image attr alt (src,tit)] contents <- inlinesToOpenXML opts [Image attr alt (src,tit)]
captionNode <- withParaPropM (pStyleM "Image Caption") captionNode <- if null alt
$ blockToOpenXML opts (Para alt) then return []
else withParaPropM (pStyleM "Image Caption")
$ blockToOpenXML opts
(Para $ Span (figid,[],[])
[Str (figname <> "\160"),
RawInline (Format "openxml")
("<w:fldSimple w:instr=\"SEQ Figure"
<> " \\* ARABIC \"><w:r><w:t>"
<> tshow fignum
<> "</w:t></w:r></w:fldSimple>"),
Str ":", Space] : alt)
return $ return $
Elem (mknode "w:p" [] (map Elem paraProps ++ contents)) Elem (mknode "w:p" [] (map Elem paraProps ++ contents))
: captionNode : captionNode
blockToOpenXML' opts (Para lst) blockToOpenXML' opts (Para lst)
| null lst && not (isEnabled Ext_empty_paragraphs opts) = return [] | null lst && not (isEnabled Ext_empty_paragraphs opts) = return []
| otherwise = do | otherwise = do
isFirstPara <- gets stFirstPara isFirstPara <- gets stFirstPara
let displayMathPara = case lst of let displayMathPara = case lst of
[x] -> isDisplayMath x [x] -> isDisplayMath x
_ -> False _ -> False
skipping to change at line 1286 skipping to change at line 1301
imgext = case mt >>= extensionFromMimeType of imgext = case mt >>= extensionFromMimeType of
Just x -> "." <> x Just x -> "." <> x
Nothing -> case imageType img of Nothing -> case imageType img of
Just Png -> ".png" Just Png -> ".png"
Just Jpeg -> ".jpeg" Just Jpeg -> ".jpeg"
Just Gif -> ".gif" Just Gif -> ".gif"
Just Pdf -> ".pdf" Just Pdf -> ".pdf"
Just Eps -> ".eps" Just Eps -> ".eps"
Just Svg -> ".svg" Just Svg -> ".svg"
Just Emf -> ".emf" Just Emf -> ".emf"
Just Tiff -> ".tiff"
Nothing -> "" Nothing -> ""
imgpath = "media/" <> ident <> imgext imgpath = "media/" <> ident <> imgext
mbMimeType = mt <|> getMimeType (T.unpack imgpath) mbMimeType = mt <|> getMimeType (T.unpack imgpath)
imgData = (T.unpack ident, T.unpack imgpath, mbMimeType, img) imgData = (T.unpack ident, T.unpack imgpath, mbMimeType, img)
if T.null imgext if T.null imgext
then -- without an extension there is no rule for content type then -- without an extension there is no rule for content type
inlinesToOpenXML opts alt -- return alt to avoid corrupted docx inlinesToOpenXML opts alt -- return alt to avoid corrupted docx
else do else do
 End of changes. 4 change blocks. 
3 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)