markdown2svg (empty) → 0.0.1.1
raw patch · 4 files changed
+95/−0 lines, 4 filesdep +basedep +filepathdep +monads-tfsetup-changed
Dependencies added: base, filepath, monads-tf, papillon, yjsvg
Files
- LICENSE +27/−0
- Setup.hs +2/−0
- markdown2svg.cabal +40/−0
- src/markdown2svg.hs +26/−0
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) 2011, Yoshikuni Jujo+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright notice,+ this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++ * Neither the name of the Yoshikuni Jujo nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVEN SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ markdown2svg.cabal view
@@ -0,0 +1,40 @@+build-type: Simple+cabal-version: >=1.8++name: markdown2svg+version: 0.0.1.1+stability: Experimental+author: Yoshikuni Jujo <PAF01143@nifty.ne.jp>+maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>++license: BSD3+license-file: LICENSE++category: Text+synopsis: markdown to svg converter+description:+ Usage: markdown2svg foo.md+ .+ Now. Implemented only following features.+ .+ paragraph, header, code, list+ .+ Not yet implemented following features.+ .+ newline, bold, quote, link, horizontal line+++source-repository head+ type: git+ location: git://github.com/YoshikuniJujo/markdown2svg.git++source-repository this+ type: git+ location: git://github.com/YoshikuniJujo/markdown2svg.git+ tag: 0.0.1.1++executable markdown2svg+ hs-source-dirs: src+ main-is: markdown2svg.hs+ build-depends: base > 3 && < 5, yjsvg, papillon, filepath, monads-tf+ ghc-options: -Wall
+ src/markdown2svg.hs view
@@ -0,0 +1,26 @@+import Control.Monad+import System.Environment+import System.FilePath++import Parser+import SVG++main :: IO ()+main = do+ fp : as <- getArgs+ let size = case as of+ [s] -> read s+ _ -> 0.15+ cnt <- readFile fp+ case parseMrd cnt of+ Just t -> forM_ (zip [1 ..] $ textToSVG True size t) $ \(i, s) ->+ writeFile (mkSVGFileName fp i) s+ _ -> return ()++mkSVGFileName :: FilePath -> Int -> FilePath+mkSVGFileName fp i = (dropExtension fp ++ show2 i) <.> "svg"++show2 :: Show a => a -> String+show2 x = replicate (2 - length s) '0' ++ s+ where+ s = show x