packages feed

publish 2.1.3 → 2.1.5

raw patch · 3 files changed

+53/−22 lines, 3 filesdep +core-data

Dependencies added: core-data

Files

publish.cabal view
@@ -4,16 +4,16 @@ -- -- see: https://github.com/sol/hpack ----- hash: 42641db30d6bd630e51fd42caac6877e1ed00681f0b775b2cd8e1f3665cf40bb+-- hash: c35d54fad6892dcaef7d0d6f267b9349e9a21788945c513b64d884539ce9494d  name:           publish-version:        2.1.3+version:        2.1.5 synopsis:       Publishing tools for papers, books, and presentations description:    Tools for rendering markdown-centric documents into PDFs.                 .                 A description of this package, a list of features, and some background                 to its design is contained in the-                <https://github.com/aesiniath/publish/blob/master/README.markdown README>+                <https://github.com/aesiniath/publish/blob/master/README.md README>                 on GitHub. category:       Text stability:      experimental@@ -24,7 +24,7 @@ copyright:      © 2016-2020 Athae Eredh Siniath and Others license:        MIT license-file:   LICENSE-tested-with:    GHC == 8.6+tested-with:    GHC == 8.8 build-type:     Simple  source-repository head@@ -43,6 +43,7 @@       base >=4.11 && <5     , bytestring     , chronologique+    , core-data     , core-program >=0.2.2.3     , core-text >=0.2.2.3     , deepseq@@ -76,6 +77,7 @@       base >=4.11 && <5     , bytestring     , chronologique+    , core-data     , core-program >=0.2.2.3     , core-text >=0.2.2.3     , deepseq@@ -111,6 +113,7 @@       base >=4.11 && <5     , bytestring     , chronologique+    , core-data     , core-program >=0.2.2.3     , core-text >=0.2.2.3     , deepseq
src/RenderDocument.hs view
@@ -8,6 +8,7 @@ where  import Control.Monad (filterM, forM_, forever, void)+import Core.Data import Core.Program import Core.System import Core.Text@@ -27,7 +28,8 @@   ) import System.Exit (ExitCode (..)) import System.FilePath.Posix-  ( replaceDirectory,+  ( dropExtension,+    replaceDirectory,     replaceExtension,     splitFileName,     takeBaseName,@@ -53,10 +55,12 @@  data Mode = Once | Cycle +data Copy = InstallPdf | NoCopyPdf+ program :: Program Env () program = do   params <- getCommandLine-  mode <- extractMode params+  (mode, copy) <- extractMode params    event "Identify .book file"   bookfile <- extractBookFile params@@ -64,13 +68,13 @@   case mode of     Once -> do       -- normal operation, single pass-      void (renderDocument mode bookfile)+      void (renderDocument (mode, copy) bookfile)     Cycle -> do       -- use inotify to rebuild on changes-      forever (renderDocument mode bookfile >>= waitForChange)+      forever (renderDocument (mode, copy) bookfile >>= waitForChange) -renderDocument :: Mode -> FilePath -> Program Env [FilePath]-renderDocument mode file = do+renderDocument :: (Mode, Copy) -> FilePath -> Program Env [FilePath]+renderDocument (mode, copy) file = do   event "Read .book file"   book <- processBookFile file @@ -101,23 +105,37 @@   catch     ( do         renderPDF-        copyHere+        case copy of+          InstallPdf -> copyHere+          NoCopyPdf -> return ()     )     ( \(e :: ExitCode) -> case mode of         Once -> throw e         Cycle -> return ()     ) -  -- question: original lists or filtered ones?-  return (file : preambles ++ fragments ++ trailers)+  return (uniqueList file preambles fragments trailers) -extractMode :: Parameters -> Program Env Mode+--+-- Quickly reduce the fragment names to a unique list so we don't waste+-- inotify watches.+--+uniqueList :: FilePath -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath]+uniqueList file preambles fragments trailers =+  let files = insertElement file (intoSet trailers <> (intoSet preambles <> intoSet fragments))+   in fromSet files++extractMode :: Parameters -> Program Env (Mode, Copy) extractMode params =   let mode = case lookupOptionFlag "watch" params of         Just False -> error "Invalid State"         Just True -> Cycle         Nothing -> Once-   in return mode+      copy = case lookupOptionFlag "no-copy" params of+        Just False -> error "Invalid State"+        Just True -> NoCopyPdf+        Nothing -> InstallPdf+   in return (mode, copy)  {- For the situation where the .book file is in a location other than '.'@@ -394,12 +412,13 @@ convertImage file = do   env <- getApplicationState   let tmpdir = tempDirectoryFrom env-      target = tmpdir ++ "/" ++ replaceExtension file ".pdf"-      buffer = target ++ "-tmp"-      rsvgConvert =-        [ "rsvg-convert",-          "--format=pdf",-          "--output=" ++ buffer,+      basepath = dropExtension file+      target = tmpdir ++ "/" ++ basepath ++ ".pdf"+      buffer = tmpdir ++ "/" ++ basepath ++ "~tmp.pdf"+      inkscape =+        [ "inkscape",+          "--export-type=pdf",+          "--export-filename=" ++ buffer,           file         ] @@ -407,7 +426,7 @@     debugS "target" target     (exit, out, err) <- do       ensureDirectory target-      execProcess rsvgConvert+      execProcess inkscape      case exit of       ExitFailure _ -> do
src/RenderMain.hs view
@@ -46,6 +46,15 @@             rendering engine if changes are detected.           |],             Option+              "no-copy"+              Nothing+              Empty+              [quote|+            Should the resultant PDF be copied to this directory? Of course+            it should, so the default is true. Select this if you want to+            leave the file in /tmp.+          |],+            Option               "temp"               Nothing               (Value "TMPDIR")