packages feed

pandoc-emphasize-code 0.2.4 → 0.3.0

raw patch · 5 files changed

+46/−40 lines, 5 filesdep ~pandoc-typesPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: pandoc-types

API changes (from Hackage documentation)

- Text.Pandoc.Filter.EmphasizeCode.Range: disjoint :: (Ord a) => a -> a -> a -> a -> Bool
+ Text.Pandoc.Filter.EmphasizeCode.Range: disjoint :: Ord a => a -> a -> a -> a -> Bool

Files

pandoc-emphasize-code.cabal view
@@ -5,8 +5,8 @@ author:              Oskar Wickström maintainer:          Oskar Wickström homepage:	           https://github.com/owickstrom/pandoc-emphasize-code-version:             0.2.4-cabal-version:       >= 1.8+version:             0.3.0+cabal-version:       >= 1.10 build-type:          Simple category:            Documentation license:             MPL-2.0@@ -35,9 +35,10 @@                    , filepath                    , text                 >= 1.2      && < 1.3                    , mtl                  >= 2.2      && < 3-                   , pandoc-types         >= 1.12     && <= 1.19+                   , pandoc-types         >= 1.20     && < 2                    , lucid                >= 2.9      && < 3     ghc-options:     -Wall+    default-language: Haskell2010   executable pandoc-emphasize-code@@ -45,8 +46,9 @@     other-modules:   Paths_pandoc_emphasize_code     main-is:         Main.hs     build-depends:   base                 >= 4        && < 5-                   , pandoc-types         >= 1.12     && <= 1.19+                   , pandoc-types         >= 1.20     && < 2                    , pandoc-emphasize-code+    default-language: Haskell2010  test-suite filter-tests     type:            exitcode-stdio-1.0@@ -59,10 +61,11 @@                      Text.Pandoc.Filter.EmphasizeCode.Testing.Ranges     build-depends:   base                 >= 4        && < 5                    , unordered-containers >= 0.2      && < 0.3-                   , pandoc-types         >= 1.12     && <= 1.19+                   , pandoc-types         >= 1.20     && < 2                    , pandoc-emphasize-code                    , tasty                    , tasty-hunit                    , tasty-hspec                    , tasty-discover                    , text                 >= 1.2      && < 1.3+    default-language: Haskell2010
src/Text/Pandoc/Filter/EmphasizeCode.hs view
@@ -17,6 +17,7 @@ import           Text.Pandoc.Filter.EmphasizeCode.Pretty import           Text.Pandoc.Filter.EmphasizeCode.Range import           Text.Pandoc.Filter.EmphasizeCode.Renderable+import Data.Text (Text)  printAndFail :: NonEmpty ParseError -> IO a printAndFail (err :| []) = fail . Text.unpack . printParseError $ err@@ -31,15 +32,15 @@   | f == "beamer" = Just (renderEmphasized Latex)   | otherwise = Nothing -lookupRanges :: HM.HashMap String String -> Maybe Text.Text-lookupRanges attrs = Text.pack <$> HM.lookup "emphasize" attrs+lookupRanges :: HM.HashMap Text Text -> Maybe Text.Text+lookupRanges = HM.lookup "emphasize"  -- | A Pandoc filter that emphasizes code blocks. emphasizeCode :: Maybe Pandoc.Format -> Pandoc.Block -> IO Pandoc.Block emphasizeCode (Just (toRenderer -> Just render)) cb@(Pandoc.CodeBlock (id', classes, attrs) contents) =   case lookupRanges attrs' >>= (runParser . parseRanges) of     Just (Right ranges) ->-      let lines' = emphasizeRanges (splitRanges ranges) (Text.pack contents)+      let lines' = emphasizeRanges (splitRanges ranges) contents           block =             render               (id', classes, HM.toList (HM.delete "emphasize" attrs'))
src/Text/Pandoc/Filter/EmphasizeCode/Html.hs view
@@ -41,12 +41,12 @@   renderEmphasized (Html tag) (_, classes, _) lines' =     Pandoc.RawBlock       (Pandoc.Format "html")-      (TextLazy.unpack (Html.renderText emphasized))+      (TextLazy.toStrict (Html.renderText emphasized))     where       classAttrs =         if null classes           then []-          else [Html.class_ (Text.pack (unwords classes))]+          else [Html.class_ (Text.unwords classes)]       emphasized =         Html.pre_ classAttrs $         Html.code_ $
src/Text/Pandoc/Filter/EmphasizeCode/Latex.hs view
@@ -1,27 +1,28 @@-{-# LANGUAGE CPP               #-}-{-# LANGUAGE LambdaCase        #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.Filter.EmphasizeCode.Latex-  ( Latex(Latex)-  ) where+  ( Latex (Latex),+  )+where+ #if MIN_VERSION_base(4,8,0) import           Data.Semigroup                              ((<>)) #else import           Control.Applicative import           Data.Monoid #endif-import           Data.Char                                   (isSpace)-import           Data.Text                                   (Text)-import qualified Data.Text                                   as Text-import qualified Text.Pandoc.Definition                      as Pandoc--import           Text.Pandoc.Filter.EmphasizeCode.Chunking-import           Text.Pandoc.Filter.EmphasizeCode.Range-import           Text.Pandoc.Filter.EmphasizeCode.Renderable+import Data.Char (isSpace)+import Data.Text (Text)+import qualified Data.Text as Text+import qualified Text.Pandoc.Definition as Pandoc+import Text.Pandoc.Filter.EmphasizeCode.Chunking+import Text.Pandoc.Filter.EmphasizeCode.Range+import Text.Pandoc.Filter.EmphasizeCode.Renderable -data Latex =-  Latex+data Latex+  = Latex  escaped :: Char -> Text escaped = \case@@ -45,38 +46,38 @@   renderEmphasized _ (_, classes, _) lines' =     Pandoc.RawBlock       (Pandoc.Format "latex")-      (Text.unpack (encloseInVerbatim emphasized))+      (encloseInVerbatim emphasized)     where       languageAttr =         case classes of-          [lang] -> ",language=" <> Text.pack lang-          _      -> ""+          [lang] -> ",language=" <> lang+          _ -> ""       encloseInTextIt style t         | Text.null t = t         | otherwise =           case style of             Inline -> "£\\CodeEmphasis{" <> t <> "}£"-            Block  -> "£\\CodeEmphasisLine{" <> t <> "}£"+            Block -> "£\\CodeEmphasisLine{" <> t <> "}£"       emphasizeNonSpace style t         | Text.null t = t         | otherwise =           let (nonSpace, rest) = Text.break isSpace t               (spaces, rest') = Text.span isSpace rest-          in mconcat-               [ encloseInTextIt style nonSpace-               , spaces-               , emphasizeNonSpace style rest'-               ]+           in mconcat+                [ encloseInTextIt style nonSpace,+                  spaces,+                  emphasizeNonSpace style rest'+                ]       emphasizeChunk chunk =         case chunk of-          Literal t          -> t+          Literal t -> t           Emphasized style t -> emphasizeNonSpace style (Text.concatMap escaped t)       emphasized = Text.unlines (map (foldMap emphasizeChunk) lines')       encloseInVerbatim t =         mconcat-          [ "\\begin{lstlisting}[escapechar=£"-          , languageAttr-          , "]\n"-          , t-          , "\\end{lstlisting}\n"+          [ "\\begin{lstlisting}[escapechar=£",+            languageAttr,+            "]\n",+            t,+            "\\end{lstlisting}\n"           ]
test/Text/Pandoc/Filter/EmphasizeCodeTest.hs view
@@ -7,6 +7,7 @@  import qualified Text.Pandoc.Filter.EmphasizeCode as Filter import           Text.Pandoc.JSON+import Data.Text (Text)  singleRangeHtmlMark :: Block singleRangeHtmlMark =@@ -30,7 +31,7 @@        , "hei verden</code></pre>"        ]) -emphasizeCode :: Format -> String -> IO Block+emphasizeCode :: Format -> Text -> IO Block emphasizeCode format ranges =   Filter.emphasizeCode     (Just format)