pandoc-include-code 1.4.0.0 → 1.5.0.0
raw patch · 4 files changed
+22/−15 lines, 4 filesdep ~pandoc-typesdep ~text
Dependency ranges changed: pandoc-types, text
Files
- CHANGELOG.md +2/−0
- pandoc-include-code.cabal +5/−4
- src/Text/Pandoc/Filter/IncludeCode.hs +8/−7
- test/FilterTest.hs +7/−4
CHANGELOG.md view
@@ -1,5 +1,7 @@ # Changelog +* **1.5.0.0**+ - Support Pandoc 2.8, thereby requiring `pandoc-types == 1.20` * **1.4.0.0** - Use data files for test fixtures, fixing Nixpkgs test problem * **1.3.0.0**
pandoc-include-code.cabal view
@@ -8,7 +8,7 @@ author: Oskar Wickström maintainer: Oskar Wickström homepage: https://github.com/owickstrom/pandoc-include-code-version: 1.4.0.0+version: 1.5.0.0 cabal-version: >= 1.8 build-type: Simple category: Documentation@@ -36,14 +36,14 @@ , filepath , text >= 1.2 && < 2 , mtl >= 2.2 && < 3- , pandoc-types >= 1.12 && <= 1.19+ , pandoc-types >= 1.20 && <= 1.20 executable pandoc-include-code hs-source-dirs: filter main-is: Main.hs build-depends: base >= 4 && < 5- , pandoc-types >= 1.12 && <= 1.19+ , pandoc-types >= 1.20 && <= 1.20 , pandoc-include-code test-suite filter-tests@@ -53,10 +53,11 @@ , Paths_pandoc_include_code main-is: Driver.hs build-depends: base >= 4 && < 5- , pandoc-types >= 1.12 && <= 1.19+ , pandoc-types >= 1.20 && <= 1.20 , pandoc-include-code , tasty , tasty-hunit , tasty-hspec+ , text , hspec , hspec-expectations
src/Text/Pandoc/Filter/IncludeCode.hs view
@@ -84,10 +84,11 @@ initialState = InclusionState {startLineNumber = Nothing} parseInclusion ::- HashMap String String -> Either InclusionError (Maybe InclusionSpec)+ HashMap Text Text -> Either InclusionError (Maybe InclusionSpec) parseInclusion attrs = case HM.lookup "include" attrs of- Just include -> do+ Just tinclude -> do+ let include = Text.unpack tinclude rangeMode <- parseRangeMode mode <- case catMaybes [rangeMode, snippetMode] of@@ -97,8 +98,8 @@ return (Just InclusionSpec {..}) Nothing -> return Nothing where- lookupInt name = HM.lookup name attrs >>= readMaybe- snippetMode = SnippetMode . Text.pack <$> HM.lookup "snippet" attrs+ lookupInt name = HM.lookup name attrs >>= readMaybe . Text.unpack+ snippetMode = SnippetMode <$> HM.lookup "snippet" attrs dedent = lookupInt "dedent" parseRangeMode = case (lookupInt "startLine", lookupInt "endLine") of@@ -159,7 +160,7 @@ Nothing -> "" modifyAttributes ::- InclusionState -> [String] -> [(String, String)] -> [(String, String)]+ InclusionState -> [Text] -> [(Text ,Text)] -> [(Text, Text)] modifyAttributes InclusionState {startLineNumber} classes = (++) extraAttrs . filter nonFilterAttribute where@@ -168,7 +169,7 @@ extraAttrs = case startLineNumber of Just n- | "numberLines" `elem` classes -> [("startFrom", show n)]+ | "numberLines" `elem` classes -> [("startFrom", Text.pack (show n))] _ -> [] printAndFail :: InclusionError -> IO a@@ -203,7 +204,7 @@ (Right (CodeBlock (id', classes, modifyAttributes state classes attrs)- (Text.unpack contents)))+ contents)) Right Nothing -> return (Right cb) Left err -> return (Left err) includeCode' x = return (Right x)
test/FilterTest.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} module FilterTest where@@ -8,6 +9,8 @@ import qualified Text.Pandoc.Filter.IncludeCode as Filter import Text.Pandoc.JSON+import Data.Text (Text)+import qualified Data.Text as Text import Paths_pandoc_include_code @@ -24,11 +27,11 @@ includeCode :: String- -> [String]- -> [(String, String)]+ -> [Text]+ -> [(Text, Text)] -> IO (Either Filter.InclusionError Block) includeCode fixtureName classes attrs = do- fname <- getDataFileName ("test/fixtures/" ++ fixtureName)+ fname <- Text.pack <$> getDataFileName ("test/fixtures/" ++ fixtureName) Filter.includeCode' (CodeBlock ( ""@@ -38,7 +41,7 @@ noRange = (Nothing, Nothing) -codeBlock :: String -> Block+codeBlock :: Text -> Block codeBlock = CodeBlock ("", [], []) tests =