Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add cabal file for HtmlToBlaze tool

  • Loading branch information...
commit 6fc882123368b199df18ee1ccc344bc93b8f221e 1 parent 448c0f3
@jaspervdj authored
View
4 Makefile
@@ -48,3 +48,7 @@ hide-cabal-files:
blaze-html: hide-cabal-files
mv blaze-html.cabal.blaze-html blaze-html.cabal
mv Setup.hs.blaze-html Setup.hs
+
+blaze-html-to-blaze: hide-cabal-files
+ mv blaze-html-to-blaze.cabal.blaze-html-to-blaze blaze-html-to-blaze.cabal
+ mv Setup.hs.blaze-html-to-blaze Setup.hs
View
2  Setup.hs.blaze-html-to-blaze
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
View
1  Util/GenerateHtmlCombinators.hs
@@ -7,7 +7,6 @@
module Util.GenerateHtmlCombinators where
import Control.Arrow ((&&&))
-import Control.Monad (mapM_)
import Data.List (isPrefixOf, sort, sortBy)
import Data.List (intersperse, intercalate)
import Data.Ord (comparing)
View
10 Util/HtmlToBlaze.hs
@@ -1,10 +1,9 @@
-- | A module for conversion from HTML to BlazeHtml Haskell code.
--
-module HtmlToBlaze where
+module Main where
import Control.Monad (forM_)
-import Data.List (intercalate)
-import Data.Maybe (listToMaybe, fromMaybe)
+import Data.Maybe (listToMaybe)
import Data.Char (toLower, isSpace)
import Control.Arrow (first)
import System.Environment (getArgs)
@@ -46,7 +45,7 @@ makeTree :: [String] -- ^ Stack of open tags
makeTree stack []
| null stack = (Block [], [])
| otherwise = error $ "Error: tags left open at the end: " ++ show stack
-makeTree stack (TagPosition row column : x : xs) = case x of
+makeTree stack (TagPosition row _ : x : xs) = case x of
TagOpen tag attrs -> if toLower' tag == "!doctype"
then addHtml Doctype xs
else let (inner, t) = makeTree (tag : stack) xs
@@ -65,6 +64,7 @@ makeTree stack (TagPosition row column : x : xs) = case x of
in (Block (html : l), r)
toLower' = map toLower
+makeTree _ _ = error "TagSoup error"
-- | Remove empty text from the HTML.
--
@@ -105,7 +105,7 @@ fromHtml variant (Block block) = concatMap (fromHtml variant) block
fromHtml variant (Parent tag attrs inner) = case combinatorType variant tag of
-- Actual parent tags
ParentCombinator -> case inner of
- (Block b) -> (combinator ++ " $ do") : indent (fromHtml variant inner)
+ (Block _) -> (combinator ++ " $ do") : indent (fromHtml variant inner)
-- We join non-block parents for better readability.
x -> let ls = fromHtml variant x
apply = if dropApply x then " " else " $ "
View
4 Util/Sanitize.hs
@@ -34,5 +34,5 @@ sanitize tag = if tag == "html" -- We make an exception for the html tag, since
replace' '-' = '_'
replace' x = x
- appendUnderscore tag | tag `S.member` keywords = tag ++ "_"
- | otherwise = tag
+ appendUnderscore t | t `S.member` keywords = t ++ "_"
+ | otherwise = t
View
24 blaze-html-to-blaze.cabal.blaze-html-to-blaze
@@ -0,0 +1,24 @@
+Name: blaze-html-to-blaze
+Version: 0.2.0
+Synopsis: Tool to convert HTML to BlazeHtml code.
+Description: Tool that converts HTML files to Haskell code, ready to be
+ used with the BlazeHtml library.
+Homepage: http://jaspervdj.be/blaze
+Bug-Reports: http://github.com/jaspervdj/BlazeHtml/issues
+License: BSD3
+License-file: LICENSE
+Author: Jasper Van der Jeugt, Simon Meier
+Maintainer: jaspervdj@gmail.com, simon.meier@inf.ethz.ch
+Stability: Experimental
+Category: Text
+Build-type: Simple
+Cabal-version: >= 1.2
+
+Executable html-to-blaze
+ Ghc-Options: -Wall
+ Main-Is: Util/HtmlToBlaze.hs
+ Build-depends: base >= 4 && < 5,
+ containers >= 0.3,
+ filepath >= 1.1,
+ directory >= 1.0,
+ tagsoup >= 0.10

0 comments on commit 6fc8821

Please sign in to comment.
Something went wrong with that request. Please try again.