packages feed

haggis 0.1.2.1 → 0.1.3.0

raw patch · 4 files changed

+28/−14 lines, 4 filesdep +blaze-htmldep +network-uridep −networkdep ~haggis

Dependencies added: blaze-html, network-uri

Dependencies removed: network

Dependency ranges changed: haggis

Files

haggis.cabal view
@@ -1,5 +1,5 @@ name:                haggis-version:             0.1.2.1+version:             0.1.3.0 synopsis:            A static site generator with blogging/comments support homepage:            http://github.com/tych0/haggis license:             MIT@@ -24,8 +24,9 @@                  blaze-builder >= 0.3, pandoc >= 1.10, pandoc-types >= 1.10,                  xmlhtml >= 0.2, containers >= 0.5, hquery >= 0.1.1.0,                  time >= 1.4, old-locale, parsec >= 3.1, split >= 0.2,-                 text >= 0.11, rss >= 3000.2, network >= 2.4, MissingH >= 1.2,-                 HDBC >= 2.3, HDBC-sqlite3 >= 2.3, convertible >= 1.0.11+                 text >= 0.11, rss >= 3000.2, network-uri >= 2.4, MissingH >= 1.2,+                 HDBC >= 2.3, HDBC-sqlite3 >= 2.3, convertible >= 1.0.11,+                 blaze-html >= 0.8   hs-source-dirs: src   exposed-modules: Text.Haggis, Text.Haggis.Parse, Text.Haggis.Types,                    Text.Haggis.Binders, Text.Haggis.RSS, Text.Haggis.Utils,@@ -37,5 +38,5 @@   hs-source-dirs: tools   build-depends: base ==4.*, filemanip >= 0.3, filepath >= 1.3,                  optparse-applicative >= 0.5, directory >= 1.1,-                 haggis >= 0.1.2.0+                 haggis >= 0.1.3.0   ghc-options: -Wall
src/Text/Haggis/Binders.hs view
@@ -13,8 +13,8 @@  import System.FilePath -import Text.Pandoc.Readers.Markdown import Text.Pandoc.Options+import Text.Pandoc.Readers.Markdown import Text.Haggis.Types hiding (bindPage, bindComment, bindTag, bindSpecial) import Text.Haggis.Utils import Text.Hquery
src/Text/Haggis/Parse.hs view
@@ -35,20 +35,20 @@ import System.FilePath.Find import System.Locale -import Text.Blaze.Renderer.XmlHtml import Text.Pandoc.Definition+import Text.Pandoc.Error import Text.Pandoc.Options import Text.Pandoc.Readers.Markdown-import Text.Pandoc.Writers.HTML import Text.Parsec import Text.Parsec.String import Text.Haggis.Types+import Text.Haggis.Utils import Text.XmlHtml  data ParseException = ParseException String deriving (Show, Typeable) instance Exception ParseException -fileTypes :: Map.Map String (String -> Pandoc)+fileTypes :: Map.Map String (String -> Either PandocError Pandoc) fileTypes = Map.fromList [ (".md", readMarkdown def)                          ] @@ -76,7 +76,7 @@   (pageBuilder, content) <- findMetadata   let Just reader = Map.lookup (takeExtension fp) fileTypes       doc = reader content-  return $ pageBuilder $ renderHtmlNodes $ writeHtml def doc+  return $ pageBuilder $ pandocToHtml doc   where     findMetadata :: IO ([Node] -> Page, String)     findMetadata = do
src/Text/Haggis/Utils.hs view
@@ -2,20 +2,33 @@  import Blaze.ByteString.Builder -import qualified Data.ByteString.Lazy as BS+import qualified Data.ByteString.Lazy as BSL import qualified Data.Map.Lazy as M+import qualified Data.Text as T -import Text.Blaze.Renderer.XmlHtml+import qualified Text.Blaze.Html.Renderer.Utf8 as PHTML import Text.Pandoc.Definition+import Text.Pandoc.Error import Text.Pandoc.Options import Text.Pandoc.Writers.HTML import Text.XmlHtml -renderHtml :: [Node] -> BS.ByteString+import Debug.Trace++renderHtml :: [Node] -> BSL.ByteString renderHtml = toLazyByteString . renderHtmlFragment UTF8  mapAccum :: Ord a => [(a, b)] -> M.Map a [b] mapAccum = foldr (\(k,v) -> M.insertWith (++) k [v]) M.empty -pandocToHtml :: Pandoc -> [Node]-pandocToHtml = renderHtmlNodes . writeHtml def+pandocToHtml :: Either PandocError Pandoc -> [Node]+pandocToHtml (Left err) = [TextNode (T.pack (show err))]+-- Text.Blaze.Renderer.XmlHtml's renderHtmlNodes doesn't render RawNodes in+-- pandoc correctly. Instead, we render the document to a string, and re-parse+-- it with XmlHtml's parseHTML, which parses them correctly into Nodes.+pandocToHtml (Right doc) =+  let rendered = PHTML.renderHtml $ writeHtml def doc+      result = parseHTML "foo" $ (trace (show rendered) (BSL.toStrict rendered))+  in case result of+       Left err -> [TextNode (T.pack (show err))]+       Right doc2 -> docContent doc2