eve-hub 0.16.28 → 0.16.29

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.
Files changed (2) hide show
  1. package/bubbles.mjs +13 -5
  2. package/package.json +1 -1
package/bubbles.mjs CHANGED
@@ -1,9 +1,11 @@
1
1
  // The bubble rule: a post's text splits into bubbles at each top-level
2
2
  // thematic break, by CommonMark's rules, as the app splits it
3
3
  // (MarkdownCards.swift, `case .rule`). A `---` in code, an HTML block, a list
4
- // or a quote is no break. Bots write the break as BUBBLE_BREAK. The cap
5
- // (post_message) and what an unnamed reader is shown (delivery-context) both
6
- // cut here.
4
+ // or a quote is no break. A `---` right under a paragraph, which CommonMark
5
+ // reads as a setext heading underline, is a break too: that is what a bot
6
+ // writing it means (MarkdownBlocks.parse splits it the same way). Bots write
7
+ // the break as BUBBLE_BREAK. The cap (post_message) and what an unnamed reader
8
+ // is shown (delivery-context) both cut here.
7
9
  import { fromMarkdown } from "mdast-util-from-markdown";
8
10
 
9
11
  export const BUBBLE_BREAK = "\n\n---\n\n";
@@ -13,8 +15,14 @@ export function bubbles(text) {
13
15
  const out = [];
14
16
  let from = 0;
15
17
  for (const node of fromMarkdown(s).children) {
16
- if (node.type !== "thematicBreak") continue;
17
- out.push(s.slice(from, node.position.start.offset));
18
+ if (node.type === "thematicBreak") {
19
+ out.push(s.slice(from, node.position.start.offset));
20
+ } else if (node.type === "heading" && node.depth === 2) {
21
+ const source = s.slice(node.position.start.offset, node.position.end.offset);
22
+ const underline = source.lastIndexOf("\n");
23
+ if (underline < 0 || !/^[ \t]*-+[ \t]*$/.test(source.slice(underline + 1))) continue;
24
+ out.push(s.slice(from, node.position.start.offset + underline));
25
+ } else continue;
18
26
  from = node.position.end.offset;
19
27
  }
20
28
  out.push(s.slice(from));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-hub",
3
- "version": "0.16.28",
3
+ "version": "0.16.29",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Bot-side code shared by every hub agent: registry tools, the roster hook, the eve channel, the host sandbox and browser, and model helpers.",
6
6
  "type": "module",