From 071d91f494e07d45069ae308d7725f6c2f4f8114 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 28 Aug 2018 10:32:43 -0700 Subject: [PATCH] A typesetting that shows whitespace for help debugging --- src/Reprinting/Typeset.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Reprinting/Typeset.hs b/src/Reprinting/Typeset.hs index e1b12e399..2da1d797c 100644 --- a/src/Reprinting/Typeset.hs +++ b/src/Reprinting/Typeset.hs @@ -1,6 +1,7 @@ module Reprinting.Typeset ( typeset , typesetting + , typesettingWithVisualWhitespace ) where import Prologue @@ -24,3 +25,16 @@ step (Layout (Indent 0 Spaces)) = mempty step (Layout (Indent n Spaces)) = stimes n space step (Layout (Indent 0 Tabs)) = mempty step (Layout (Indent n Tabs)) = stimes n "\t" + +-- | Typeset, but show whitespace with printable characters for debugging purposes. +typesettingWithVisualWhitespace :: Monad m => ProcessT m Splice (Doc a) +typesettingWithVisualWhitespace = auto step where + step :: Splice -> Doc a + step (Emit t) = pretty t + step (Layout SoftWrap) = softline + step (Layout HardWrap) = "\\n" <> hardline + step (Layout Space) = "." + step (Layout (Indent 0 Spaces)) = mempty + step (Layout (Indent n Spaces)) = stimes n "." + step (Layout (Indent 0 Tabs)) = mempty + step (Layout (Indent n Tabs)) = stimes n "\t"