Skip to content

Commit

Permalink
添加note支持,键盘[n]键有惊喜哦~
Browse files Browse the repository at this point in the history
  • Loading branch information
ksky521 committed Sep 12, 2013
1 parent 1e65bc7 commit 1101ee6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
21 changes: 16 additions & 5 deletions lib/md_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ var parser = function(string, callback) {
var contents = string.split('[slide]');
//第一个是封面
var cover = contents.shift();

var json = parseCover(cover);
var config = require(path.join(libDir, '../package.json'));
json.nodeppt_version = config.version
json.nodeppt_site = config.site;
json = mix(defaultJSON, json);

var slides = [];
var reg = /\[note\]([\s\S]+)\[\/note\]/im;
contents.forEach(function(v) {
slides.push(parse(marked(v)));
var note = reg.exec(v);
if (note) {
v = v.replace(reg, '');
note = marked(note[1]);
}
slides.push(parse(marked(v), note));
});
//合并
json.content = slides.join(EOL);
Expand Down Expand Up @@ -115,10 +121,15 @@ function parseCover(str) {
* @return {[type]} [description]
*/

function parse(str) {
function parse(str, note) {
var arr = str.split('<hr>');
var head = '',
article = '';
if (note && note.length > 3) {
note = '<aside class="note">\n<section>' + note + '</section>\n</aside>';
} else {
note = '';
}
if (arr.length === 2) {
head = arr[0];
article = arr[1];
Expand Down Expand Up @@ -170,7 +181,7 @@ function parse(str) {
if (bgimage) {
tagStart = '<slide class="slide fill" style="background-image:url(' + bgimage + ')">'
}
return tagStart + content + '</slide>';
return tagStart + note + content + '</slide>';
}

function do_attr(str, isArticle, noHead) {
Expand Down Expand Up @@ -232,4 +243,4 @@ function parseAttr(idinput, attrs) {
///test
// var str = fs.readFileSync('../test/basic.md').toString();

// parser(str);
// parser(str);
34 changes: 32 additions & 2 deletions ppts/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ nodeppt:https://github.com/ksky521/nodePPT
环境 |js/nodejs | Ruby | nodejs
扩展名 | .less | .sass/.scss | .styl
特点 | 老牌,用户多,支持js解析 | 功能全,有成型框架,发展快 | 语法多样,小众
案例/框架 | [Bootstrap](http://getbootstrap.com/) | [compass](http://compass-style.org) [bourbon](http://bourbon.io) |
案例/框架 | [Bootstrap](http://getbootstrap.com/) | [compass](http://compass-style.org) [bourbon](http://bourbon.io) |

[slide]

## 代码格式化
### 使用 **highlightjs**
### 使用 **highlightjs**
----

```javascript
Expand Down Expand Up @@ -87,6 +87,32 @@ nodeppt:https://github.com/ksky521/nodePPT

npm install -g feinit

[slide]
[note]
##这里是note

使用n键,才能显示
[/note]
## 使用note笔记
### note笔记是多窗口,或者自己做一些笔记用的
---
按下键盘【n】键测试下note,

markdown语法如下:
```markdown
[note]
这里是note,{ 要换成中括号啊!!
{/note]
```
[slide]

## 使用画笔
### 使用画笔做标记哦~你也可以随便作画啊!
---
按下键盘【p】键。按下鼠标左键,在此处乱花下看看效果。

按下键盘【c】键。清空画板

[slide]

## 哦 忘记说了
Expand All @@ -98,6 +124,10 @@ npm install -g feinit
* horizontal3d
* horizontal
* vertical3d
* zoomin
* zoomout

当然你可以自己写更炫的动画啊,记得pull给我动画代码哦~

[slide]
## 怎么用?
Expand Down

0 comments on commit 1101ee6

Please sign in to comment.