@sigrix-io/gatehouse 0.5.0 → 0.5.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/README.md CHANGED
@@ -78,7 +78,7 @@ The run page draws the bundle's name as `<h1 class="run-title">`, which is right
78
78
  new Gatehouse.RunRenderer(container, client, { titleLevel: 2 });
79
79
  ```
80
80
 
81
- A number or numeric text (`'2'`) is read as a level; anything that does not read as a whole number from 1 to 6 (absent, `0`, `7`, `2.5`, other text) is the default, 1. Pass 2 for a page that has an `<h1>` of its own; from 3 on, the heading above the examples and a result's top heading are both `<h2>` and outrank the name. Only the name's level moves: the heading above the examples stays an `<h2>`, and a result's own headings stay between `<h2>` and `<h4>`, so at `titleLevel: 2` they sit beside the name and skip no level beneath it. The renderer draws no other `<h1>`.
81
+ A number or numeric text (`'2'`) is read as a level; anything that does not read as a whole number from 1 to 6 (absent, `0`, `7`, `2.5`, other text) is the default, 1. Pass 2 for a page that has an `<h1>` of its own; from 3 on, the heading above the examples is an `<h2>` and outranks the name. A result's own headings (Markdown output) sit beneath the name, except at `titleLevel: 6`, where no level is left and they are `<h6>`, level with it: `#` is drawn one level below it, each `#` after it one level further, over three levels, and nothing is drawn past `<h6>` (what would be stays at `<h6>`). At the default level that is `<h2>` to `<h4>`, as ever; at `titleLevel: 2`, `#` is an `<h3>` and `##` an `<h4>`. The heading above the examples stays an `<h2>`. The renderer draws no other `<h1>`.
82
82
 
83
83
  ## The composition
84
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigrix-io/gatehouse",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "A browser client for Postern: draws a run page from a describe document and connects it to the four verbs. No build step and no dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Sigrix",
@@ -791,12 +791,16 @@
791
791
 
792
792
  renderMarkdown(value, into) {
793
793
  const target = into || this.nodes.rendered;
794
+ const title = this.titleLevel;
794
795
  NS.viewModel.outputBlocks(value).forEach(function (block) {
795
796
  if (block.kind === 'heading') {
796
- /* Clamped to h2..h4: the page has an `<h1>` (the agent's name by
797
- * default, or the host's own when `titleLevel` moves it), and an
798
- * agent that emits `#` is describing its answer, not the page. */
799
- const level = Math.min(4, Math.max(2, block.level + 1));
797
+ /* A result's headings sit beneath the title, never beside it: `#`
798
+ * is drawn one level below the title and each `#` after it one
799
+ * level further, over three levels (title + 1 to title + 3), the
800
+ * span h2..h4 has always had under the default h1. Past h6 they
801
+ * stay at h6. An agent that emits `#` is describing its answer, not
802
+ * the page. */
803
+ const level = Math.min(6, title + 3, title + block.level);
800
804
  target.appendChild(el('h' + level, 'run-md-heading', block.text));
801
805
  return;
802
806
  }