-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vextab.hs
52 lines (46 loc) · 1.59 KB
/
Vextab.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module Vextab (plugin) where
{-
This plugin lays the groundwork for rendered musical notation output in the
html of wiki pages. It does so by taking the contents of code block with
specific classes, and placing the conents into HTML div elements with a special
class name. Example below:
```{.vexchord}
position 3
bar 2 1 1
string 5 0
string 4 3
string 3 2
string 6 x
```
License: GPL
written by Kohei OZAKI <i@smly.org>
modified by John MacFarlane to use withTempDir
modified by Kyle Robertson to acomplish a totally different goal
with the same basic functionality
-}
import Network.Gitit.Interface
import System.Process (system)
import System.Directory
import Data.ByteString.Lazy.UTF8 (fromString)
import Data.Digest.Pure.SHA
import System.FilePath
import Control.Monad.Trans (liftIO)
-- plugin has type Plugin, defined in Network.Gitit.Interface
plugin :: Plugin
-- Calls mkPageTransformM on transformBlock and assigns it to plugin
plugin = mkPageTransformM transformBlock
transformBlock :: Block -> PluginM Block
transformBlock (CodeBlock (_, classes, namevals) contents)
| "vextab" `elem` classes = do
cfg <- askConfig
let text = concat ["<div class=vex-tabdivinit>\n", contents, "\n</div>"]
return $ RawBlock (Format "html") text
| "vexfretboard" `elem` classes = do
cfg <- askConfig
let text = concat ["<div class=vex-fretdiv>\n", contents, "\n</div>"]
return $ RawBlock (Format "html") text
| "vexchord" `elem` classes = do
cfg <- askConfig
let text = concat ["<div class=vex-chorddiv>\n", contents, "\n</div>"]
return $ RawBlock (Format "html") text
transformBlock x = return x