markdown2svg 0.0.1.7 → 0.0.1.8
raw patch · 2 files changed
+14/−3 lines, 2 files
Files
- markdown2svg.cabal +2/−2
- src/SVG.hs +12/−1
markdown2svg.cabal view
@@ -2,7 +2,7 @@ cabal-version: >=1.8 name: markdown2svg-version: 0.0.1.7+version: 0.0.1.8 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -31,7 +31,7 @@ source-repository this type: git location: git://github.com/YoshikuniJujo/markdown2svg.git- tag: 0.0.1.7+ tag: 0.0.1.8 executable markdown2svg hs-source-dirs: src
src/SVG.hs view
@@ -4,7 +4,6 @@ import Control.Applicative import Data.Maybe-import Data.List import Data.Char import Text.XML.YJSVG @@ -19,6 +18,7 @@ textToSVG :: Bool -> Double -> [Text] -> [String] textToSVG n r = map (showSVG (width r) (height r)) . textToSVGData r (topMargin r) .+ preprocess . if n then addChapters [Nothing, Just 0, Just 0, Just 0, Nothing, Nothing] else id width, height :: Double -> Double@@ -167,3 +167,14 @@ chaps = concatMap (++ ".") $ map show $ catMaybes $ take n newCs newCs = take (n - 1) cs ++ [(+ 1) <$> cs !! (n - 1)] ++ drop n cs addChapters cs (t : ts) = t : addChapters cs ts++preprocess :: [Text] -> [Text]+preprocess [] = []+preprocess (Paras strs : ts) = Paras (map remSpaces strs) : preprocess ts+preprocess (t : ts) = t : preprocess ts++remSpaces :: String -> String+remSpaces "" = ""+remSpaces (c : ' ' : c' : cs)+ | not (isAscii c) && not (isAscii c') = c : c' : remSpaces cs+remSpaces (c : cs) = c : remSpaces cs