@rse/specbook 1.2.14 → 1.2.15

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.
@@ -50,34 +50,37 @@
50
50
  let indexed = false
51
51
 
52
52
  /* fill the unit and vocabulary indices once on first use: a unit
53
- is an outermost paragraph-level element within an article, i.e.
54
- one not nested inside another unit (like a paragraph or diagram
55
- in a table cell, which is covered by its table row), where a
56
- diagram is searched by its SVG text labels, joined by spaces,
57
- as its raw text content would run them together, and where the
58
- explicit anchor id of an object heading or table row joins the
59
- searched text */
53
+ is an outermost paragraph-level element within an article or
54
+ the title page abstract (a lone paragraph being the unit itself),
55
+ i.e. one not nested inside another unit (like a paragraph in a
56
+ table cell, covered by its table row), where a diagram is
57
+ searched by its space-joined SVG text labels (its raw text
58
+ content runs them together), and where the explicit anchor id
59
+ of an object heading or table row joins the searched text */
60
60
  const index = () => {
61
61
  if (indexed)
62
62
  return
63
63
  indexed = true
64
- document.querySelectorAll("article").forEach((article) => {
65
- article.querySelectorAll("p, li, tr, pre, blockquote, h1, h2, h3, h4, h5, h6, div.diagram")
66
- .forEach((el) => {
67
- let parent = el.parentElement
68
- while (parent !== null && parent.tagName !== "ARTICLE") {
69
- if (/^(TR|TD|TH|LI|P|BLOCKQUOTE)$/.test(parent.tagName))
70
- return
71
- parent = parent.parentElement
72
- }
73
- const id = (el.dataset.id ?? "").toLowerCase()
74
- const text = ((el.classList.contains("diagram") ?
75
- Array.from(el.querySelectorAll("text")).map((t) => t.textContent ?? "").join(" ") :
76
- (el.textContent ?? "")) + " " + id).toLowerCase()
77
- const words = new Set(text.split(/[^\p{L}\p{N}]+/u).filter((w) => w !== ""))
78
- words.forEach((w) => { vocab.add(w) })
79
- units.push({ el, id, text, words, keep: false })
80
- })
64
+ document.querySelectorAll("article, div.titlepage > .description").forEach((root) => {
65
+ const els = Array.from(root.querySelectorAll(
66
+ "p, li, tr, pre, blockquote, h1, h2, h3, h4, h5, h6, div.diagram"))
67
+ if (root.tagName === "P")
68
+ els.unshift(root)
69
+ els.forEach((el) => {
70
+ let parent = el.parentElement
71
+ while (parent !== null && parent !== root) {
72
+ if (/^(TR|TD|TH|LI|P|BLOCKQUOTE)$/.test(parent.tagName))
73
+ return
74
+ parent = parent.parentElement
75
+ }
76
+ const id = (el.dataset.id ?? "").toLowerCase()
77
+ const text = ((el.classList.contains("diagram") ?
78
+ Array.from(el.querySelectorAll("text")).map((t) => t.textContent ?? "").join(" ") :
79
+ (el.textContent ?? "")) + " " + id).toLowerCase()
80
+ const words = new Set(text.split(/[^\p{L}\p{N}]+/u).filter((w) => w !== ""))
81
+ words.forEach((w) => { vocab.add(w) })
82
+ units.push({ el, id, text, words, keep: false })
83
+ })
81
84
  })
82
85
 
83
86
  /* let a hyperlink whose target the filtering hid leave the
@@ -38,9 +38,9 @@ const templates = {
38
38
  <div class="theme-switch" onclick="themeSwitch()" title="switch color theme"><svg class="theme-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="12" cy="12" r="8.5"/><path d="M12 3.5 A 8.5 8.5 0 0 0 12 20.5 Z" fill="currentColor" stroke="none"/></svg></div>
39
39
  {% if Document.info %}<div class="info-switch" title="toggle description popups"><svg class="info-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="12" cy="12" r="8.5"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="7.75" x2="12.01" y2="7.75"/></svg></div>{% endif %}
40
40
  <div class="search" id="search">
41
- <div class="search-toggle" id="search-toggle" title="toggle search field"><svg class="search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="10" cy="10" r="6.5"/><line x1="15" y1="15" x2="21" y2="21"/></svg></div>
41
+ <div class="search-toggle" id="search-toggle" title="toggle search field"><svg class="search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="3.5,4.5 20.5,4.5 14,12.5 14,20 10,17.5 10,12.5"/></svg></div>
42
42
  <div class="search-field">
43
- <input type="text" id="search-input" placeholder="Search&hellip;" autocomplete="off" spellcheck="false"/>
43
+ <input type="text" id="search-input" placeholder="Filter&hellip; (fuzzy matched keywords)" autocomplete="off" spellcheck="false"/>
44
44
  <span class="search-clear" id="search-clear" title="clear search">&#x00D7;</span>
45
45
  </div>
46
46
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rse/specbook",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "publishConfig": { "access": "public" },
5
5
  "description": "Markdown-based Specification Format (API, CLI and MCP service)",
6
6
  "license": "Apache-2.0",