First commit

master
Aadhavan Srinivasan 2 weeks ago
commit bc43f75a28

@ -0,0 +1,5 @@
# Revision history for md-to-html
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.

@ -0,0 +1,29 @@
Copyright (c) 2025, Aadhavan Srinivasan
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 copyright holder 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 EVENT 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.

@ -0,0 +1,81 @@
module Main where
import Text.ParserCombinators.ReadP
import Control.Monad
import Control.Applicative
type HeaderLevel = Int
newtype URL = URL {getUrl :: String}
newtype ImgPath = ImgPath {getPath :: String}
data MdToken = Header HeaderLevel MdToken
| Para [MdToken]
| Linebreak
| HorizontalRule
| Blockquote MdToken
| UnordList [MdToken]
| OrdList [MdToken]
| Code String
| Codeblock String
| Link [MdToken] URL
| Image [MdToken] ImgPath
| Bold [MdToken]
| Italic [MdToken]
| Strikethrough [MdToken]
| Unit String
-- Deriving Show for MdToken
instance Show MdToken where
show (Header level token) = "<h" ++ show level ++ ">" ++ show token ++ "</h" ++ show level ++ ">"
show (Para tokens) = concat(map show tokens)
show Linebreak = "\n"
show HorizontalRule = "---------"
show (Blockquote token) = "BLOCK" ++ show token
show (UnordList tokens) = "UNORD" ++ concat(map show tokens)
show (OrdList tokens) = "ORD" ++ concat(map show tokens)
show (Code code) = concat(map show code)
show (Codeblock code) = concat(map show code)
show (Link txt url) = "<a href=" ++ (getUrl url) ++ ">" ++ concat(map show txt) ++ "</a>"
show (Image txt path) = "<img src=" ++ (getPath path) ++ ">" ++ concat(map show txt) ++ "</img>"
show (Bold tokens) = "<b>" ++ concat(map show tokens) ++ "</b>"
show (Italic tokens) = "<i>" ++ concat(map show tokens) ++ "</i>"
show (Strikethrough tokens) = "<s>" ++ concat (map show tokens) ++ "</s>"
show (Unit unit) = show unit
-- ---------------
-- Helpers
mustBeHash :: ReadP Char
mustBeHash = satisfy (\x -> x == '#')
-- ---------------
parseHeader :: ReadP MdToken
parseHeader = do
headers <- many1 mustBeHash
when ((length headers) > 6)
pfail
_ <- string " "
text <- munch1 (const True) -- Parse until EOL
return (Header (length headers) text)
parseBold :: ReadP MdToken
parseBold = do
_ <- string "__" <|> string "**"
text <- munch1 (\x -> x /= '_' && x /= '*') -- Parse until first asterisk/underscore
_ <- char '_' <|> char '*' -- Throw away the second asterisk/underscore
return (Bold text)
parseMain :: String -> []MdToken
parseMain
main :: IO ()
main = putStrLn "Hello, Haskell!"

@ -0,0 +1 @@
ignore-project: False

@ -0,0 +1 @@
ignore-project: False

@ -0,0 +1,25 @@
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module PackageInfo_md_to_html (
name,
version,
synopsis,
copyright,
homepage,
) where
import Data.Version (Version(..))
import Prelude
name :: String
name = "md_to_html"
version :: Version
version = Version [0,1,0,0] []
synopsis :: String
synopsis = ""
copyright :: String
copyright = ""
homepage :: String
homepage = ""

@ -0,0 +1,77 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
#if __GLASGOW_HASKELL__ >= 810
{-# OPTIONS_GHC -Wno-prepositive-qualified-module #-}
#endif
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_md_to_html (
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import qualified Data.List as List
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
#if defined(VERSION_base)
#if MIN_VERSION_base(4,0,0)
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#else
catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a
#endif
#else
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#endif
catchIO = Exception.catch
version :: Version
version = Version [0,1,0,0] []
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir `joinFileName` name)
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/aadhavan/.cabal/bin"
libdir = "/home/aadhavan/.cabal/lib/x86_64-linux-ghc-9.8.2-32bd/md-to-html-0.1.0.0-inplace-md-to-html"
dynlibdir = "/home/aadhavan/.cabal/lib/x86_64-linux-ghc-9.8.2-32bd"
datadir = "/home/aadhavan/.cabal/share/x86_64-linux-ghc-9.8.2-32bd/md-to-html-0.1.0.0"
libexecdir = "/home/aadhavan/.cabal/libexec/x86_64-linux-ghc-9.8.2-32bd/md-to-html-0.1.0.0"
sysconfdir = "/home/aadhavan/.cabal/etc"
getBinDir = catchIO (getEnv "md_to_html_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "md_to_html_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "md_to_html_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "md_to_html_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "md_to_html_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "md_to_html_sysconfdir") (\_ -> return sysconfdir)
joinFileName :: String -> String -> FilePath
joinFileName "" fname = fname
joinFileName "." fname = fname
joinFileName dir "" = dir
joinFileName dir fname
| isPathSeparator (List.last dir) = dir ++ fname
| otherwise = dir ++ pathSeparator : fname
pathSeparator :: Char
pathSeparator = '/'
isPathSeparator :: Char -> Bool
isPathSeparator c = c == '/'

@ -0,0 +1,120 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package md-to-html-0.1.0.0 */
#ifndef VERSION_md_to_html
#define VERSION_md_to_html "0.1.0.0"
#endif /* VERSION_md_to_html */
#ifndef MIN_VERSION_md_to_html
#define MIN_VERSION_md_to_html(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 1 || \
(major1) == 0 && (major2) == 1 && (minor) <= 0)
#endif /* MIN_VERSION_md_to_html */
/* package base-4.19.1.0 */
#ifndef VERSION_base
#define VERSION_base "4.19.1.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 19 || \
(major1) == 4 && (major2) == 19 && (minor) <= 1)
#endif /* MIN_VERSION_base */
/* tool gcc-14.2.1 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "14.2.1"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 14 || \
(major1) == 14 && (major2) < 2 || \
(major1) == 14 && (major2) == 2 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-9.8.2 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "9.8.2"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 8 || \
(major1) == 9 && (major2) == 8 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-9.8.2 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "9.8.2"
#endif /* TOOL_VERSION_ghc_pkg */
#ifndef MIN_TOOL_VERSION_ghc_pkg
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 8 || \
(major1) == 9 && (major2) == 8 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.30.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.30.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 30 || \
(major1) == 2 && (major2) == 30 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool hpc-0.69 */
#ifndef TOOL_VERSION_hpc
#define TOOL_VERSION_hpc "0.69"
#endif /* TOOL_VERSION_hpc */
#ifndef MIN_TOOL_VERSION_hpc
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 69 || \
(major1) == 0 && (major2) == 69 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_hpc */
/* tool hsc2hs-0.68.10 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.10"
#endif /* TOOL_VERSION_hsc2hs */
#ifndef MIN_TOOL_VERSION_hsc2hs
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 10)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool pkg-config-2.4.3 */
#ifndef TOOL_VERSION_pkg_config
#define TOOL_VERSION_pkg_config "2.4.3"
#endif /* TOOL_VERSION_pkg_config */
#ifndef MIN_TOOL_VERSION_pkg_config
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 4 || \
(major1) == 2 && (major2) == 4 && (minor) <= 3)
#endif /* MIN_TOOL_VERSION_pkg_config */
/* tool runghc-9.8.2 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "9.8.2"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 8 || \
(major1) == 9 && (major2) == 8 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_runghc */
/* tool strip-2.44 */
#ifndef TOOL_VERSION_strip
#define TOOL_VERSION_strip "2.44"
#endif /* TOOL_VERSION_strip */
#ifndef MIN_TOOL_VERSION_strip
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 44 || \
(major1) == 2 && (major2) == 44 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_strip */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "md-to-html-0.1.0.0-inplace-md-to-html"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "0.1.0.0"
#endif /* CURRENT_PACKAGE_VERSION */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
{"cabal-version":"3.12.1.0","cabal-lib-version":"3.12.1.0","compiler-id":"ghc-9.8.2","os":"linux","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.19.1.0-9254","pkg-name":"base","pkg-version":"4.19.1.0","depends":["ghc-bignum-1.3-c93f","ghc-prim-0.11.0-d19b","rts-1.0.2"]},{"type":"pre-existing","id":"ghc-bignum-1.3-c93f","pkg-name":"ghc-bignum","pkg-version":"1.3","depends":["ghc-prim-0.11.0-d19b"]},{"type":"pre-existing","id":"ghc-prim-0.11.0-d19b","pkg-name":"ghc-prim","pkg-version":"0.11.0","depends":["rts-1.0.2"]},{"type":"configured","id":"md-to-html-0.1.0.0-inplace-md-to-html","pkg-name":"md-to-html","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/home/aadhavan/Programming/Haskell/md-to-html/."},"dist-dir":"/home/aadhavan/Programming/Haskell/md-to-html/dist-newstyle/build/x86_64-linux/ghc-9.8.2/md-to-html-0.1.0.0/x/md-to-html","build-info":"/home/aadhavan/Programming/Haskell/md-to-html/dist-newstyle/build/x86_64-linux/ghc-9.8.2/md-to-html-0.1.0.0/x/md-to-html/build-info.json","depends":["base-4.19.1.0-9254"],"exe-depends":[],"component-name":"exe:md-to-html","bin-file":"/home/aadhavan/Programming/Haskell/md-to-html/dist-newstyle/build/x86_64-linux/ghc-9.8.2/md-to-html-0.1.0.0/x/md-to-html/build/md-to-html/md-to-html"},{"type":"pre-existing","id":"rts-1.0.2","pkg-name":"rts","pkg-version":"1.0.2","depends":[]}]}

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,76 @@
cabal-version: 3.0
-- The cabal-version field refers to the version of the .cabal specification,
-- and can be different from the cabal-install (the tool) version and the
-- Cabal (the library) version you are using. As such, the Cabal (the library)
-- version used must be equal or greater than the version stated in this field.
-- Starting from the specification version 2.2, the cabal-version field must be
-- the first thing in the cabal file.
-- Initial package description 'md-to-html' generated by
-- 'cabal init'. For further documentation, see:
-- http://haskell.org/cabal/users-guide/
--
-- The name of the package.
name: md-to-html
-- The package version.
-- See the Haskell package versioning policy (PVP) for standards
-- guiding when and how versions should be incremented.
-- https://pvp.haskell.org
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.0
-- A short (one-line) description of the package.
-- synopsis:
-- A longer description of the package.
-- description:
-- The license under which the package is released.
license: BSD-3-Clause
-- The file containing the license text.
license-file: LICENSE
-- The package author(s).
author: Aadhavan Srinivasan
-- An email address to which users can send suggestions, bug reports, and patches.
maintainer: aadhavan@twomorecents.org
-- A copyright notice.
-- copyright:
build-type: Simple
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README.
extra-doc-files: CHANGELOG.md
-- Extra source files to be distributed with the package, such as examples, or a tutorial module.
-- extra-source-files:
common warnings
ghc-options: -Wall
executable md-to-html
-- Import common warning flags.
import: warnings
-- .hs or .lhs file containing the Main module.
main-is: Main.hs
-- Modules included in this executable, other than Main.
-- other-modules:
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends: base ^>=4.19.1.0
-- Directories containing source files.
hs-source-dirs: app
-- Base language which the package is written in.
default-language: Haskell2010
Loading…
Cancel
Save