@excom/quark-formatter 0.1.0

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.
@@ -0,0 +1,33 @@
1
+ {
2
+ "shortName": "quark-formatter",
3
+ "package": {
4
+ "name": "@excom/quark-formatter",
5
+ "version": "0.1.0",
6
+ "description": "Opinionated SCSS-style formatter for the Quark language, built on the quark-parser AST",
7
+ "peerDependencies": {},
8
+ "excom": {
9
+ "packageType": "tool"
10
+ }
11
+ },
12
+ "demos": {},
13
+ "readme": "<h1 id=\"md-quark-formatter\">quark-formatter</h1>\n<p>Prettier-style formatting for Quark sheets — one call, one canonical style, nothing to configure.</p>\n<include-content data-language=\"js\"><template>import { format } from \"@excom/quark-formatter\";\n\nformat(`provider-fetch[is-success]{$todos:prop(\"provision\").body;ul{content:iterate($todos)}}`);\n// provider-fetch[is-success] {\n// $todos: prop(\"provision\").body;\n// ul {\n// content: iterate($todos);\n// }\n// }</template></include-content>\n<h2 id=\"md-features\">Features</h2>\n<ul>\n<li><strong>One style</strong> Two-space indent, 80-column wrapping, one selector per line, single blank lines between groups</li>\n<li><strong>Safe</strong> Invalid Quark throws instead of rewriting; comments stay where they were written; formatting is idempotent</li>\n<li><strong>Editor / CLI ready</strong> Powers Format Document in the <spa-a route-href=\"/nucleus/packages/nucleus-quark-highlighter\" role=\"link\">Nucleus &amp; Quark extension</spa-a> and the monorepo <code>format</code> script</li>\n<li><strong>Self-contained</strong> Parser bundled in; runs in Node, bundlers and browsers</li>\n</ul>\n<h2 id=\"md-installation\">Installation</h2>\n<p><include-content is-active template-ref=\"/views/install-section/install-section.html\"></include-content></p>\n<h2 id=\"md-usage\">Usage</h2>\n<p><code>format(source, options?)</code> returns the formatted sheet as a string. The only option is <code>indent</code> (default two spaces).</p>\n<p><include-content data-language=\"js\"><template>import { format } from &quot;@excom/quark-formatter&quot;;</p>\n<p>const pretty = format(source, { indent: &quot;\\t&quot; });</template></include-content></p>\n<p>Invalid input throws <code>QuarkParseError</code> (from <code>@excom/quark-parser</code>) with the line and column, so callers leave the original file untouched:</p>\n<p><include-content data-language=\"js\"><template>try {\n fs.writeFileSync(file, format(fs.readFileSync(file, &quot;utf8&quot;)));\n} catch (error) {\n console.error(<code>${file}: ${error.message}</code>);\n}</template></include-content></p>\n<h3 id=\"md-what-gets-normalized\">What gets normalized</h3>\n<ul>\n<li>Whitespace, indentation and blank lines (at most one preserved between statements)</li>\n<li>Selector lists: one per line at rule heads, <code>, </code>-joined inside <code>:not()</code> / <code>:is()</code></li>\n<li>Operator spacing, with only the parentheses the expression needs: <code>($a or $b) and $c</code></li>\n<li>Accessors and call chains print compactly: <code>$todo.title</code>, <code>$row[&quot;id&quot;]</code>, <code>closest(&quot;li&quot;).getAttribute(&quot;id&quot;)</code></li>\n<li>Comments (<code>/* … */</code> only) keep their position, including trailing same-line comments</li>\n<li>Lines wrap at 80 columns the way prettier wraps CSS: maps, call arguments, <code>if()</code> arms, <code>@on</code> / <code>@dispatch</code> / <code>@command</code> / <code>@view-transition</code> options and <code>@delay</code> durations that overflow break one item per line, operator chains wrap like text, a comma list of multi-word values breaks one value per line</li>\n</ul>\n<include-content data-language=\"quark\"><template>dataset: (\n trip: event.target.form.elements[\"data-trip\"].value,\n outbound: event.target.form.elements[\"data-outbound\"].value\n);\ndata-mode: if(\n event.target.name == \"data-mode\": event.target.value;\n else: preserve\n);</template></include-content>\n<p>Strings, selectors and interpolations never wrap, so a long <code>content: &quot;…#{…}…&quot;</code> stays on one line. Listener at-rules print as <code>@on input, change (debounce: 300, handle: save) {</code> — the event list as written, the options group like a map — and <code>@dispatch</code> / <code>@command</code> statements the same way; <code>@view-transition (types: &quot;todo-change&quot;) {</code> prints its options like <code>@on</code>&#39;s and always opens a block, as does <code>@scope {</code>.</p>\n<p>Quark is a derivative of CSS, not a superset: the formatter prints Quark&#39;s own at-rules — <code>@use</code>, <code>@scope</code>, <code>@on</code>, <code>@dispatch</code>, <code>@command</code>, <code>@view-transition</code>, <code>@delay</code>, <code>@warn</code>, <code>@debug</code>, <code>@error</code> — and nothing else. Anything the parser rejects (<code>@media</code> and the other CSS at-rules, SCSS&#39;s <code>@if</code> / <code>@each</code> / <code>@mixin</code>, <code>%placeholder</code> selectors, <code>#{…}</code> outside a string, <code>!important</code> / <code>!default</code>, nested property blocks, <code>@use … with (…)</code>) throws rather than being reformatted.</p>\n<h3 id=\"md-in-the-editor\">In the editor</h3>\n<p>Install the <spa-a route-href=\"/nucleus/packages/nucleus-quark-highlighter\" role=\"link\">Nucleus &amp; Quark Syntax Highlighter</spa-a> to format <code>.quark</code> files with Format Document and inline <code>&lt;quark-sheet&gt;</code> blocks with a command.</p>\n",
14
+ "docs": {
15
+ "readme": "<h1 id=\"md-quark-formatter\">quark-formatter</h1>\n<p>Prettier-style formatting for Quark sheets — one call, one canonical style, nothing to configure.</p>\n<include-content data-language=\"js\"><template>import { format } from \"@excom/quark-formatter\";\n\nformat(`provider-fetch[is-success]{$todos:prop(\"provision\").body;ul{content:iterate($todos)}}`);\n// provider-fetch[is-success] {\n// $todos: prop(\"provision\").body;\n// ul {\n// content: iterate($todos);\n// }\n// }</template></include-content>\n<h2 id=\"md-features\">Features</h2>\n<ul>\n<li><strong>One style</strong> Two-space indent, 80-column wrapping, one selector per line, single blank lines between groups</li>\n<li><strong>Safe</strong> Invalid Quark throws instead of rewriting; comments stay where they were written; formatting is idempotent</li>\n<li><strong>Editor / CLI ready</strong> Powers Format Document in the <spa-a route-href=\"/nucleus/packages/nucleus-quark-highlighter\" role=\"link\">Nucleus &amp; Quark extension</spa-a> and the monorepo <code>format</code> script</li>\n<li><strong>Self-contained</strong> Parser bundled in; runs in Node, bundlers and browsers</li>\n</ul>\n<h2 id=\"md-installation\">Installation</h2>\n<p><include-content is-active template-ref=\"/views/install-section/install-section.html\"></include-content></p>\n<h2 id=\"md-usage\">Usage</h2>\n<p><code>format(source, options?)</code> returns the formatted sheet as a string. The only option is <code>indent</code> (default two spaces).</p>\n<p><include-content data-language=\"js\"><template>import { format } from &quot;@excom/quark-formatter&quot;;</p>\n<p>const pretty = format(source, { indent: &quot;\\t&quot; });</template></include-content></p>\n<p>Invalid input throws <code>QuarkParseError</code> (from <code>@excom/quark-parser</code>) with the line and column, so callers leave the original file untouched:</p>\n<p><include-content data-language=\"js\"><template>try {\n fs.writeFileSync(file, format(fs.readFileSync(file, &quot;utf8&quot;)));\n} catch (error) {\n console.error(<code>${file}: ${error.message}</code>);\n}</template></include-content></p>\n<h3 id=\"md-what-gets-normalized\">What gets normalized</h3>\n<ul>\n<li>Whitespace, indentation and blank lines (at most one preserved between statements)</li>\n<li>Selector lists: one per line at rule heads, <code>, </code>-joined inside <code>:not()</code> / <code>:is()</code></li>\n<li>Operator spacing, with only the parentheses the expression needs: <code>($a or $b) and $c</code></li>\n<li>Accessors and call chains print compactly: <code>$todo.title</code>, <code>$row[&quot;id&quot;]</code>, <code>closest(&quot;li&quot;).getAttribute(&quot;id&quot;)</code></li>\n<li>Comments (<code>/* … */</code> only) keep their position, including trailing same-line comments</li>\n<li>Lines wrap at 80 columns the way prettier wraps CSS: maps, call arguments, <code>if()</code> arms, <code>@on</code> / <code>@dispatch</code> / <code>@command</code> / <code>@view-transition</code> options and <code>@delay</code> durations that overflow break one item per line, operator chains wrap like text, a comma list of multi-word values breaks one value per line</li>\n</ul>\n<include-content data-language=\"quark\"><template>dataset: (\n trip: event.target.form.elements[\"data-trip\"].value,\n outbound: event.target.form.elements[\"data-outbound\"].value\n);\ndata-mode: if(\n event.target.name == \"data-mode\": event.target.value;\n else: preserve\n);</template></include-content>\n<p>Strings, selectors and interpolations never wrap, so a long <code>content: &quot;…#{…}…&quot;</code> stays on one line. Listener at-rules print as <code>@on input, change (debounce: 300, handle: save) {</code> — the event list as written, the options group like a map — and <code>@dispatch</code> / <code>@command</code> statements the same way; <code>@view-transition (types: &quot;todo-change&quot;) {</code> prints its options like <code>@on</code>&#39;s and always opens a block, as does <code>@scope {</code>.</p>\n<p>Quark is a derivative of CSS, not a superset: the formatter prints Quark&#39;s own at-rules — <code>@use</code>, <code>@scope</code>, <code>@on</code>, <code>@dispatch</code>, <code>@command</code>, <code>@view-transition</code>, <code>@delay</code>, <code>@warn</code>, <code>@debug</code>, <code>@error</code> — and nothing else. Anything the parser rejects (<code>@media</code> and the other CSS at-rules, SCSS&#39;s <code>@if</code> / <code>@each</code> / <code>@mixin</code>, <code>%placeholder</code> selectors, <code>#{…}</code> outside a string, <code>!important</code> / <code>!default</code>, nested property blocks, <code>@use … with (…)</code>) throws rather than being reformatted.</p>\n<h3 id=\"md-in-the-editor\">In the editor</h3>\n<p>Install the <spa-a route-href=\"/nucleus/packages/nucleus-quark-highlighter\" role=\"link\">Nucleus &amp; Quark Syntax Highlighter</spa-a> to format <code>.quark</code> files with Format Document and inline <code>&lt;quark-sheet&gt;</code> blocks with a command.</p>\n"
16
+ },
17
+ "installation": {
18
+ "name": "@excom/quark-formatter",
19
+ "shortName": "quark-formatter",
20
+ "version": "0.1.0",
21
+ "description": "Opinionated SCSS-style formatter for the Quark language, built on the quark-parser AST",
22
+ "packageType": "tool",
23
+ "install": {
24
+ "npm": "npm install @excom/quark-formatter"
25
+ },
26
+ "imports": {
27
+ "js": "import { /* … */ } from \"@excom/quark-formatter\";"
28
+ },
29
+ "peerDependencies": []
30
+ },
31
+ "elementApis": [],
32
+ "exportedFiles": {}
33
+ }