wikity 1.3.5 → 1.3.6

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/dist/compile.js CHANGED
@@ -49,7 +49,7 @@ function compile(dir = '.', config = {}) {
49
49
  // Create TOC
50
50
  if (!metadata.notoc && (metadata.toc || (((_a = outText.match(/<h\d[^>]*>/g)) === null || _a === void 0 ? void 0 : _a.length) || 0) > 3)) {
51
51
  let toc = '';
52
- let headings = Array.from(parsedContent.match(/<h\d[^>]*>.+?<\/h\d>/gs) || []);
52
+ let headings = Array.from(parsedContent.match(/<h\d auto[^>]*>.+?<\/h\d>/gs) || []);
53
53
  headings.forEach(match => {
54
54
  var _a;
55
55
  const headingInner = match.replace(/\s*<\/?h\d[^>]*>\s*/g, '');
@@ -59,25 +59,29 @@ function compile(dir = '.', config = {}) {
59
59
  });
60
60
  toc = toc.replace(/<\/ol>\s*<ol>/g, '');
61
61
  const tocElem = (0, dedent_1.default) `
62
- <div id="page+toc">
63
- <span id="page+toc+heading">
62
+ <div id="page_toc">
63
+ <span id="page_toc_heading">
64
64
  <strong>Contents</strong>
65
65
  [<a href="javascript:void(0)" onclick="
66
- document.getElementById('page+toc+contents').setAttribute('style', this.innerText === 'hide' ? 'display: none;' : '');
66
+ document.getElementById('page_toc_contents').setAttribute('style', this.innerText === 'hide' ? 'display: none;' : '');
67
67
  this.innerText = this.innerText === 'hide' ? 'show' : 'hide';
68
68
  ">hide</a>]
69
69
  </span>
70
- <ol id="page+toc+contents">${toc}</ol>
70
+ <ol id="page_toc_contents">${toc}</ol>
71
71
  </div>
72
72
  `;
73
73
  // Set TOC on page
74
- if (outText.includes('<toc></toc>'))
74
+ if (outText.includes('<toc></toc>')) {
75
+ // put TOC where explicitly declared
75
76
  outText = outText.replace('<toc></toc>', tocElem);
76
- else
77
- outText = outText.replace(/<h\d[^>]*>/, tocElem + '$&');
77
+ }
78
+ else {
79
+ // put TOC above first auto heading
80
+ outText = outText.replace(/<h[1-6] auto/, tocElem + '$&');
81
+ }
78
82
  }
79
83
  // Create plaintext of HTML for use as description/metadata property.
80
- const plaintextData = parsedContent.replace(/<.+?>/gs, ' ');
84
+ const plaintextData = parsedContent.replace(/<.+?>/gs, '');
81
85
  // Create HTML
82
86
  const folderUpCount = file.split(/[\/\\]/).length - dir.split(/[\/\\]/).length; // number of folders to go up by to get to root
83
87
  const html = (0, dedent_1.default) `
package/dist/parse.js CHANGED
@@ -121,7 +121,7 @@ function parse(data, config = {}) {
121
121
  image-${imageData.type || 'default'}
122
122
  "
123
123
  style="
124
- display: inline-block;
124
+ margin: 8px;
125
125
  float: ${imageData.float || 'none'};
126
126
  clear: ${imageData.float || 'none'};
127
127
  vertical-align: ${imageData.align || 'unset'};
@@ -309,7 +309,7 @@ function parse(data, config = {}) {
309
309
  // Headings: ==heading==
310
310
  .replace((0, common_1.RegExpBuilder)(r `^ (=+) \s* (.+?) \s* \1 \s* $`), (_, lvl, txt) => {
311
311
  const linkForm = encodeURI(txt.replace(/ /g, '_').replace(/<.+?>/g, ''));
312
- return `<h${lvl.length} id="${linkForm}">${txt}</h${lvl.length}>`;
312
+ return `<h${lvl.length} auto id="${linkForm}">${txt}</h${lvl.length}>`;
313
313
  })
314
314
  // Bulleted list: *item
315
315
  .replace((0, common_1.RegExpBuilder)(r `^ (\*+) (.+?) $`), (_, lvl, content) => {
@@ -369,14 +369,8 @@ function parse(data, config = {}) {
369
369
  if (!ref)
370
370
  return _;
371
371
  ref.i++;
372
- const content = `
373
- <sup class="refnote">
374
- <a id="cite-${ref.id}${ref.i > 0 ? `_${ref.i}` : ''}" class="ref" href="#ref-${ref.id}">
375
- [${ref.id}]
376
- </a>
377
- </sup>
378
- `;
379
- return content;
372
+ const citeId = `cite-${ref.id}${ref.i > 0 ? `_${ref.i}` : ''}`;
373
+ return `<sup class="refnote"><a id="${citeId}" class="ref" href="#ref-${ref.id}">[${ref.id}]</a></sup>`;
380
374
  })
381
375
  // Nonstandard: ``code`` and ```code blocks```
382
376
  .replace((0, common_1.RegExpBuilder)(r ` \`\`\` ([^\`]+?) \`\`\` `), '<pre>$1</pre>')
@@ -397,7 +391,7 @@ function parse(data, config = {}) {
397
391
  let multiRefContent = '';
398
392
  if (refdata.i > 0) {
399
393
  for (let i = 0; i <= refdata.i; i++) {
400
- multiRefContent += `<sup><a href="#cite-${refdata.id}${i > 0 ? `_${i}` : ''}">${i + 1}</a></sup>`;
394
+ multiRefContent += `<sup><a href="#cite-${refdata.id}${i > 0 ? `_${i}` : ''}">${i + 1}</a></sup>&nbsp;`;
401
395
  }
402
396
  }
403
397
  const refline = `
package/dist/wiki.css.js CHANGED
@@ -8,7 +8,7 @@ ul, ol {margin: 0.3em 0 0 1.6em; padding: 0;}
8
8
  dt {font-weight: bold;}
9
9
  dd, dl dl {margin-block: 0; margin-inline-start: 30px;}
10
10
 
11
- figure {margin: 1em;}
11
+ figure {margin: 1em; width: 300px;}
12
12
  .image-thumb, .image-frame {padding: 6px; border: 1px solid gray;}
13
13
  .image-default {margin: 0;}
14
14
  figcaption {padding-top: 6px;}
@@ -26,9 +26,9 @@ a.external-link::after {content: '\1f855';}
26
26
  a.redlink {color: #d33;}
27
27
  a.redlink:visited {color: #b44;}
28
28
 
29
- #page+toc {border: 1px solid #aab; padding: 8px; width: fit-content; background-color: #f8f8f8; font-size: 95%;}
30
- #page+toc-heading {display: block; text-align: center;}
31
- #page+toc ol {margin: 0 0 0 1.3em;}
29
+ #page_toc {border: 1px solid #aab; padding: 8px; width: fit-content; background-color: #f8f8f8; font-size: 95%;}
30
+ #page_toc_heading {display: block; text-align: center;}
31
+ #page_toc ol {margin: 0 0 0 1.3em;}
32
32
 
33
33
  #infobox {float: right; clear: right; margin: 0 0 1em 1em; width: 300px; padding: 2px; border: 1px solid #CCC; overflow: auto; font-size: 90%;}
34
34
  #infobox tr:first-child :first-child {padding: 10px; text-align: center; font-weight: bold; font-size: 120%;}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wikity",
3
- "version": "1.3.5",
4
- "description": "Compile wikitext to HTML: wikitext as a templating language.",
3
+ "version": "1.3.6",
4
+ "description": "Compile wikitext to HTML! Supporst use of wikitext as a templating language.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "tsc && cd test && eleventy"
package/readme.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  This package comes with built-in support for compilation using [Eleventy](https://11ty.dev).
10
10
 
11
+ ## Exemplar
12
+
13
+ See the `example` folder for a template on making your own wiki site!
14
+
11
15
  ## Install
12
16
 
13
17
  Wikity is available [on npm](https://www.npmjs.com/package/wikity).