packages feed

pandoc-vimhl 0.3.2.0 → 0.3.2.1

raw patch · 3 files changed

+26/−22 lines, 3 files

Files

Changelog.md view
@@ -1,3 +1,7 @@+### 0.3.2.1++- Replace use of *liftM2* with the applicative style.+ ### 0.3.2.0  - Improvement after the previous release: do not use */dev/tty* if the backend
pandoc-vimhl.cabal view
@@ -1,5 +1,5 @@ name:                    pandoc-vimhl-version:                 0.3.2.0+version:                 0.3.2.1 synopsis:                Pandoc filter for native Vim code highlighting description:             Pandoc filter for native Vim code highlighting         in HTML and PDF documents. Requires Vim (or Neovim) and plugin
vimhl.hs view
@@ -23,9 +23,9 @@ import qualified Data.Text.IO as T  vimHl :: Maybe Format -> Block -> IO Block-vimHl (Just fm@(Format fmt)) (CodeBlock (_, cls@(ft : _), namevals) contents)-    | lookup "hl" namevals' == Just "vim" &&-        fmt `elem` ["html", "latex", "gfm"] = do+vimHl (Just fmt) (CodeBlock (_, cls@(ft : _), namevals) contents)+    | Just "vim" <- lookup "hl" namevals'+    , fmt `elem` ["html", "latex", "gfm"] = do         let vimhlcmd = unwords [cmd fmt, nmb]                 where cmd "latex" = "MakeTexCodeHighlight"                       cmd _ = "MakeHtmlCodeHighlight"@@ -75,22 +75,22 @@                 r <- waitForProcess handle                 unless (r == ExitSuccess) $ exitWith r                 T.readFile dst-        return $ RawBlock fm' $ wrap fm block+        return $ uncurry RawBlock $ decorate fmt block     where namevals' = map (T.map toLower *** T.unpack) namevals-          fm' | fm == Format "latex" = fm-              | otherwise = Format "html"           {- Note that Github markdown sanitizer strips CSS styles in HTML-           - tags. See details at https://github.com/github/markup. -}-          wrap "gfm" block = T.concat-              ["<div class=\"highlight notranslate \-               \position-relative overflow-auto\" dir=\"auto\" \-               \data-snippet-clipboard-copy-content=\""-              ,escapeHtml $ stripShellOutputPrompt contents-              ,"\">"-              ,block-              ,"</div>"-              ]-          wrap _ block = block+           - tags. See details at https://github.com/github/markup#readme. -}+          decorate "gfm" block =+              ("html"+              ,T.concat ["<div class=\"highlight notranslate \+                         \position-relative overflow-auto\" dir=\"auto\" \+                         \data-snippet-clipboard-copy-content=\""+                        ,escapeHtml $ stripShellOutputPrompt contents+                        ,"\">"+                        ,block+                        ,"</div>"+                        ]+              )+          decorate fm block = (fm, block)           escapeHtml = T.concatMap $ \case               '<' -> "&lt;"               '>' -> "&gt;"@@ -132,10 +132,10 @@     maybe (do                home <- getHomeDirectory `catchIOError` const (return "")                let vimrc = home </> ".vimrc.pandoc"-                   exists = doesFileExist &&> (fmap readable . getPermissions)-                   (&&>) = liftM2 andM-                   (<<$) = liftM2 (<$>)-               (bool Nothing . Just) <<$ exists $ vimrc+                   returnIf = (fmap <$> bool Nothing . Just <*>)+                   exists = andM <$>+                       doesFileExist <*> fmap readable . getPermissions+               returnIf exists vimrc           ) (return . Just) {-# NOINLINE vimrcPandoc #-}