tecitheme 1.1.1 → 1.1.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.
@@ -130,15 +130,15 @@
130
130
  Pricing <span aria-hidden="true">&rarr;</span>
131
131
  </a>
132
132
 
133
- <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
133
+ <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
134
134
  Download <span aria-hidden="true">&rarr;</span>
135
135
  </a>
136
136
 
137
- <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
137
+ <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
138
138
  Documentation <span aria-hidden="true">&rarr;</span>
139
139
  </a>
140
140
 
141
- <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/examples" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
141
+ <a href="https://www.thunderheadeng.com/docs/latest/pyrosim/examples" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
142
142
  Tutorials <span aria-hidden="true">&rarr;</span>
143
143
  </a>
144
144
 
@@ -178,15 +178,15 @@
178
178
  Pricing <span aria-hidden="true">&rarr;</span>
179
179
  </a>
180
180
 
181
- <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
181
+ <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
182
182
  Download <span aria-hidden="true">&rarr;</span>
183
183
  </a>
184
184
 
185
- <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
185
+ <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
186
186
  Documentation <span aria-hidden="true">&rarr;</span>
187
187
  </a>
188
188
 
189
- <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/examples" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
189
+ <a href="https://www.thunderheadeng.com/docs/latest/pathfinder/examples" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
190
190
  Tutorials <span aria-hidden="true">&rarr;</span>
191
191
  </a>
192
192
 
@@ -224,15 +224,15 @@
224
224
  Pricing <span aria-hidden="true">&rarr;</span>
225
225
  </a>
226
226
 
227
- <a href="https://www.thunderheadeng.com/docs/latest/ventus/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
227
+ <a href="https://www.thunderheadeng.com/docs/latest/ventus/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
228
228
  Download <span aria-hidden="true">&rarr;</span>
229
229
  </a>
230
230
 
231
- <a href="https://www.thunderheadeng.com/docs/latest/ventus/" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
231
+ <a href="https://www.thunderheadeng.com/docs/latest/ventus/" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
232
232
  Documentation <span aria-hidden="true">&rarr;</span>
233
233
  </a>
234
234
 
235
- <a href="https://www.thunderheadeng.com/docs/latest/ventus/examples" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
235
+ <a href="https://www.thunderheadeng.com/docs/latest/ventus/examples" rel="external" class="text-teci-blue-light hover:text-teci-blue-dark font-medium">
236
236
  Tutorials <span aria-hidden="true">&rarr;</span>
237
237
  </a>
238
238
 
@@ -819,6 +819,7 @@
819
819
  <div class="flow-root">
820
820
  <a
821
821
  href="https://www.thunderheadeng.com/docs/"
822
+ rel="external"
822
823
  class="-m-3 flex items-start p-3 text-base font-medium text-gray-900 hover:bg-gray-100"
823
824
  >
824
825
  <svg
@@ -16,7 +16,12 @@
16
16
 
17
17
  const { searchClient, setMeiliSearchParams } = instantMeiliSearch (
18
18
  "https://ms-6689ffd3d866-29089.nyc.meilisearch.io",
19
- "d9f20886cbbbe171f3933dc93a1ec38e365d53f072854e5d9f92a9b130fa1f7d"
19
+ "d9f20886cbbbe171f3933dc93a1ec38e365d53f072854e5d9f92a9b130fa1f7d",
20
+ {
21
+ meiliSearchParams: {
22
+ showMatchesPosition: true
23
+ }
24
+ }
20
25
  )
21
26
 
22
27
  onMount(() => {
@@ -90,7 +90,106 @@
90
90
  }
91
91
  }
92
92
 
93
+ function tokenizeHTML(html) {
94
+ const tokens = [];
95
+ let buffer = "";
96
+ let insideTag = false;
97
+
98
+ for (let i = 0; i < html.length; i++) {
99
+ const c = html[i];
100
+
101
+ if (c === "<") {
102
+ // flush text buffer
103
+ if (buffer) tokens.push({ type: "text", value: buffer });
104
+ buffer = "<";
105
+ insideTag = true;
106
+ } else if (c === ">" && insideTag) {
107
+ buffer += ">";
108
+ tokens.push({ type: "tag", value: buffer });
109
+ buffer = "";
110
+ insideTag = false;
111
+ } else {
112
+ buffer += c;
113
+ }
114
+ }
115
+
116
+ if (buffer) {
117
+ tokens.push({ type: insideTag ? "tag" : "text", value: buffer });
118
+ }
119
+
120
+ return tokens;
121
+ }
122
+
123
+ function buildOffsetMap(tokens) {
124
+ let global = 0;
125
+
126
+ return tokens.map(t => {
127
+ const start = global;
128
+ const end = start + t.value.length;
129
+
130
+ global = end;
131
+
132
+ return {
133
+ ...t,
134
+ globalStart: start,
135
+ globalEnd: end
136
+ };
137
+ });
138
+ }
139
+
140
+ function applyHighlights(tokens, matches) {
141
+ // Process matches from last → first to prevent index shifting
142
+ matches.sort((a, b) => b.start - a.start);
143
+
144
+ matches.forEach(({ start, length }) => {
145
+ const end = start + length;
146
+
147
+ tokens.forEach(token => {
148
+ if (token.type === "tag") return;
93
149
 
150
+ // skip if match does not touch this token
151
+ if (end <= token.globalStart || start >= token.globalEnd) return;
152
+
153
+ // ----- compute localStart -----
154
+ let localStart;
155
+ if (start < token.globalStart) {
156
+ localStart = 0;
157
+ } else {
158
+ localStart = start - token.globalStart;
159
+ }
160
+
161
+ // ----- compute localEnd -----
162
+ let localEnd;
163
+ const tokenLength = token.value.length;
164
+
165
+ if (end > token.globalEnd) {
166
+ localEnd = tokenLength;
167
+ } else {
168
+ localEnd = end - token.globalStart;
169
+ }
170
+
171
+ // apply the highlight
172
+ const text = token.value;
173
+
174
+ token.value =
175
+ text.slice(0, localStart) +
176
+ "<mark>" +
177
+ text.slice(localStart, localEnd) +
178
+ "</mark>" +
179
+ text.slice(localEnd);
180
+ });
181
+ });
182
+
183
+ return tokens.map(t => t.value).join("");
184
+ }
185
+
186
+ function highlightHTMLWithMatches(html, matches) {
187
+ if (!matches || matches.length === 0) return html
188
+
189
+ const tokens = tokenizeHTML(html);
190
+ const mapped = buildOffsetMap(tokens);
191
+ return applyHighlights(mapped, matches);
192
+ }
94
193
  </script>
95
194
 
96
195
  <svelte:window on:keydown={(e) => handleKeyPress(e)} />
@@ -209,7 +308,7 @@
209
308
  <!-- Content Preview -->
210
309
  <div class="flex flex-col">
211
310
  <h4 class="text-lg font-bold text-black uppercase">Preview</h4>
212
- <p class="line-clamp-4 mb-4"><Highlight {hit} attribute="content" /></p>
311
+ <p class="highlightedSearchContent line-clamp-4 mb-4">{@html highlightHTMLWithMatches(hit.content, hit._matchesPosition.content)}</p>
213
312
  </div>
214
313
 
215
314
  <!-- On This Page headings -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tecitheme",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",