@tblaisot/prez-as-adoc 0.0.2 → 0.0.3
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.adoc +2 -2
- package/asciidoctor/extensions/index.js +2 -0
- package/asciidoctor/templates/admonition.js +2 -3
- package/asciidoctor/templates/document.js +36 -37
- package/asciidoctor/templates/index.cjs +9 -0
- package/asciidoctor/templates/preamble.js +7 -8
- package/asciidoctor/templates/section.js +23 -24
- package/asciidoctor/templates/slide.js +4 -5
- package/asciidoctor/templates/speaker_note.js +8 -9
- package/asciidoctor/templates/title.js +15 -19
- package/bespoke-plugins/index.js +9 -0
- package/package.json +10 -6
- package/vite-plugins/index.js +1 -0
- package/{vitejs/plugins → vite-plugins}/prez-as-adoc-plugin.js +5 -4
package/README.adoc
CHANGED
|
@@ -19,12 +19,12 @@ prez-as-adoc --base_dir=./src --to_dir=./dist --slides-templates=./slide-templat
|
|
|
19
19
|
[source,bash]
|
|
20
20
|
----
|
|
21
21
|
// vite.config.js
|
|
22
|
-
import {
|
|
22
|
+
import { prezAsAdoc } from '@tblaisot/prez-as-adoc/vite-plugins'
|
|
23
23
|
import { defineConfig } from 'vite'
|
|
24
24
|
|
|
25
25
|
export default defineConfig({
|
|
26
26
|
plugins: [
|
|
27
|
-
|
|
27
|
+
prezAsAdoc({ slidesTemplates: ['./slide-templates'] })
|
|
28
28
|
]
|
|
29
29
|
})
|
|
30
30
|
----
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const {$aside} = HELPERS;
|
|
1
|
+
const {admonition: admonition_template} = require("@tblaisot/asciidoctorjs-templates-js/templates");
|
|
2
|
+
const {$aside} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
4
3
|
|
|
5
4
|
module.exports = function ({node}) {
|
|
6
5
|
if (node.hasRole('speaker')) {
|
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {$, $metaIf, toAttribute, toAttributes,isEmptyString} = HELPERS;
|
|
1
|
+
const {$, $metaIf, toAttribute, toAttributes, isEmptyString} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
3
2
|
|
|
4
3
|
function getFavicon(node) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let favicon = ''
|
|
5
|
+
if (node.document.hasAttribute('favicon')) {
|
|
6
|
+
let icon_href = node.document.getAttribute('favicon');
|
|
7
|
+
if (isEmptyString(icon_href)) {
|
|
8
|
+
icon_href = 'favicon.ico';
|
|
9
|
+
}
|
|
10
|
+
const icon_ext = icon_href.split('.').pop();
|
|
11
|
+
const icon_type = icon_ext === 'ico' ? 'image/x-icon' : `image/${icon_ext}`;
|
|
12
|
+
favicon = $('link', {rel: "icon", type: icon_type, href: icon_href});
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
const icon_type = icon_ext === 'ico' ? 'image/x-icon' : `image/${icon_ext}`;
|
|
13
|
-
favicon = $('link', {rel: "icon", type: icon_type, href: icon_href});
|
|
14
|
-
}
|
|
15
|
-
return favicon
|
|
14
|
+
return favicon
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
// false needs to be verbatim everything else is a string.
|
|
19
18
|
// Calling side isn't responsible for quoting so we are doing it here
|
|
20
19
|
function toValidSlideNumber(val) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
// corner case: empty is empty attribute which is true
|
|
21
|
+
if (val === "") {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// using toString here handles both the 'false' string and the false boolean
|
|
25
|
+
return val.toString() === 'false' ? false : `'${val}'`
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* Returns formatted style/link and script tags for header.
|
|
31
30
|
*/
|
|
32
31
|
module.exports = function ({node}) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const document_content = node.getContent();
|
|
33
|
+
let docinfo_content_header = node.getDocinfo('header', '.html');
|
|
34
|
+
let docinfo_content_head = node.getDocinfo('head', '.html');
|
|
35
|
+
let docinfo_content_footer = node.getDocinfo('footer', '.html');
|
|
37
36
|
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
if (node.getNoheader() || isEmptyString(docinfo_content_header)) {
|
|
39
|
+
docinfo_content_header = '';
|
|
40
|
+
}
|
|
41
|
+
if (isEmptyString(docinfo_content_footer)) {
|
|
42
|
+
docinfo_content_footer = '';
|
|
43
|
+
}
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const scripts = node.getAttribute('scripts', '').split(',').map(script => `<script type="module" src="${script}"></script>`)
|
|
46
|
+
const stylesheets = node.getAttribute('stylesheets', '').split(',').map(style => `<link rel="stylesheet" type="text/css" href="${style}">`)
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
return `
|
|
50
49
|
<!DOCTYPE html>
|
|
51
50
|
<html ${toAttribute('lang', node.hasAttribute('nolang') ? '' : node.getAttribute('lang', 'en'))}>
|
|
52
51
|
<head>
|
|
@@ -64,12 +63,12 @@ module.exports = function ({node}) {
|
|
|
64
63
|
${docinfo_content_head}
|
|
65
64
|
</head>
|
|
66
65
|
<body ${toAttributes({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
id: node.getId(),
|
|
67
|
+
class: [
|
|
68
|
+
node.getAttribute('doctype'),
|
|
69
|
+
node.getAttribute('docrole') || node.getAttribute('role'),
|
|
70
|
+
]
|
|
71
|
+
})}>
|
|
73
72
|
${docinfo_content_header}
|
|
74
73
|
<div class="slides">
|
|
75
74
|
<!-- START CONTENT -->
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
admonition: require('./admonition.js'),
|
|
3
|
+
document: require('./document.js'),
|
|
4
|
+
preamble: require('./preamble.js'),
|
|
5
|
+
section: require('./section.js'),
|
|
6
|
+
slide: require('./slide.js'),
|
|
7
|
+
speaker_note: require('./speaker_note.js'),
|
|
8
|
+
title: require('./title.js'),
|
|
9
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {$section} = HELPERS;
|
|
1
|
+
const {$section} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
3
2
|
|
|
4
3
|
module.exports = function ({node}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
return $section({
|
|
5
|
+
id: 'preamble',
|
|
6
|
+
'aria-label': 'Preamble'
|
|
7
|
+
},
|
|
8
|
+
node.getContent()
|
|
9
|
+
);
|
|
11
10
|
}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {$h, $a, $section, sectionTitle,isDefined} = HELPERS;
|
|
1
|
+
const {$h, $a, $section, sectionTitle, isDefined} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
3
2
|
|
|
4
3
|
module.exports = function ({node}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
let content = '';
|
|
5
|
+
if (isDefined(node.getId())) {
|
|
6
|
+
if (node.document.hasAttribute('sectanchors')) {
|
|
7
|
+
content += $a({class: "anchor", href: `#${node.getId()}`, 'aria-hidden': "true"})
|
|
8
|
+
}
|
|
9
|
+
if (node.document.hasAttribute('sectlinks')) {
|
|
10
|
+
content += $a({class: "link", href: `#${node.getId()}`}, sectionTitle(node))
|
|
11
|
+
} else {
|
|
12
|
+
content += sectionTitle(node)
|
|
13
|
+
}
|
|
12
14
|
} else {
|
|
13
|
-
|
|
15
|
+
content += sectionTitle(node)
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
),
|
|
27
|
-
node.getContent()
|
|
28
|
-
)
|
|
17
|
+
return $section({
|
|
18
|
+
class: ['doc-section', `level-${node.getLevel()}`, node.getRole()],
|
|
19
|
+
},
|
|
20
|
+
$h({
|
|
21
|
+
level: node.getLevel() + 1,
|
|
22
|
+
id: node.getId()
|
|
23
|
+
},
|
|
24
|
+
content
|
|
25
|
+
),
|
|
26
|
+
node.getContent()
|
|
27
|
+
)
|
|
29
28
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const {resolve} = require("path");
|
|
2
2
|
const {readFileSync, existsSync} = require("fs");
|
|
3
|
-
const {
|
|
4
|
-
const {$, isEmptyString} = HELPERS;
|
|
3
|
+
const {$, isEmptyString} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
5
4
|
|
|
6
5
|
function resolveTemplate(paths, templateName) {
|
|
7
6
|
// find in folders
|
|
8
|
-
for(let path of paths){
|
|
9
|
-
const templatePath = resolve(path
|
|
10
|
-
if(existsSync(templatePath)){
|
|
7
|
+
for (let path of paths) {
|
|
8
|
+
const templatePath = resolve(path, `${templateName}-slide.html`)
|
|
9
|
+
if (existsSync(templatePath)) {
|
|
11
10
|
return readFileSync(templatePath, {encoding: 'utf-8'});
|
|
12
11
|
}
|
|
13
12
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {$} = HELPERS;
|
|
1
|
+
const {$} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
3
2
|
|
|
4
3
|
module.exports = function ({node}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
return $('aside',
|
|
5
|
+
{
|
|
6
|
+
id: node.getId(),
|
|
7
|
+
class: ['speaker-notes'],
|
|
8
|
+
},
|
|
9
|
+
node.getBlocks().map(block => block.convert()).join('\n')
|
|
10
|
+
)
|
|
12
11
|
}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {$, $h, $a, isDefined, sectionTitle} = HELPERS;
|
|
1
|
+
const {$h, $a, isDefined} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
|
|
3
2
|
|
|
4
3
|
module.exports = function ({node}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
let content = '';
|
|
5
|
+
if (isDefined(node.getId())) {
|
|
6
|
+
if (node.document.hasAttribute('sectanchors')) {
|
|
7
|
+
content += $a({class: "anchor", href: `#${node.getId()}`, 'aria-hidden': "true"})
|
|
8
|
+
}
|
|
9
|
+
if (node.document.hasAttribute('sectlinks')) {
|
|
10
|
+
content += $a({class: "link", href: `#${node.getId()}`}, node.getContent())
|
|
11
|
+
} else {
|
|
12
|
+
content += node.getContent()
|
|
13
|
+
}
|
|
12
14
|
} else {
|
|
13
|
-
|
|
15
|
+
content += node.getContent()
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return $h({
|
|
19
|
-
level: node.getAttribute('level') + 1,
|
|
20
|
-
id: node.getId()
|
|
21
|
-
},
|
|
22
|
-
content
|
|
23
|
-
);
|
|
17
|
+
return $h({
|
|
18
|
+
level: node.getAttribute('level') + 1, id: node.getId()
|
|
19
|
+
}, content);
|
|
24
20
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export scale from './bespoke-scale.js';
|
|
2
|
+
export nav from './bespoke-nav.js';
|
|
3
|
+
export speaker from './bespoke-speaker.js';
|
|
4
|
+
export classes from './bespoke-classes.js';
|
|
5
|
+
export progress from './bespoke-progress.js';
|
|
6
|
+
export debug from './bespoke-debug.js';
|
|
7
|
+
export editor from './bespoke-editor.js';
|
|
8
|
+
export hash from './bespoke-hash.js';
|
|
9
|
+
export viewMode from './bespoke-view-mode.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tblaisot/prez-as-adoc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
"prez-as-adoc": "bin/prez-as-adoc.js"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"import": "./index.mjs"
|
|
14
|
+
"./asciidoctor-extensions": {
|
|
15
|
+
"import": "./asciidoctor/extensions/index.js"
|
|
17
16
|
},
|
|
18
|
-
"./
|
|
17
|
+
"./vite-plugins": {
|
|
18
|
+
"import": "./vite-plugins/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./bespoke-plugins": {
|
|
21
|
+
"import": "./bespoke-plugins/index.js"
|
|
22
|
+
}
|
|
19
23
|
},
|
|
20
24
|
"keywords": [
|
|
21
25
|
"cli"
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"author": "",
|
|
24
28
|
"license": "ISC",
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@tblaisot/asciidoctorjs-templates-js": "^0.0.
|
|
30
|
+
"@tblaisot/asciidoctorjs-templates-js": "^0.0.2",
|
|
27
31
|
"arg": "^5.0.2",
|
|
28
32
|
"node-html-parser": "^6.1.5",
|
|
29
33
|
"vite": "^4.2.1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {prezAsAdoc} from './prez-as-adoc-plugin.js'
|
|
@@ -2,12 +2,13 @@ import {HTMLElement, parse as parseHTML, TextNode} from 'node-html-parser';
|
|
|
2
2
|
import {asciidoctor, BASE_OPTIONS, HELPERS, REGISTRY} from "@tblaisot/asciidoctorjs-templates-js";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import * as url from 'url';
|
|
5
|
-
import
|
|
6
|
-
import * as speakerNotesTreeprocessor from "../../asciidoctor/extensions/speaker_notes_treeprocessor.js";
|
|
5
|
+
import {slidesTreeprocessor, speakerNotesTreeprocessor} from "../asciidoctor/extensions/index.js";
|
|
7
6
|
|
|
8
7
|
const {$, isEmptyString} = HELPERS;
|
|
9
8
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
10
9
|
|
|
10
|
+
const ASCIIDOCTOR_TEMPLATES_PATH = '../asciidoctor/templates';
|
|
11
|
+
|
|
11
12
|
slidesTreeprocessor.register(REGISTRY);
|
|
12
13
|
speakerNotesTreeprocessor.register(REGISTRY);
|
|
13
14
|
|
|
@@ -53,7 +54,7 @@ function transformIndexHtml(
|
|
|
53
54
|
const document = parseHTML(html);
|
|
54
55
|
|
|
55
56
|
|
|
56
|
-
const template_dirs = [...BASE_OPTIONS.template_dirs, path.resolve(__dirname,
|
|
57
|
+
const template_dirs = [...BASE_OPTIONS.template_dirs, path.resolve(__dirname, ASCIIDOCTOR_TEMPLATES_PATH)]
|
|
57
58
|
if (asciidoctorTemplatesOverloads && asciidoctorTemplatesOverloads.length > 0) {
|
|
58
59
|
asciidoctorTemplatesOverloads.forEach(overload => {
|
|
59
60
|
template_dirs.push(path.resolve(process.cwd(), overload));
|
|
@@ -105,7 +106,7 @@ function transformIndexHtml(
|
|
|
105
106
|
return document.toString();
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
export const
|
|
109
|
+
export const prezAsAdoc = (options) => {
|
|
109
110
|
return {
|
|
110
111
|
name: 'prez-as-adoc',
|
|
111
112
|
transformIndexHtml: transformIndexHtml.bind(null, options),
|