Support comments

This commit is contained in:
Jasper Van der Jeugt 2018-05-04 14:45:00 +02:00 committed by Jasper Van der Jeugt
parent 943326d88d
commit 81696a9d2d
5 changed files with 57 additions and 5 deletions

View File

@ -211,6 +211,25 @@ two content slides.
For more information, see [Advanced slide splitting](#advanced-slide-splitting).
Patat supports comments which can be used as speaker notes.
---
title: This is my presentation
author: Jane Doe
...
# Chapter 1
<!--
Note: I should not bore the audience with my thoughts on powerpoint but
just get straight to the point.
-->
Slide contents. Yay.
<!-- TODO: Finish the rest of the presentation. -->
Configuration
-------------

View File

@ -15,7 +15,7 @@ import Control.Applicative ((<$>))
import Control.Monad (mplus, unless)
import qualified Data.Aeson.Extended as A
import Data.Data.Extended (grecQ)
import Data.List (intersperse)
import qualified Data.List as L
import Data.Maybe (fromMaybe)
import Data.Monoid (mconcat, mempty, (<>))
import qualified Data.Text as T
@ -113,11 +113,11 @@ dumpPresentation :: Presentation -> IO ()
dumpPresentation pres =
let theme = fromMaybe Theme.defaultTheme (psTheme $ pSettings pres) in
PP.putDoc $ withWrapSettings (pSettings pres) $
PP.vcat $ intersperse "----------" $ do
PP.vcat $ L.intersperse "----------" $ do
slide <- pSlides pres
return $ case slide of
TitleSlide block -> "~~~title" <$$> prettyBlock theme block
ContentSlide fragments -> PP.vcat $ intersperse "~~~frag" $ do
ContentSlide fragments -> PP.vcat $ L.intersperse "~~~frag" $ do
fragment <- fragments
return $ prettyFragment theme fragment
@ -238,7 +238,7 @@ prettyBlock theme@Theme {..} (Pandoc.LineBlock inliness) =
--------------------------------------------------------------------------------
prettyBlocks :: Theme -> [Pandoc.Block] -> PP.Doc
prettyBlocks theme = PP.vcat . map (prettyBlock theme)
prettyBlocks theme = PP.vcat . map (prettyBlock theme) . filter isVisibleBlock
--------------------------------------------------------------------------------
@ -327,3 +327,11 @@ isReferenceLink :: Pandoc.Inline -> Bool
isReferenceLink (Pandoc.Link _attrs text (target, _)) =
[Pandoc.Str target] /= text
isReferenceLink _ = False
--------------------------------------------------------------------------------
isVisibleBlock :: Pandoc.Block -> Bool
isVisibleBlock Pandoc.Null = False
isVisibleBlock (Pandoc.RawBlock (Pandoc.Format "html") t) =
not ("<!--" `L.isPrefixOf` t && "-->" `L.isSuffixOf` t)
isVisibleBlock _ = True

View File

@ -1,4 +1,4 @@
resolver: lts-11.5
resolver: lts-11.7
packages:
- '.'
flags:
@ -7,3 +7,4 @@ flags:
extra-deps:
- 'pandoc-2.2'
- 'pandoc-types-1.17.4.2'
- 'haddock-library-1.5.0.1'

16
tests/comments.md Normal file
View File

@ -0,0 +1,16 @@
# This is a test
Hello world
<!--
This is a comment so please don't include it.
-->
# This is a second slide
<!--- Differently-formatted comment -->
Where are my raw blocks at
<!-- Differently-formatted
comment -->

8
tests/comments.md.dump Normal file
View File

@ -0,0 +1,8 @@
# This is a test
Hello world
----------
# This is a second slide
Where are my raw blocks at