Skip to content

Commit f0f08e8

Browse files
committed
Feat: fix formatting
1 parent 27c62d8 commit f0f08e8

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

docs/src/components/AIPrompt/AIPrompt.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { formatCode, ready as highlighterReady } from '@javascript/client-highlight.js';
22
import { defineComponent } from '@semantic-ui/component';
33
import { getJSON } from '@semantic-ui/utils';
4+
import pretty from 'pretty';
45

56
import { AILoader } from '@components/AILoader/AILoader.js';
67
import { UIButton } from '@semantic-ui/core';
@@ -243,15 +244,16 @@ const createComponent = ({ self, $, settings, state }) => ({
243244
}
244245
}
245246
else if (data.type === 'done') {
246-
const trimmed = htmlAccum.trim();
247+
// trim and add newline for pretty to fix
248+
const currentHTML = htmlAccum;
247249
if (!isValidHTML) {
248250
// API returned plain text, not HTML — show as note instead
249251
state.codeHTML.set('');
250252
state.previewHTML.set('');
251-
state.note.set(trimmed || 'No valid HTML was returned');
253+
state.note.set(currentHTML || 'No valid HTML was returned');
252254
break;
253255
}
254-
self.currentHTML = trimmed;
256+
self.currentHTML = pretty(currentHTML, { ocd: true });
255257
state.previewHTML.set(self.currentHTML);
256258
state.codeHTML.set(formatCode(self.currentHTML));
257259
self.promptHistory.push({ prompt, html: self.currentHTML });

docs/src/javascript/client-highlight.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ export const ready = createHighlighterCore({
3030
});
3131

3232
export function formatCode(code, lang = 'html') {
33-
if (!highlighter) {
34-
return `<pre><code>${code}</code></pre>`;
35-
}
33+
// trim and add newline for pretty to fix
34+
code = code.trim();
35+
3636
if (lang === 'html') {
37+
code = code.replaceAll('>', '>\n');
38+
code = code.replaceAll('<', '\n<');
3739
code = pretty(code, { ocd: true });
3840
}
41+
42+
if (!highlighter) {
43+
return `<pre><code>${code}</code></pre>`;
44+
}
3945
return highlighter.codeToHtml(code, { lang, theme: 'github-dark', colorReplacements });
4046
}

docs/src/pages/index.astro

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,15 @@ const demoSteps = [
256256
<div class="copy">
257257
<h4 class="sub header">Component Authoring</h4>
258258
<h3 class="header">Expressive Templates</h3>
259-
<p>Author components using a signals based templating engine. Updates are surgical without full component rerenders.</p>
259+
<p>Use javascript or list style expressions. Surgically update values with Signals against your data.</p>
260260
<ul class="feature-list">
261261
<li>
262262
<ui-icon check></ui-icon>
263-
Use <code>js</code> style expression to handle complexity.
263+
Use any javascript inside templates without arbitrary limitations
264264
</li>
265265
<li>
266266
<ui-icon check></ui-icon>
267-
Use <code>lisp</code> style expression to improve legibility and semantic intent.
268-
</li>
269-
<li>
270-
<ui-icon check></ui-icon>
271-
Mix syntaxes to get the best of both worlds
267+
Try out natural-language style Lisp syntax to improve comprehension during Huma in the Loop
272268
</li>
273269
</ul>
274270
<UIButton subtle icon-after icon="right-chevron" href="/docs/guides/templates">Templating Guide</UIButton>

0 commit comments

Comments
 (0)