packages feed

pandoc-vimhl 0.1.3.0 → 0.1.4.0

raw patch · 4 files changed

+19/−9 lines, 4 files

Files

Changelog.md view
@@ -1,3 +1,7 @@+### 0.1.4.0++- Use environment variable *VIMHL_BACKEND* to choose between vim flavors.+ ### 0.1.3.0  - Updated after Pandoc *2.8* and the *String-to-Text* migration.
LICENSE view
@@ -1,7 +1,7 @@ The following license covers this documentation, and the source code, except where otherwise indicated. -Copyright 2016-2019, Alexey Radkov. All rights reserved.+Copyright 2016-2022, Alexey Radkov. All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
pandoc-vimhl.cabal view
@@ -1,5 +1,5 @@ name:                    pandoc-vimhl-version:                 0.1.3.0+version:                 0.1.4.0 synopsis:                Pandoc filter for native Vim code highlighting description:             Pandoc filter for native Vim code highlighting         in HTML and PDF documents. Requires Vim and plugin@@ -10,7 +10,7 @@ extra-source-files:      Changelog.md author:                  Alexey Radkov <alexey.radkov@gmail.com> maintainer:              Alexey Radkov <alexey.radkov@gmail.com>-copyright:               2016-2019 Alexey Radkov+copyright:               2016-2022 Alexey Radkov category:                Text build-type:              Simple cabal-version:           1.20
vimhl.hs view
@@ -3,6 +3,7 @@ import System.IO (IOMode (WriteMode), openFile, hFlush) import System.IO.Temp import System.IO.Error+import System.Environment (lookupEnv) import System.Directory import System.FilePath import System.Process@@ -18,11 +19,15 @@ import Control.Conditional hiding (unless) #if MIN_VERSION_pandoc_types(1,20,0) import Prelude hiding (readFile)-import Data.Text.IO (readFile, hPutStr)+import Data.Text.IO (readFile)+import qualified Data.Text.IO as P (hPutStr) import Data.Text (Text, unpack) #else-import System.IO (hPutStr)+import qualified System.IO as P (hPutStr) #endif+#ifdef DEBUG+import System.IO (hPutStr, hPutStrLn, stderr)+#endif  #if MIN_VERSION_pandoc_types(1,20,0) tOSTRING :: Text -> String@@ -65,12 +70,13 @@                 ($>)  = liftM2 (<$>)             (bool "" . ("--noplugin -u '" ++) . (++ "'")) $> exists $ vimrc         block <- withSystemTempFile "_vimhl_src." $ \src hsrc -> do-            hPutStr hsrc contents >> hFlush hsrc+            P.hPutStr hsrc contents >> hFlush hsrc             bracket (emptySystemTempFile "_vimhl_dst.") removeFile $                 \dst -> do+                    vimexe <- fromMaybe "vim" <$> lookupEnv "VIMHL_BACKEND"                     let vimcmd =                             unwords-                                ["vim -Nen", cmds, vimrccmd, colorscheme+                                [vimexe, "-Nen", cmds, vimrccmd, colorscheme                                 ,"-c 'set ft=" ++ ft', "|"                                 ,vimhlcmd ++ "' -c 'w!", dst ++ "' -c 'qa!'"                                 ,src@@ -90,10 +96,10 @@                     (_, _, _, handle) <- createProcess (shell vimcmd)                         {std_in = UseHandle hin, std_out = UseHandle hout}                     r <- waitForProcess handle-                    unless (r == ExitSuccess) $ exitWith r #ifdef DEBUG-                    hPutStrLn stderr "done"+                    hPutStrLn stderr $ show r #endif+                    unless (r == ExitSuccess) $ exitWith r                     readFile dst         return $ RawBlock fm block     where fmt' = tOSTRING fmt