From 82277e9ea8d4e4983e480ab7af1ac99aebb38335 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 10 Jun 2025 14:14:26 -0400 Subject: [PATCH] Only add newlines for linebreak when pretty printing --- src/MdToHTML.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MdToHTML.hs b/src/MdToHTML.hs index 2bcb34e..dea69a6 100644 --- a/src/MdToHTML.hs +++ b/src/MdToHTML.hs @@ -58,7 +58,7 @@ instance Show MdToken where show (Header level token) = "" ++ show token ++ "" show (Para token) = "

" ++ show token ++ "

" show (Line tokens) = concatMap show tokens - show Linebreak = "
\n" + show Linebreak = "
" show SingleNewline = " " show HorizontalRule = "
" show (Blockquote tokens) = "
" ++ concatMap show tokens ++ "
" @@ -81,6 +81,8 @@ instance Show MdToken where prettyPrint :: MdToken -> String prettyPrint (Para token) = "

" ++ T.unpack (wrapText defaultWrapSettings 70 (T.pack $ prettyPrint token)) ++ "

\n" prettyPrint (Table (thead : tokenGrid)) = "\n\n\n" ++ concatMap (\x -> "\n") thead ++ "\n\n" ++ "\n" ++ concatMap (\x -> "\n" ++ concatMap (\y -> "\n") x ++ "\n") tokenGrid ++ "\n
" ++ rstrip (prettyPrint x) ++ "
" ++ rstrip (prettyPrint y) ++ "
\n" +prettyPrint Linebreak = "
\n" +prettyPrint (Line tokens) = concatMap prettyPrint tokens prettyPrint (Document tokens) = concatMap prettyPrint tokens prettyPrint token = show token