Skip to content

Commit daf3d69

Browse files
committed
render with china chao nima
1 parent e62a30f commit daf3d69

File tree

2 files changed

+293
-267
lines changed

2 files changed

+293
-267
lines changed

src/Main.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
module Main where
22

33
import qualified Data.Text as T
4+
import qualified Data.Text.Encoding as TE
45
import qualified Data.Text.IO as TIO
56
import Markdown
67
import Parser
78
import System.Environment (getArgs)
9+
import System.IO (hSetEncoding, stdout, utf8)
810

911
main :: IO ()
1012
main = do
13+
-- Set UTF-8 encoding for stdout
14+
hSetEncoding stdout utf8
15+
1116
args <- getArgs
1217
case args of
1318
["-c"] -> do
1419
content <- TIO.getContents
15-
let html = markdownToHtml content
20+
let html = T.concat [T.pack "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n</head>\n<body>\n", markdownToHtml content, T.pack "\n</body>\n</html>"]
1621
TIO.putStrLn html
1722
[input, output] -> do
1823
content <- TIO.readFile input
19-
let html = markdownToHtml content
24+
let html = T.concat [T.pack "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n</head>\n<body>\n", markdownToHtml content, T.pack "\n</body>\n</html>"]
2025
TIO.writeFile output html
2126
_ -> putStrLn "Usage: program <input> <output> OR program -c"

0 commit comments

Comments
 (0)