@geml/geml 1.7.0 → 1.7.2

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/dist/from-md.js CHANGED
@@ -55,7 +55,12 @@ function metaLine(line) {
55
55
  if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'")))
56
56
  v = v.slice(1, -1);
57
57
  const bareSafe = /^[^\s"]+$/.test(v);
58
- return bareSafe ? `${m[1]}=${v}` : `${m[1]}="${v.replace(/"/g, '\\"')}"`;
58
+ // No backslash escape here — a `data` block value is read by `coerce`, which
59
+ // simply strips the outer quotes (§4); GEML defines no `\"` escape at all.
60
+ // Emitting one wrote the backslash into the parsed value, so `a"b` came back
61
+ // as `a\"b`. Quoting the value verbatim round-trips instead: coerce keeps
62
+ // everything between the first and last quote, embedded quotes included.
63
+ return bareSafe ? `${m[1]}=${v}` : `${m[1]}="${v}"`;
59
64
  }
60
65
  // Rewrite Markdown autolinks `<https://…>` / `<mailto:…>` into GEML links
61
66
  // `[url](url)` (GEML has no autolink syntax). Inline code spans are left intact.
@@ -182,7 +187,7 @@ export function mdToGeml(source) {
182
187
  // the same character is content — this is what lets a document *show*
183
188
  // nested ``` fences without ending the block early.
184
189
  const indent = raw.length - raw.trimStart().length;
185
- const c = raw.replace(/\s+$/, "").trimStart();
190
+ const c = raw.trimEnd().trimStart();
186
191
  if (indent <= 3 && c.length >= marker.length && c[0] === marker[0] && /^[`~]+$/.test(c))
187
192
  break;
188
193
  body.push(raw);
package/dist/geml.d.ts CHANGED
@@ -4,6 +4,7 @@ import { type Value } from "./attrs.js";
4
4
  import { type Inline } from "./inline.js";
5
5
  import { type TableModel } from "./table.js";
6
6
  import { type ChartModel } from "./chart.js";
7
+ import { type Addressed } from "./selector.js";
7
8
  export { type Value } from "./attrs.js";
8
9
  export { type Inline } from "./inline.js";
9
10
  export { type TableModel } from "./table.js";
@@ -12,6 +13,7 @@ export { renderHtml, pageAssets } from "./render-html.js";
12
13
  export { type RenderOptions } from "./render.js";
13
14
  export { serialize } from "./serialize.js";
14
15
  export { gemlToMd } from "./to-md.js";
16
+ export declare function reLit(s: string): string;
15
17
  export type BodyMode = "raw" | "flow" | "data";
16
18
  export type DataValue = null | boolean | number | string | DataValue[] | {
17
19
  [key: string]: DataValue;
@@ -68,15 +70,45 @@ export interface Document {
68
70
  }
69
71
  export interface ParseOptions {
70
72
  resolveDoc?: (doc: string) => string | null;
73
+ docExists?: (doc: string) => boolean;
71
74
  self?: string;
72
75
  }
76
+ export declare const FENCE_OPEN: RegExp;
77
+ export declare function isCloseFence(line: string, openLen: number): boolean;
78
+ export declare const EMBED_DEPTH_LIMIT = 8;
73
79
  export declare function projectableInlines(blocks: Block[], id: string): {
74
80
  inlines: Inline[];
75
81
  } | "not-inline" | null;
82
+ export declare function relJoinPath(base: string, target: string): string;
83
+ export declare function relDirPath(p: string): string;
84
+ export declare function gatherEmbeds(source: string): {
85
+ doc: string;
86
+ anchor?: string;
87
+ }[];
76
88
  export declare function parse(source: string, opts?: ParseOptions): Document;
77
89
  export interface Span {
78
90
  start: number;
79
91
  end: number;
80
92
  }
93
+ export declare function stripEol(line: string): string;
94
+ export declare function trimSpaceTabEnd(s: string): string;
81
95
  export declare function blockSpans(source: string): Map<string, Span>;
96
+ export declare function addressedUnits(source: string): Addressed[];
97
+ export declare function splitLines(source: string): string[];
98
+ export declare function newlineOf(text: string): string;
99
+ export declare function toLf(text: string): string;
100
+ export declare function toNewline(text: string, nl: string): string;
101
+ export declare function narrowToHead(span: Span): Span;
102
+ export declare function closeFenceLine(lines: string[], span: Span): string | null;
103
+ export declare function narrowToIntro(source: string, span: Span): Span;
104
+ /** Which part of one unit to output. `intro` applies to headings only. */
105
+ export type UnitPart = "whole" | "head" | "body" | "intro";
106
+ export declare function sliceUnit(source: string, span: Span, part?: UnitPart): string;
107
+ export declare function findBlockSite(blocks: Block[], id: string): {
108
+ siblings: Block[];
109
+ index: number;
110
+ } | undefined;
111
+ export declare function sectionEndIndex(siblings: Block[], k: number): number;
112
+ export declare function historyPathFor(geml: string): string;
113
+ export declare const VERSION = "1.0";
82
114
  export declare const PARSER_VERSION: string;