wiki-formant 0.47.0 → 0.47.1
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/metadata.js +8 -3
- package/package.json +1 -1
package/dist/metadata.js
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
// with no image while their og:image named a card, one listed citations, one
|
|
20
20
|
// collection page had no ItemList at all.
|
|
21
21
|
import { decodeEntities } from './markdown.js';
|
|
22
|
-
import { stripHtml } from './text.js';
|
|
23
22
|
export function pageMetadata(o) {
|
|
24
23
|
const { title, description, url, type = 'website', image, imageSize = { width: 1200, height: 630 }, siteName, locale, handle, markdownTwin, article } = o;
|
|
25
24
|
const images = image ? [{ url: image, ...imageSize, alt: o.imageAlt ?? title }] : undefined;
|
|
@@ -118,14 +117,20 @@ export function citationsFromReferences(items, max = 50) {
|
|
|
118
117
|
* characters is a heading with no section, and is skipped.
|
|
119
118
|
*/
|
|
120
119
|
export function questionPairs(html) {
|
|
120
|
+
// Plain text, not `stripHtml`, which keeps an href in parentheses for a model
|
|
121
|
+
// following citations: a heading's permalink anchor would end it in "(#id)"
|
|
122
|
+
// rather than "?". The anchor itself goes, glyph and all.
|
|
123
|
+
const plain = (s) => decodeEntities(s.replace(/<a\b[^>]*href="#[^"]*"[^>]*>[\s\S]*?<\/a>/gi, '').replace(/<[^>]+>/g, ' '))
|
|
124
|
+
.replace(/\s+/g, ' ')
|
|
125
|
+
.trim();
|
|
121
126
|
const pairs = [];
|
|
122
127
|
const sections = html.split(/<h[23][^>]*>/i);
|
|
123
128
|
for (const section of sections.slice(1)) {
|
|
124
129
|
const [heading = '', ...rest] = section.split(/<\/h[23]>/i);
|
|
125
|
-
const q =
|
|
130
|
+
const q = plain(heading).replace(/\s+([?.,;:!])/g, '$1');
|
|
126
131
|
if (!q.endsWith('?'))
|
|
127
132
|
continue;
|
|
128
|
-
const a =
|
|
133
|
+
const a = plain(rest.join('')).replace(/\s+([?.,;:!])/g, '$1');
|
|
129
134
|
if (a.length >= 40)
|
|
130
135
|
pairs.push({ q, a: a.slice(0, 1000) });
|
|
131
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-formant",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "The portable half of a wiki: derived taxonomy and facet controls, a version-negotiating MCP transport, markdown twins, block rendering, a rich-text editor engine, conditional-GET plumbing, and the headers and CSP every origin sends.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|