累 死 累 活 干 不 过做 PPT的 !
> 查看效果 :https://nodeppt.js.org
nodeppt 2.0
npm install -g nodeppt
- bug fix
增加 多 页编辑公共 资源,说人话就是 splitChunks
简化
- new:
使用 线上模 板 创建一 个新的 md文 件 - serve:启动
一 个 md文 件 的 webpack dev server - build:编译产出
一 个 md文 件
# create a new slide with an official template
$ nodeppt new slide.md
# create a new slide straight from a github template
$ nodeppt new slide.md -t username/repo
# start local sever show slide
$ nodeppt serve slide.md
# to build a slide
$ nodeppt build slide.md
# help
nodeppt -h
# 获取帮助
nodeppt serve -h
nodeppt ?mode=speaker
- Page: ↑/↓/←/→ Space Home End
- Fullscreen: F
- Overview: -/+
- Speaker Note: N
- Grid Background: Enter
如果项目public
webpack dev server
contentBase
选项。
build
dist
这里说下怎么编写。
<slide>
nodeppt
title: nodeppt markdown 演 示
speaker: 三水 清
url: https://github.com/ksky521/nodeppt
js:
- https://www.echartsjs.com/asset/theme/shine.js
prismTheme: solarizedlight
plugins:
- echarts
- mermaid
- katex
- title:
演 讲主题 - speaker:
演 讲者 - url:
地 址 - js:js
文 件数 组,放 到 body之 前 - css:css
文 件数 组,放 到 头部 - prismTheme:prism
配色 ,取 值范围['dark', 'coy', 'funky', 'okaidia', 'tomorrow', 'solarizedlight', 'twilight']
- plugins:
目前 支持 echarts,mermaid和 katex三 个插件
echarts yaml
fence
语法,如下:
{
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line'
}]
}
mermaid yaml
fence
语法,如下:
sequenceDiagram
Alice ->> Bob: Hello Bob, how are you?
Bob-->>John: How about you John?
Bob--x Alice: I am good thanks!
Bob-x John: I am good thanks!
Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
Bob-->Alice: Checking with John...
Alice->John: Yes... John, how are you?
nodeppt <slide>
对整个 markdown <slide>
标签
- class/style
等 :正常 的 class 类,可 以通过这个控制 居中 (aligncenter),内容 位置 ,背景 色 等 - image:
背景 图片,基本 语法image="img_url"
- video:
背景 视频,基本 语法video="video_src1,video_src2"
- :class:wrap
的 class,下面 详解
<section class="slide" attrs...><div class="wrap" wrap="true">// 具体 markdown 渲染的 内容 </div></section>
其中<slide>
class
<section>
标签:class
则被div.wrap
<slide :class="size-50" class="bg-primary"></slide>
output 为:
<section class="slide bg-primary"><div class="wrap size-50" wrap="true">// 具体 markdown 渲染的 内容 </div></section>
<slide>
image
<slide image="https://source.unsplash.com/UJbHNoVPZW0/">
# 这是一个普通的背景图
<slide image="https://source.unsplash.com/UJbHNoVPZW0/ .dark">
# 这张背景 图会在 图片上面 蒙 一层偏黑色的透明层
<slide image="https://source.unsplash.com/UJbHNoVPZW0/ .light">
# 这张背景 图会在 图片上面 蒙 一层偏白色的透明层
<slide class="bg-black aligncenter" image="https://source.unsplash.com/n9WPPWiPPJw/ .anim">
# 这张背景 图会缓慢动
样式
nodeppt 这次webslides
attribute
,
其中:..class
{.class1.class2}
这种
# header {.style-me.class2}
paragraph {data-toggle=modal}
Output:
<h1 class="style-me class2">header</h1>
<p data-toggle="modal">paragraph</p>
Use the css-module green on this paragraph. {.text-intro}
Output:
<p class="text-intro">Use the css-module green on this paragraph.</p>
- list item **bold** {.red}
Output:
<ul>
<li class="red">list item <strong>bold</strong></li>
</ul>
- list item **bold**
{.red}
Output:
<ul class="red">
<li>list item <strong>bold</strong></li>
</ul>
对于 image ,!![](图片
,
!![](https://webslides.tv/static/images/iphone.png .size-50.alignleft)
Output:
<img src="https://webslides.tv/static/images/iphone.png" class="size-50 alignleft" />
!![figure](https://webslides.tv/static/images/setup.png .aligncenter)
Output:
<figure><img src="https://webslides.tv/static/images/setup.png" class="aligncenter" /></figure>
nodeppt link
语法
[普通 按钮](){.button} [圆角普通 按钮](){.button.radius}
[空 心 ](){.button.ghost} [:fa-github: 前面 带 icon](){.button}
nodeppt
:fa-xxx:
→<i class="fa fa-xxx"></i>
:~fa-xxx:~
→<span><i class="fa fa-xxx"></i></span>
::fa-xxx::
→ 块级<i class="fa fa-xxx"></i>
,即 不 会 被 p
包 裹
attr
语法,
:span:
:span: {.text-span}
nodeppt 一如既往的支持动效,2.0
- fadeIn
- zoomIn
- rollIn
- moveIn
- fadeInUp
- slow
.build
.tobuild+动效 class
按照惯例,nodeppt 还animate.css
详细查看
:::
语法
:::div {.content-left}
## title
:::
Output:
<div class="content-left"><h2>title</h2></div>
还tag
- card:卡片,
一 边是图片,一 边是内容 - column:column
多 栏布局 - shadowbox:带阴
影 的 盒子 - steps:
步 骤组件 - cta:
- gallery:图片
- flexblock:flex block
布 局 ,支持 多 个子类型 - note:
演 讲注释
:::TYPE {.attrs}
## 第 一 部分
使用 hr 标签隔开
---
## 第 二 部分
这里的 内容 也是哦
:::
详细
chrome 浏览command+P/ctrl+P
如果
nodeppt.config.js
webpack
config.js
/**
* @file 默 认配置
*/
module.exports = () => ({
// project deployment base
baseUrl: '/',
// where to output built files
outputDir: 'dist',
// where to put static assets (js/css/img/font/...)
assetsDir: '',
// filename for index.html (relative to outputDir)
indexPath: 'index.html',
// 插件,包括 markdown 和 posthtml
plugins: [],
// chainWebpack: [],
// whether filename will contain hash part
filenameHashing: true,
// boolean, use full build?
runtimeCompiler: false,
// deps to transpile
transpileDependencies: [
/* string or regex */
],
// sourceMap for production build?
productionSourceMap: true,
// use thread-loader for babel & TS in production build
// enabled by default if the machine has more than 1 cores
parallel: () => {
try {
return require('os').cpus().length > 1;
} catch (e) {
return false;
}
},
// multi-page config
pages: undefined,
// <script type="module" crossorigin="use-credentials">
// #1656, #1867, #2025
crossorigin: undefined,
// subresource integrity
integrity: false,
css: {
extract: true
// modules: false,
// localIdentName: '[name]_[local]_[hash:base64:5]',
// sourceMap: false,
// loaderOptions: {}
},
devServer: {
/*
host: '0.0.0.0',
port: 8080,
https: false,
proxy: null, // string | Object
before: app => {}
*/
}
});
markdown-it
posthtml
,
- markdown-it:
是 解析 markdown文 件 的 ,如果是 增强 markdown 语法,可 以用这类插件 - posthtml:
是 处理 html 标签的 ,如果是 修 改 输出的 html内容 ,可 以用这类插件
module.exports = {
// 这里的 id 必须以 markdown/posthtml开头
// 分 别对应 markdown-it和 posthtml 插件语法
id: 'markdown-xxx',
// 这里的 apply 是 插件实际的 内容 ,详细查看 markdown-it和 posthtml 插件开发
apply: () => {}
};
WebSlides 插件window.WSPlugins_
js: - webslide_plugins.js
// webslide_plugins.js内容
window.WSPlugins_ = [
{
id: 'webslide_plugin_name',
// 下面 是 对应的 插件类
apply: class Plugin {}
}
];
nodeppt new username/repo xxx.md