Treat div with class "notes" as speaker notes in slide formats.

Currently beamer goes to `\note{}`, revealjs to `<aside class="notes">`,
and the notes are simply suppressed in other formats.

Closes #925.
This commit is contained in:
John MacFarlane 2013-10-13 15:36:19 -07:00
parent 2ae7f5e2a0
commit 0df7cce37d
3 changed files with 33 additions and 3 deletions

18
README
View file

@ -2731,6 +2731,24 @@ bibliographies:
# References {.allowframebreaks}
Speaker notes
-------------
reveal.js has good support for speaker notes. You can add notes to your
markdown document thus:
<div class="notes">
This is my note.
- It can contain markdown
- like this list
</div>
To show the notes window, press `s` while viewing the presentation.
Notes are not yet supported for other slide formats, but the notes
will not appear on the slides themselves.
Literate Haskell support
========================

View file

@ -421,9 +421,16 @@ blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do
blockToHtml opts (Para lst) = do
contents <- inlineListToHtml opts lst
return $ H.p contents
blockToHtml opts (Div attr bs) = do
blockToHtml opts (Div attr@(_,classes,_) bs) = do
contents <- blockListToHtml opts bs
return $ addAttrs opts attr $ H.div $ nl opts >> contents >> nl opts
let contents' = nl opts >> contents >> nl opts
return $
if "notes" `elem` classes
then case writerSlideVariant opts of
RevealJsSlides -> addAttrs opts attr $ H5.aside $ contents'
NoSlides -> addAttrs opts attr $ H.div $ contents'
_ -> mempty
else addAttrs opts attr $ H.div $ contents'
blockToHtml _ (RawBlock f str)
| f == Format "html" = return $ preEscapedString str
| otherwise = return mempty

View file

@ -285,7 +285,12 @@ isLineBreakOrSpace _ = False
blockToLaTeX :: Block -- ^ Block to convert
-> State WriterState Doc
blockToLaTeX Null = return empty
blockToLaTeX (Div _ bs) = blockListToLaTeX bs
blockToLaTeX (Div (_,classes,_) bs) = do
beamer <- writerBeamer `fmap` gets stOptions
contents <- blockListToLaTeX bs
if beamer && "notes" `elem` classes -- speaker notes
then return $ "\\note" <> braces contents
else return contents
blockToLaTeX (Plain lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
-- title beginning with fig: indicates that the image is a figure