diff options
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 9 | ||||
-rw-r--r-- | Pandoc.hs.patch | 101 | ||||
-rw-r--r-- | cabal.patch | 15 |
4 files changed, 123 insertions, 8 deletions
@@ -1,7 +1,7 @@ pkgbase = haskell-latex-formulae-pandoc pkgdesc = Render LaTeX formulae in pandoc documents to images with an actual LaTeX installation pkgver = 0.2.0.6 - pkgrel = 3 + pkgrel = 4 url = https://hackage.haskell.org/package/latex-formulae-pandoc arch = x86_64 arch = i686 @@ -15,8 +15,10 @@ pkgbase = haskell-latex-formulae-pandoc depends = haskell-latex-formulae-image source = haskell-latex-formulae-pandoc-0.2.0.6.tar.gz::https://hackage.haskell.org/packages/archive/latex-formulae-pandoc/0.2.0.6/latex-formulae-pandoc-0.2.0.6.tar.gz source = cabal.patch + source = Pandoc.hs.patch sha256sums = 2efc0b9238e237eeacdf3c24f80b7a7546175d4edcb5e86a6f6ffad4769d0c88 - sha256sums = dd8498cdc786abe005900574f1a05e0932fc74b6f6f25a10756e51a19fca6577 + sha256sums = 6d1dfb1d95ffbeb09ae82a1e202260cf77688aabb9318916edb42eaa7d8928f2 + sha256sums = 33e6cb538ce21351ff0d6211c6d95dbeb0af30382c9e80a2b6087a5c23fd3987 pkgname = haskell-latex-formulae-pandoc @@ -1,7 +1,7 @@ pkgname=haskell-latex-formulae-pandoc _hkgname=latex-formulae-pandoc pkgver=0.2.0.6 -pkgrel=3 +pkgrel=4 pkgdesc="Render LaTeX formulae in pandoc documents to images with an actual LaTeX installation" url="https://hackage.haskell.org/package/latex-formulae-pandoc" license=('BSD') @@ -13,13 +13,16 @@ depends=('ghc-libs' 'haskell-latex-formulae-image') makedepends=('ghc') source=(${pkgname}-${pkgver}.tar.gz::"https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz" - cabal.patch) + cabal.patch + Pandoc.hs.patch) sha256sums=('2efc0b9238e237eeacdf3c24f80b7a7546175d4edcb5e86a6f6ffad4769d0c88' - 'dd8498cdc786abe005900574f1a05e0932fc74b6f6f25a10756e51a19fca6577') + '6d1dfb1d95ffbeb09ae82a1e202260cf77688aabb9318916edb42eaa7d8928f2' + '33e6cb538ce21351ff0d6211c6d95dbeb0af30382c9e80a2b6087a5c23fd3987') prepare() { cd ${_hkgname}-${pkgver} patch --forward --strip=1 --input="${srcdir}/cabal.patch" + patch --forward --strip=1 --input="${srcdir}/Pandoc.hs.patch" } build() { diff --git a/Pandoc.hs.patch b/Pandoc.hs.patch new file mode 100644 index 000000000000..14a168b8ec95 --- /dev/null +++ b/Pandoc.hs.patch @@ -0,0 +1,101 @@ +diff --git a/src/Image/LaTeX/Render/Pandoc.hs b/src/Image/LaTeX/Render/Pandoc.hs +index 33473fe..f63ec33 100644 +--- a/src/Image/LaTeX/Render/Pandoc.hs ++++ b/src/Image/LaTeX/Render/Pandoc.hs +@@ -1,4 +1,5 @@ +-{-# LANGUAGE LambdaCase #-} ++{-# LANGUAGE LambdaCase #-} ++{-# LANGUAGE OverloadedStrings #-} + module Image.LaTeX.Render.Pandoc + ( -- * Data URIs + convertFormulaDataURI +@@ -25,16 +26,17 @@ module Image.LaTeX.Render.Pandoc + , convertAllFormulaeFilesWith + ) where + +-import Text.Pandoc.Definition +-import Text.Pandoc.Walk +-import Image.LaTeX.Render +-import Codec.Picture +-import Control.Applicative +-import Data.IORef +-import System.FilePath ++import Codec.Picture ++import Control.Applicative ++import Data.IORef ++import Data.Text ++import Image.LaTeX.Render ++import System.FilePath ++import Text.Pandoc.Definition ++import Text.Pandoc.Walk + + import qualified Data.ByteString.Base64.Lazy as B64 +-import qualified Data.ByteString.Lazy.Char8 as BS ++import qualified Data.ByteString.Lazy.Char8 as BS + + dims :: Image a -> (Int,Int) + dims = liftA2 (,) imageWidth imageHeight +@@ -51,7 +53,7 @@ dimensions (ImageYA16 i) = dims i + dimensions _ = error "Unsupported image format somehow!" + + +--- | All options pertaining to the actual display of formulae. ++-- | All options pertaining to the actual display of formulae. + data PandocFormulaOptions = PandocFormulaOptions + { shrinkBy :: ShrinkSize + -- ^ Denominator for all dimensions. Useful for displaying high DPI images in small sizes, for retina displays. Otherwise set to 1. +@@ -96,16 +98,16 @@ convertFormulaDataURIWith + -- ^ Function that renders a formula, such as @imageForFormula defaultEnv@ + -> PandocFormulaOptions -- ^ Formula display settings + -> Inline -> IO Inline +-convertFormulaDataURIWith f o (Math t s) = f (formulaOptions o t) s >>= \case ++convertFormulaDataURIWith f o (Math t s) = f (formulaOptions o t) (unpack s) >>= \case + Left e -> return $ errorDisplay o e + Right (b,i) -> let + Right bs = encodeDynamicPng i + dataUri = "data:image/png;base64," ++ BS.unpack (B64.encode bs) + (ow,oh) = dimensions i + (w,h) = (ow `div` shrinkBy o, oh `div` shrinkBy o) +- in return $ RawInline (Format "html") $ ++ in return $ RawInline (Format "html") $ pack $ + "<img width=" ++ show w ++ +- " alt=\"" ++ processAltString s ++ "\"" ++ ++ " alt=\"" ++ (processAltString $ unpack s) ++ "\"" ++ + " height=" ++ show h ++ + " src=\"" ++ dataUri ++ "\"" ++ + " class=" ++ (case t of InlineMath -> "inline-math"; _ -> "display-math") ++ +@@ -151,7 +153,7 @@ convertFormulaFilesWith + -> FilePath -- ^ Name of image directory where images will be stored + -> PandocFormulaOptions -- ^ Formula display settings + -> Inline -> IO Inline +-convertFormulaFilesWith f ns bn o (Math t s) = f (formulaOptions o t) s >>= \case ++convertFormulaFilesWith f ns bn o (Math t s) = f (formulaOptions o t) (unpack s) >>= \case + Left e -> return $ errorDisplay o e + Right (b,i) -> do + fn <- readIORef ns +@@ -160,7 +162,7 @@ convertFormulaFilesWith f ns bn o (Math t s) = f (formulaOptions o t) s >>= \cas + (ow,oh) = dimensions i + (w,h) = (ow `div` shrinkBy o, oh `div` shrinkBy o) + _ <- writeDynamicPng uri i +- return $ RawInline (Format "html") $ ++ return $ RawInline (Format "html") $ pack $ + "<img width=" ++ show w ++ + " height=" ++ show h ++ + " src=\"" ++ uri ++ "\"" ++ +@@ -207,11 +209,11 @@ hideError = const $ Str blank + displayError :: RenderError -> Inline + displayError ImageIsEmpty = pandocError [Str "The rendered image was empty"] + displayError CannotDetectBaseline = pandocError [Str "Cannot detect baseline in rendered image"] +-displayError (LaTeXFailure str) = pandocError [Str "LaTeX failed:", LineBreak, Code nullAttr str] +-displayError (DVIPSFailure str) = pandocError [Str "DVIPS failed:", LineBreak, Code nullAttr str] +-displayError (IMConvertFailure str) = pandocError [Str "convert failed:", LineBreak, Code nullAttr str] +-displayError (ImageReadError str) = pandocError [Str "Error reading image:", LineBreak, Code nullAttr str] +-displayError (IOException e) = pandocError [Str "IO Exception:", LineBreak, Code nullAttr $ show e] ++displayError (LaTeXFailure str) = pandocError [Str "LaTeX failed:", LineBreak, Code nullAttr $ pack str] ++displayError (DVIPSFailure str) = pandocError [Str "DVIPS failed:", LineBreak, Code nullAttr $ pack str] ++displayError (IMConvertFailure str) = pandocError [Str "convert failed:", LineBreak, Code nullAttr $ pack str] ++displayError (ImageReadError str) = pandocError [Str "Error reading image:", LineBreak, Code nullAttr $ pack str] ++displayError (IOException e) = pandocError [Str "IO Exception:", LineBreak, Code nullAttr $ pack $ show e] + + pandocError :: [Inline] -> Inline + pandocError = Strong . (Emph [Str "Error:"] :) diff --git a/cabal.patch b/cabal.patch index 316167c64419..973c8e97604f 100644 --- a/cabal.patch +++ b/cabal.patch @@ -1,8 +1,8 @@ diff --git a/latex-formulae-pandoc.cabal b/latex-formulae-pandoc.cabal -index 743c06e..b2e6cdb 100644 +index 743c06e..d16c25d 100644 --- a/latex-formulae-pandoc.cabal +++ b/latex-formulae-pandoc.cabal -@@ -22,7 +22,7 @@ source-repository head +@@ -22,13 +22,14 @@ source-repository head library exposed-modules: Image.LaTeX.Render.Pandoc build-depends: base >=4.7 && <5 @@ -11,12 +11,21 @@ index 743c06e..b2e6cdb 100644 , latex-formulae-image >= 0.1 && < 0.2 , JuicyPixels >= 3.2 && < 3.4 , directory >= 1.2 && < 1.4 -@@ -38,7 +38,7 @@ executable latex-formulae-filter + , filepath >= 1.3 && < 1.5 + , base64-bytestring >= 1.0 && < 1.1 + , bytestring >= 0.10 && <0.11 ++ , text + hs-source-dirs: src + ghc-options: -Wall + default-language: Haskell2010 +@@ -38,8 +39,9 @@ executable latex-formulae-filter main-is: Main.hs ghc-options: -Wall build-depends: base >=4.7 && <5, latex-formulae-pandoc - , pandoc-types >= 1.12 && < 1.18 + , pandoc-types >= 1.12 , latex-formulae-image >= 0.1 && < 0.2 ++ , text default-language: Haskell2010 + |