marp-dev-preview 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +1 -1
- package/src/args.mjs +6 -0
- package/src/client.js +4 -4
- package/src/marp-dev-preview.mjs +7 -6
- package/src/marp-utils.mjs +6 -3
package/README.md
CHANGED
|
@@ -73,10 +73,10 @@ mdp my-slides/presentation.md --port 3000 --theme-dir my-themes
|
|
|
73
73
|
|
|
74
74
|
In addition to normal browser navigation keys (`Page Up`, `Page Down`, `Home`, `End`), the following bindings are available:
|
|
75
75
|
|
|
76
|
-
- **Ctrl+f**
|
|
77
|
-
- **Ctrl+b**
|
|
78
|
-
- **Ctrl+d** — Forward half a page
|
|
79
|
-
- **Ctrl+u** — Backward half a page
|
|
76
|
+
- **Ctrl+f** — Forward one page
|
|
77
|
+
- **Ctrl+b** — Backward one page
|
|
78
|
+
- **Ctrl+d** or **Ctrl+n** — Forward half a page
|
|
79
|
+
- **Ctrl+u** or **Ctrl+p** — Backward half a page
|
|
80
80
|
- **gg** — First slide
|
|
81
81
|
- **G** — Last slide
|
|
82
82
|
- **:number** — Jump to slide `{number}`
|
package/package.json
CHANGED
package/src/args.mjs
CHANGED
|
@@ -9,6 +9,12 @@ export function parseArgs() {
|
|
|
9
9
|
describe: 'Path to the markdown file to preview',
|
|
10
10
|
type: 'string'
|
|
11
11
|
})
|
|
12
|
+
.option('containers', {
|
|
13
|
+
alias: 'c',
|
|
14
|
+
describe: 'containers for the markdown-it-containers plugin',
|
|
15
|
+
type: 'array',
|
|
16
|
+
default: ["note", "info", "warning", "details"]
|
|
17
|
+
})
|
|
12
18
|
.option('theme-set', {
|
|
13
19
|
alias: 't',
|
|
14
20
|
describe: 'Directories for custom themes',
|
package/src/client.js
CHANGED
|
@@ -147,16 +147,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
147
147
|
} else if (e.key === 'k') {
|
|
148
148
|
window.scrollBy({ top: -window.innerHeight * 0.1, behavior: 'smooth' });
|
|
149
149
|
lastKey = '';
|
|
150
|
-
} else if (e.key === 'u' && e.ctrlKey) {
|
|
150
|
+
} else if ((e.key === 'u' || e.key === 'p') && e.ctrlKey) {
|
|
151
151
|
window.scrollBy({ top: -window.innerHeight * 0.5, behavior: 'smooth' });
|
|
152
152
|
lastKey = '';
|
|
153
|
-
} else if (e.key === 'd' && e.ctrlKey) {
|
|
153
|
+
} else if ((e.key === 'd' || e.key === 'n') && e.ctrlKey) {
|
|
154
154
|
window.scrollBy({ top: window.innerHeight * 0.5, behavior: 'smooth' });
|
|
155
155
|
lastKey = '';
|
|
156
|
-
} else if (
|
|
156
|
+
} else if (e.key === 'f' && e.ctrlKey) {
|
|
157
157
|
window.scrollBy({ top: window.innerHeight * 0.9, behavior: 'smooth' });
|
|
158
158
|
lastKey = '';
|
|
159
|
-
} else if (
|
|
159
|
+
} else if (e.key === 'b' && e.ctrlKey) {
|
|
160
160
|
window.scrollBy({ top: -window.innerHeight * 0.9, behavior: 'smooth' });
|
|
161
161
|
lastKey = '';
|
|
162
162
|
} else if (e.key === '?') {
|
package/src/marp-dev-preview.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const markdownFile = argv.markdownFile;
|
|
|
20
20
|
const themeSet = argv.themeSet;
|
|
21
21
|
const port = argv.port;
|
|
22
22
|
const verbose = argv.verbose;
|
|
23
|
+
const containers = argv.containers;
|
|
23
24
|
|
|
24
25
|
if (argv.version) {
|
|
25
26
|
const pkg = JSON.parse(await fs.readFile(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
@@ -111,10 +112,10 @@ async function renderMarp() {
|
|
|
111
112
|
<tr><td><kbd>gg</kbd> or <kbd>Home</kbd></td><td>Go to first slide</td></tr>
|
|
112
113
|
<tr><td><kbd>G</kbd> or <kbd>End</kbd></td><td>Go to last slide</td></tr>
|
|
113
114
|
<tr><td><kbd>:<number></kbd></td><td>Go to the given slide number</td></tr>
|
|
114
|
-
<tr><td><kbd>^f</kbd
|
|
115
|
-
<tr><td><kbd>^b</kbd
|
|
116
|
-
<tr><td><kbd>^d</kbd></td><td>Forward half a page</td></tr>
|
|
117
|
-
<tr><td><kbd>^u</kbd></td><td>Back half a page</td></tr>
|
|
115
|
+
<tr><td><kbd>^f</kbd></td><td>Forward one page</td></tr>
|
|
116
|
+
<tr><td><kbd>^b</kbd></td><td>Back one page</td></tr>
|
|
117
|
+
<tr><td><kbd>^d</kbd> or <kbd>^n</kbd></td><td>Forward half a page</td></tr>
|
|
118
|
+
<tr><td><kbd>^u</kbd> or <kbd>^p</kbd></td><td>Back half a page</td></tr>
|
|
118
119
|
<tr><td><kbd>?</kbd></td><td>Show/hide help</td></tr>
|
|
119
120
|
</table>
|
|
120
121
|
</div>
|
|
@@ -159,14 +160,14 @@ if (themeSet) {
|
|
|
159
160
|
console.debug('Reloading theme from file :', file);
|
|
160
161
|
|
|
161
162
|
console.debug(`Theme file ${file} changed, updating...`);
|
|
162
|
-
await initializeMarp(themeSet);
|
|
163
|
+
await initializeMarp(themeSet, containers);
|
|
163
164
|
const md = await fs.readFile(markdownFile, 'utf8');
|
|
164
165
|
await reload(md);
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
initializeMarp(themeSet).then(() => {
|
|
170
|
+
initializeMarp(themeSet, containers).then(() => {
|
|
170
171
|
const app = createServer(markdownDir, renderMarp, reload, wss, __dirname);
|
|
171
172
|
const server = http.createServer(app);
|
|
172
173
|
|
package/src/marp-utils.mjs
CHANGED
|
@@ -13,12 +13,15 @@ export function getMarp() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
export async function initializeMarp(themeSet) {
|
|
16
|
+
export async function initializeMarp(themeSet, containers) {
|
|
17
17
|
const options = { html: true, linkify: true, };
|
|
18
18
|
marp = new Marp(options)
|
|
19
19
|
.use(markdownItFootnote)
|
|
20
|
-
.use(markdownItMark)
|
|
21
|
-
|
|
20
|
+
.use(markdownItMark);
|
|
21
|
+
|
|
22
|
+
for (const container of containers) {
|
|
23
|
+
marp = marp.use(markdownItContainer, container);
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
if (!themeSet) {
|
|
24
27
|
return marp;
|