Commit 57924457 authored by Henrik Tramberend's avatar Henrik Tramberend
Browse files

Runs on Windows now and some cosmetics

parent 7104aef2
...@@ -79,7 +79,7 @@ The following text ist included from file `/resource/realtive.md`: ...@@ -79,7 +79,7 @@ The following text ist included from file `/resource/realtive.md`:
## Slide source ## Slide source
~~~ {.markdown} ~~~ {.markdown}
...
~~~ ~~~
``` ```
......
---
author: Henrik Tramberend
date: '15.5.2016'
subtitle: Tutorial and Examples
theme: 'htr-slides'
title: Decker Slide Tool
transition: linear
---
# Overview
- Features
- Installation
- Usage
- Development
# Features {.section}
# Markdown Syntax
## Pandoc-Markdown
- Slides are basically [Pandoc-Markdown](http://pandoc.org) formatted
text
- Pandoc provides a Markdown variant with many extensions
## Some Pandoc extensions
- Bibliographies
- Footnotes
- Tables
- Figures with captions
- Code blocks with syntax highlighting
- LaTeX math typesetting
# Slides
## Markdown header
- Level 1 header (`#`) starts new slide
- Level 2 header (`##`) starts a block on a slide
- Level 3 header (`###`) starts new column on a slide
``` {.markdown}
# Episode IV: A new Slide
## A long time ago ...
... in a galaxy far, far away.
```
# Includes
## Include markdown files
The following text ist included from file `/resource/realtive.md`:
[#include](/resource/relative.md)
# Multicolumn slides
## The author
![](img/htr-beuth.jpg)
###
## Slide source
``` {.markdown}
# Multicolumn slides
## The author
![](img/htr-beuth.jpg)
###
## Slide source
~~~ {.markdown}
~~~
```
# Local Images
## Relative path
![](img/06-metal.png){width=75%}
# LaTeX Math
## Syntax
- Standard LaTeX syntax
- Single \$ encloses inline math
- Double \$\$ encloses a display math block
## Example
- To $\infty$ and beyond!
$$
e = mc^2
$$
# Compile Time Macros
## Macros
- Appropriated link `[Link text](Url)` and image `![Alt text](Url)` syntax
- Example: embed a YouTube video
``` {.markdown}
## Video
[:youtube](Wji-BZ0oCwg)
```
###
## Video
[:youtube](Wji-BZ0oCwg)
# Compile Time Templating
## Mustache templates
- Markdown source code is processed with Mustache
``` {.markdown}
{{=<% %>=}}
The current semester is {{semester}}
<%={{ }}=%>
```
- Data is provided in YAML files
``` {.yaml}
---
semester: Summer 2016
---
```
- Results in
``` {.markdown}
The current semester is Summer 2016
```
# Blocks
## Block markup
- Level 2 headers start new block
- Blocks can be marked with attributes
## Alert block {.alert}
- This block is marked `alert`
``` {.markdown}
## Alert block {.alert}
- This block is marked `.alert`
```
###
...@@ -17,7 +17,7 @@ import Control.Monad ...@@ -17,7 +17,7 @@ import Control.Monad
import Control.Concurrent import Control.Concurrent
import Control.Exception import Control.Exception
import Development.Shake import Development.Shake
import Development.Shake.FilePath import Development.Shake.FilePath as SFP
import Data.Dynamic import Data.Dynamic
import Data.List.Extra import Data.List.Extra
import Data.Maybe import Data.Maybe
...@@ -34,7 +34,7 @@ import System.Process ...@@ -34,7 +34,7 @@ import System.Process
import System.Process.Internals import System.Process.Internals
import System.Directory as Dir import System.Directory as Dir
import System.Exit import System.Exit
import System.FilePath import System.FilePath as SF
import System.FilePath.Glob import System.FilePath.Glob
import qualified Data.Yaml as Y import qualified Data.Yaml as Y
import qualified Text.Mustache as M import qualified Text.Mustache as M
...@@ -137,10 +137,10 @@ runShakeInContext :: ActionContext -> ShakeOptions -> Rules () -> IO () ...@@ -137,10 +137,10 @@ runShakeInContext :: ActionContext -> ShakeOptions -> Rules () -> IO ()
runShakeInContext context options rules = runShakeInContext context options rules =
do opts <- setActionContext context options do opts <- setActionContext context options
catch (untilM_ (tryRunShake opts) nothingToWatch) catch (untilM_ (tryRunShake opts) nothingToWatch)
(\(SomeException e) -> putStrLn $ "Terminated: " ++ (show e)) (\(SomeException e) -> putStrLn $ "Terminated: " ++ show e)
cleanup cleanup
where tryRunShake opts = where tryRunShake opts =
do catch (shakeArgs opts rules) catch (shakeArgs opts rules)
(\(SomeException e) -> return ()) (\(SomeException e) -> return ())
cleanup = cleanup =
do process <- readIORef $ ctxServerHandle context do process <- readIORef $ ctxServerHandle context
...@@ -154,7 +154,7 @@ runShakeInContext context options rules = ...@@ -154,7 +154,7 @@ runShakeInContext context options rules =
else do waitForTwitch files else do waitForTwitch files
return False return False
watchFiles files = setFilesToWatch files watchFiles = setFilesToWatch
-- | Actively waits for the first change to any member in the set of specified -- | Actively waits for the first change to any member in the set of specified
...@@ -295,10 +295,10 @@ getRelativeSupportDir from = ...@@ -295,10 +295,10 @@ getRelativeSupportDir from =
invertPath invertPath
(makeRelative publicDir (makeRelative publicDir
(takeDirectory from)) </> (takeDirectory from)) </>
(makeRelative publicDir supportDir) makeRelative publicDir supportDir
invertPath :: FilePath -> FilePath invertPath :: FilePath -> FilePath
invertPath fp = joinPath $ map (\_ -> "..") $ filter ((/=) ".") $ splitPath fp invertPath fp = joinPath $ map (const "..") $ filter ("." /=) $ splitPath fp
-- | Write a markdown file to a HTML file using the page template. -- | Write a markdown file to a HTML file using the page template.
markdownToHtmlDeck markdownToHtmlDeck
...@@ -484,14 +484,14 @@ isCacheableURI url = ...@@ -484,14 +484,14 @@ isCacheableURI url =
-- relative to the containing document. -- relative to the containing document.
adjustImageUrls :: FilePath -> FilePath -> Pandoc -> Pandoc adjustImageUrls :: FilePath -> FilePath -> Pandoc -> Pandoc
adjustImageUrls projectDir baseDir pandoc = adjustImageUrls projectDir baseDir =
(walk adjustBlock . walk adjustInline) pandoc walk adjustBlock . walk adjustInline
where where
adjustInline (Image attr inlines (url,title)) = adjustInline (Image attr inlines (url,title)) =
(Image attr inlines (adjustLocalUrl projectDir baseDir url, title)) Image attr inlines (adjustLocalUrl projectDir baseDir url, title)
adjustInline other = other adjustInline other = other
adjustBlock (Header 1 attr inlines) = adjustBlock (Header 1 attr inlines) =
(Header 1 (adjustBgImageUrl attr) inlines) Header 1 (adjustBgImageUrl attr) inlines
adjustBlock other = other adjustBlock other = other
adjustBgImageUrl (i,cs,kvs) = adjustBgImageUrl (i,cs,kvs) =
( i ( i
...@@ -538,7 +538,7 @@ processIncludes rootDir baseDir (Pandoc meta blocks) = do ...@@ -538,7 +538,7 @@ processIncludes rootDir baseDir (Pandoc meta blocks) = do
include _ result block = return $ [block] : result include _ result block = return $ [block] : result
cacheRemoteImages :: FilePath -> Pandoc -> IO Pandoc cacheRemoteImages :: FilePath -> Pandoc -> IO Pandoc
cacheRemoteImages cacheDir pandoc = walkM cacheRemoteImage pandoc cacheRemoteImages cacheDir = walkM cacheRemoteImage
where where
cacheRemoteImage (Image attr inlines (url,title)) = do cacheRemoteImage (Image attr inlines (url,title)) = do
cachedFile <- cacheRemoteFile cacheDir url cachedFile <- cacheRemoteFile cacheDir url
...@@ -586,7 +586,7 @@ downloadUrl url = do ...@@ -586,7 +586,7 @@ downloadUrl url = do
" " ++ B.unpack (statusMessage status) ++ ")" " " ++ B.unpack (statusMessage status) ++ ")"
hashURI :: String -> String hashURI :: String -> String
hashURI uri = (show $ md5 $ L8.pack uri) <.> takeExtension uri hashURI uri = show (md5 $ L8.pack uri) SF.<.> SF.takeExtension uri
processPandocPage processPandocPage
:: String -> Pandoc -> Action Pandoc :: String -> Pandoc -> Action Pandoc
...@@ -672,7 +672,7 @@ makeRelativeTo dir file = ...@@ -672,7 +672,7 @@ makeRelativeTo dir file =
let (d,fd) = let (d,fd) =
removeCommonPrefix (splitPath dir) (splitPath (takeDirectory file)) removeCommonPrefix (splitPath dir) (splitPath (takeDirectory file))
in normalise $ in normalise $
invertPath (joinPath d) </> (joinPath fd) </> (takeFileName file) invertPath (joinPath d) </> joinPath fd </> takeFileName file
where where
removeCommonPrefix al@(a:as) bl@(b:bs) = removeCommonPrefix al@(a:as) bl@(b:bs) =
if a == b if a == b
...@@ -702,7 +702,7 @@ writeEmbeddedFiles files dir = do ...@@ -702,7 +702,7 @@ writeEmbeddedFiles files dir = do
write (path,contents) = do write (path,contents) = do
liftIO $ Dir.createDirectoryIfMissing True (takeDirectory path) liftIO $ Dir.createDirectoryIfMissing True (takeDirectory path)
exists <- liftIO $ Dir.doesFileExist path exists <- liftIO $ Dir.doesFileExist path
when (not exists) $ liftIO $ B.writeFile path contents unless exists $ liftIO $ B.writeFile path contents
lookupValue :: String -> Y.Value -> Maybe Y.Value lookupValue :: String -> Y.Value -> Maybe Y.Value
lookupValue key (Y.Object hashTable) = lookupValue key (Y.Object hashTable) =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment