diff options
author | Pacien TRAN-GIRARD | 2014-08-10 17:28:37 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-08-10 17:28:37 +0200 |
commit | e7bf5952d0729b37e677168b6e8fbd1ce58ed1a2 (patch) | |
tree | 189988e3e272b806262d1df6b87f1da089ef4af8 /point/data/markdown.js | |
parent | a32e898c8d7ad3774f5654e88bb24d5c26482137 (diff) | |
download | whatsthepoint-e7bf5952d0729b37e677168b6e8fbd1ce58ed1a2.tar.gz |
Diffstat (limited to 'point/data/markdown.js')
-rw-r--r-- | point/data/markdown.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/point/data/markdown.js b/point/data/markdown.js new file mode 100644 index 0000000..38a564d --- /dev/null +++ b/point/data/markdown.js | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * This file is part of "What's The Point" <https://github.com/Pacien/WhatsThePoint> | ||
3 | * Copyright (C) 2014 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * "What's The Point" is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU Affero General Public License as | ||
7 | * published by the Free Software Foundation, either version 3 of the | ||
8 | * License, or (at your option) any later version. | ||
9 | * | ||
10 | * "What's The Point" is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | requirejs.config({ | ||
20 | shim: { | ||
21 | "markdownjs": { | ||
22 | exports: "markdown", | ||
23 | }, | ||
24 | }, | ||
25 | paths: { | ||
26 | "markdownjs": "libs/markdownjs/markdown.min", | ||
27 | }, | ||
28 | }); | ||
29 | |||
30 | define(["js-yaml", "markdownjs"], function (jsyaml, markdownjs) { | ||
31 | |||
32 | var markdown = { | ||
33 | |||
34 | init: function () { | ||
35 | return; | ||
36 | }, | ||
37 | |||
38 | renderSlide: function (slide) { | ||
39 | if (slide.content !== undefined) { | ||
40 | slide.content = markdownjs.toHTML(slide.content); | ||
41 | } | ||
42 | if (slide.notes !== undefined) { | ||
43 | slide.notes = markdownjs.toHTML(slide.notes); | ||
44 | } | ||
45 | return slide; | ||
46 | }, | ||
47 | |||
48 | parse: function (rawData, callback) { | ||
49 | var slides = []; | ||
50 | |||
51 | jsyaml.safeLoadAll(rawData, function (slide) { | ||
52 | slides.push(markdown.renderSlide(slide)); | ||
53 | }); | ||
54 | |||
55 | callback(slides); | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | return markdown; | ||
60 | |||
61 | }); | ||