Skip to content

Commit

Permalink
understand columns
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Feb 8, 2024
1 parent a451255 commit bf124d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lib/Patat/Presentation/Display.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ dumpPresentation pres@Presentation {..} =
dumpSlide i = do
slide <- maybeToList $ getSlide i pres
dumpComment slide <> L.intercalate ["{fragment}"]
[ dumpFragment (i, j)
| j <- [0 .. numFragments slide - 1]
]
[ dumpFragment (i, j)
| j <- [0 .. numFragments slide - 1]
]

dumpComment :: Slide -> [PP.Doc]
dumpComment slide = do
Expand All @@ -186,16 +186,17 @@ dumpPresentation pres@Presentation {..} =

--------------------------------------------------------------------------------
formatWith :: PresentationSettings -> PP.Doc -> PP.Doc
formatWith ps doc = wrap . indent $
mconcat (replicate topMargin PP.hardline) <> doc
formatWith ps doc =
mconcat (replicate topMargin PP.hardline) <>
wrap (indent doc)
where
Margins {..} = margins ps
right = case mRight of
Auto -> error "auto"
NotAuto x -> x
topMargin = case mTop of
Auto -> error "auto"
NotAuto x -> x
right = case mRight of
Auto -> error "auto"
NotAuto x -> x
wrap = case (psWrap ps, psColumns ps) of
(Just True, Just (A.FlexibleNum col)) -> PP.wrapAt (Just $ col - right)
_ -> id
Expand Down
1 change: 1 addition & 0 deletions tests/golden/inputs/margins.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
author: 'Jasper'
patat:
wrap: true
columns: 57 # 10 + 42 + 5
Expand Down
2 changes: 1 addition & 1 deletion tests/golden/outputs/margins.md.dump
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
 margins.md 
 

 This text will have 10 spaces on the left.
 
  - So
Expand Down

0 comments on commit bf124d6

Please sign in to comment.