markdown2svg 0.0.1.6 → 0.0.1.7
raw patch · 3 files changed
+40/−5 lines, 3 files
Files
- markdown2svg.cabal +3/−3
- src/SVG.hs +3/−2
- src/SepWords.hs +34/−0
markdown2svg.cabal view
@@ -2,7 +2,7 @@ cabal-version: >=1.8 name: markdown2svg-version: 0.0.1.6+version: 0.0.1.7 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -31,11 +31,11 @@ source-repository this type: git location: git://github.com/YoshikuniJujo/markdown2svg.git- tag: 0.0.1.6+ tag: 0.0.1.7 executable markdown2svg hs-source-dirs: src main-is: markdown2svg.hs build-depends: base > 3 && < 5, yjsvg, papillon, filepath, monads-tf, markdown-pap ghc-options: -Wall- other-modules: SVG+ other-modules: SVG, SepWords
src/SVG.hs view
@@ -9,6 +9,7 @@ import Text.XML.YJSVG import Text.Markdown.Pap+import SepWords headerFont, normalFont, codeFont :: String headerFont = "Kochi Gothic"@@ -119,9 +120,9 @@ paraToSVGData :: Double -> Double -> String -> (Double, [SVG]) paraToSVGData r h str = (h', l : svgs) where- (s, t) = splitAtString (lineChars - 3) str+ (s, t) = splitWords (lineChars - 3) str l = Text (TopLeft (paraLeftMargin r + normal r) (h + normal r)) (normal r) (ColorName "black") normalFont s- ls = separateString lineChars t+ ls = sepWords lineChars t (h', svgs) = strsToSVGData r (h + normalSep r) ls strsToSVGData :: Double -> Double -> [String] -> (Double, [SVG])
+ src/SepWords.hs view
@@ -0,0 +1,34 @@+module SepWords (+ splitWords,+ sepWords+) where++import Data.Char++splitWords :: Int -> String -> (String, String)+splitWords = flip splitWords_ 0++splitWords_ :: Int -> Int -> String -> (String, String)+splitWords_ _ _ "" = ("", "")+splitWords_ n k (c : c'@('。') : cs)+ | k > n = ([c, c'], cs)+ | otherwise = let (l, ls) = splitWords_ n (k + 4) cs in (c : c' : l, ls)+splitWords_ n k (c : cs)+ | isSpace c && k > n = ("", cs)+ | not (isAscii c) && k > n = ([c], cs)+ | not $ isAscii c = let (l, ls) = splitWords_ n (k + 2) cs in (c : l, ls)+ | otherwise = let (l, ls) = splitWords_ n (k + 1) cs in (c : l, ls)++sepWords :: Int -> String -> [String]+sepWords = flip sepWords_ 0++sepWords_ :: Int -> Int -> String -> [String]+sepWords_ _ _ "" = [""]+sepWords_ n k (c : c'@('。') : cs)+ | k > n = [c, c'] : sepWords_ n 0 cs+ | otherwise = let l : ls = sepWords_ n (k + 4) cs in (c : c' : l) : ls+sepWords_ n k (c : cs)+ | isSpace c && k > n = "" : sepWords_ n 0 cs+ | not (isAscii c) && k > n = [c] : sepWords_ n 0 cs+ | not $ isAscii c = let l : ls = sepWords_ n (k + 2) cs in (c : l) : ls+ | otherwise = let l : ls = sepWords_ n (k + 1) cs in (c : l) : ls