packages feed

markdown2svg 0.0.1.20 → 0.0.1.21

raw patch · 2 files changed

+24/−4 lines, 2 files

Files

markdown2svg.cabal view
@@ -2,7 +2,7 @@ cabal-version:	>=1.8  name:		markdown2svg-version:	0.0.1.20+version:	0.0.1.21 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.20+  tag:		0.0.1.21  executable markdown2svg   hs-source-dirs:	src
src/SVG.hs view
@@ -67,13 +67,20 @@  textToSVGData :: Fonts -> [(FilePath, String)] -> Double -> Double -> [Text] -> [[SVG]] textToSVGData fs@(hf, nf, cf) fp r h [] = [[]]+textToSVGData fs@(hf, nf, cf) fp r h (Header n s : ts@(i@(Image _ _ _) : _))+	| h + headerSep n r * 5 / 4 + getImageHeight fp r i > bottomBorder r =+		[] : (l : one') : rest'+	where+	l = Text (TopLeft (leftMargin r) (topMargin r + headerSep n r)) (header n r) (ColorName "black") hf s+	one' : rest' = textToSVGData fs fp r (topMargin r + headerSep n r * 5 / 4) ts textToSVGData fs@(hf, nf, cf) fp r h (Header n s : ts)-	| h > bottomBorder r - headerSep n r = [l] : all+	| h > bottomBorder r - headerSep n r = [] : (l' : one') : rest' 	| otherwise = (l : one) : rest 	where 	l = Text (TopLeft (leftMargin r) (h + headerSep n r)) (header n r) (ColorName "black") hf s+	l' = Text (TopLeft (leftMargin r) (topMargin r + headerSep n r)) (header n r) (ColorName "black") hf s 	one : rest = textToSVGData fs fp r (h + headerSep n r * 5 / 4) ts-	all = textToSVGData fs fp r (topMargin r) ts+	one' : rest' = textToSVGData fs fp r (topMargin r + headerSep n r * 5 / 4) ts textToSVGData fs@(hf, nf, cf) fp r h (Paras [] : ts) = textToSVGData fs fp r h ts textToSVGData fs@(hf, nf, cf) fp r h (Paras (p : ps) : ts) 	| h' > bottomBorder r = [] : (svgs' ++ one') : rest'@@ -225,3 +232,16 @@ getSize dict fp sz = case lookup fp dict of 	Just src -> convertedSize src sz 	_ -> error $ show (map fst dict) ++ " " ++ show fp -- Nothing++getImageHeight :: [(FilePath, String)] -> Double -> Text -> Double+getImageHeight fp r (Image _ p ttl) = ht+	where+	ratio = width r - 2 * leftMargin r+	size = case ttl of+		"small" -> Small+		"large" -> Large+		_ -> Medium+	(wt, ht) = case getSize fp p size of+		Just (w_, h_) -> (w_ * ratio, h_ * ratio)+		_ -> (r * 1000, r * 1000)+getImageHeight _ _ _ = error "not Image"