@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 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 { prezAsAdocPlugin } from '@tblaisot/prez-as-adoc/vitejs/plugins/prez-as-adoc-plugin.js'
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
- prezAsAdocPlugin({slidesTemplates: ['./slide-templates']})
27
+ prezAsAdoc({ slidesTemplates: ['./slide-templates'] })
28
28
  ]
29
29
  })
30
30
  ----
@@ -0,0 +1,2 @@
1
+ export * as slidesTreeprocessor from "./slides_treeprocessor.js";
2
+ export * as speakerNotesTreeprocessor from "./speaker_notes_treeprocessor.js";
@@ -1,6 +1,5 @@
1
- const {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
2
- const {admonition: admonition_template} = TEMPLATES;
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 {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
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
- let favicon = ''
6
- if (node.document.hasAttribute('favicon')) {
7
- let icon_href = node.document.getAttribute('favicon');
8
- if (isEmptyString(icon_href)) {
9
- icon_href = 'favicon.ico';
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
- const icon_ext = icon_href.split('.').pop();
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
- // corner case: empty is empty attribute which is true
22
- if (val === "") {
23
- return true;
24
- }
25
- // using toString here handles both the 'false' string and the false boolean
26
- return val.toString() === 'false' ? false : `'${val}'`
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
- const document_content = node.getContent();
34
- let docinfo_content_header = node.getDocinfo('header', '.html');
35
- let docinfo_content_head = node.getDocinfo('head', '.html');
36
- let docinfo_content_footer = node.getDocinfo('footer', '.html');
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
- if (node.getNoheader() || isEmptyString(docinfo_content_header)) {
40
- docinfo_content_header = '';
41
- }
42
- if (isEmptyString(docinfo_content_footer)) {
43
- docinfo_content_footer = '';
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
- const scripts=node.getAttribute('scripts', '').split(',').map(script => `<script type="module" src="${script}"></script>`)
47
- const stylesheets=node.getAttribute('stylesheets', '').split(',').map(style => `<link rel="stylesheet" type="text/css" href="${style}">`)
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
- return `
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
- id: node.getId(),
68
- class: [
69
- node.getAttribute('doctype'),
70
- node.getAttribute('docrole') || node.getAttribute('role'),
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 {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
2
- const {$section} = HELPERS;
1
+ const {$section} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
3
2
 
4
3
  module.exports = function ({node}) {
5
- return $section({
6
- id: 'preamble',
7
- 'aria-label': 'Preamble'
8
- },
9
- node.getContent()
10
- );
4
+ return $section({
5
+ id: 'preamble',
6
+ 'aria-label': 'Preamble'
7
+ },
8
+ node.getContent()
9
+ );
11
10
  }
@@ -1,29 +1,28 @@
1
- const {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctor-js-templates");
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
- let content = '';
6
- if (isDefined(node.getId())) {
7
- if (node.document.hasAttribute('sectanchors')) {
8
- content += $a({class: "anchor", href: `#${node.getId()}`, 'aria-hidden': "true"})
9
- }
10
- if (node.document.hasAttribute('sectlinks')) {
11
- content += $a({class: "link", href: `#${node.getId()}`}, sectionTitle(node))
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
- content += sectionTitle(node)
15
+ content += sectionTitle(node)
14
16
  }
15
- } else {
16
- content += sectionTitle(node)
17
- }
18
- return $section({
19
- class: ['doc-section', `level-${node.getLevel()}`, node.getRole()],
20
- },
21
- $h({
22
- level: node.getLevel() + 1,
23
- id: node.getId()
24
- },
25
- content
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 {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
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,`${templateName}-slide.html`)
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 {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
2
- const {$} = HELPERS;
1
+ const {$} = require("@tblaisot/asciidoctorjs-templates-js/helpers");
3
2
 
4
3
  module.exports = function ({node}) {
5
- return $('aside',
6
- {
7
- id: node.getId(),
8
- class: ['speaker-notes'],
9
- },
10
- node.getBlocks().map(block => block.convert()).join('\n')
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 {HELPERS, TEMPLATES} = require("@tblaisot/asciidoctorjs-templates-js");
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
- let content = '';
6
- if (isDefined(node.getId())) {
7
- if (node.document.hasAttribute('sectanchors')) {
8
- content += $a({class: "anchor", href: `#${node.getId()}`, 'aria-hidden': "true"})
9
- }
10
- if (node.document.hasAttribute('sectlinks')) {
11
- content += $a({class: "link", href: `#${node.getId()}`}, node.getContent())
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
- content += node.getContent()
15
+ content += node.getContent()
14
16
  }
15
- } else {
16
- content += node.getContent()
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.2",
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
- "require": "./index.cjs",
16
- "import": "./index.mjs"
14
+ "./asciidoctor-extensions": {
15
+ "import": "./asciidoctor/extensions/index.js"
17
16
  },
18
- "./vitejs/plugins/prez-as-adoc-plugin.js": "./vitejs/plugins/prez-as-adoc-plugin.js"
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.1",
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 * as slidesTreeprocessor from "../../asciidoctor/extensions/slides_treeprocessor.js";
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, '../../asciidoctor/templates')]
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 prezAsAdocPlugin = (options) => {
109
+ export const prezAsAdoc = (options) => {
109
110
  return {
110
111
  name: 'prez-as-adoc',
111
112
  transformIndexHtml: transformIndexHtml.bind(null, options),