obsidian-mcp-server 3.5.5 → 3.6.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.
Files changed (50) hide show
  1. package/AGENTS.md +4 -2
  2. package/CLAUDE.md +4 -2
  3. package/README.md +8 -8
  4. package/changelog/3.6.x/3.6.0.md +31 -0
  5. package/dist/mcp-server/tools/definitions/_shared/schemas.d.ts.map +1 -1
  6. package/dist/mcp-server/tools/definitions/_shared/schemas.js +1 -1
  7. package/dist/mcp-server/tools/definitions/_shared/schemas.js.map +1 -1
  8. package/dist/mcp-server/tools/definitions/index.d.ts +36 -0
  9. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  10. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts +12 -0
  11. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts.map +1 -1
  12. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js +15 -2
  13. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js.map +1 -1
  14. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts +3 -2
  15. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts.map +1 -1
  16. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js +4 -3
  17. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js.map +1 -1
  18. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts +15 -2
  19. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts.map +1 -1
  20. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js +18 -4
  21. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js.map +1 -1
  22. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts +12 -0
  23. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts.map +1 -1
  24. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js +23 -10
  25. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js.map +1 -1
  26. package/dist/services/obsidian/frontmatter-ops.d.ts +4 -3
  27. package/dist/services/obsidian/frontmatter-ops.d.ts.map +1 -1
  28. package/dist/services/obsidian/frontmatter-ops.js +379 -114
  29. package/dist/services/obsidian/frontmatter-ops.js.map +1 -1
  30. package/dist/services/obsidian/markdown-blocks.d.ts +39 -0
  31. package/dist/services/obsidian/markdown-blocks.d.ts.map +1 -0
  32. package/dist/services/obsidian/markdown-blocks.js +611 -0
  33. package/dist/services/obsidian/markdown-blocks.js.map +1 -0
  34. package/dist/services/obsidian/obsidian-service.d.ts +9 -7
  35. package/dist/services/obsidian/obsidian-service.d.ts.map +1 -1
  36. package/dist/services/obsidian/obsidian-service.js +308 -111
  37. package/dist/services/obsidian/obsidian-service.js.map +1 -1
  38. package/dist/services/obsidian/patch-instruction.d.ts +141 -0
  39. package/dist/services/obsidian/patch-instruction.d.ts.map +1 -0
  40. package/dist/services/obsidian/patch-instruction.js +217 -0
  41. package/dist/services/obsidian/patch-instruction.js.map +1 -0
  42. package/dist/services/obsidian/section-extractor.d.ts +97 -24
  43. package/dist/services/obsidian/section-extractor.d.ts.map +1 -1
  44. package/dist/services/obsidian/section-extractor.js +295 -58
  45. package/dist/services/obsidian/section-extractor.js.map +1 -1
  46. package/dist/services/obsidian/types.d.ts +12 -5
  47. package/dist/services/obsidian/types.d.ts.map +1 -1
  48. package/manifest.json +1 -1
  49. package/package.json +2 -1
  50. package/server.json +3 -3
@@ -1,7 +1,8 @@
1
1
  /**
2
- * @fileoverview Client-side section extraction from a NoteJson body.
3
- * The upstream Local REST API exposes section *targeting* for PATCH but not
4
- * section-extracted GET, so we slice the markdown ourselves for `format: 'section'`.
2
+ * @fileoverview Client-side section extraction from a NoteJson body for
3
+ * `format: 'section'`. Headings are found the way the plugin's markdown-patch
4
+ * finds them for its document map and PATCH targeting, so a section read
5
+ * covers the span a section write edits, sliced from the note's own bytes.
5
6
  * @module services/obsidian/section-extractor
6
7
  */
7
8
  import type { NoteJson, SectionTarget } from './types.js';
@@ -27,35 +28,107 @@ export interface SectionExtraction {
27
28
  * Throws `NotFound` if the target does not exist in the note.
28
29
  */
29
30
  export declare function extractSection(note: NoteJson, section: SectionTarget): SectionExtraction;
30
- /** An ATX heading line's level and text. */
31
- export interface AtxHeading {
32
- /** Number of leading `#` characters. */
31
+ /** A heading as the plugin's parser reads it, located in the note's own bytes. */
32
+ export interface Heading {
33
+ /**
34
+ * Offset just past the heading's last line — its underline, for a setext
35
+ * heading — and that line's ending, or the note's length.
36
+ */
37
+ end: number;
38
+ /** 1–6: the `#` count of an ATX heading, 1 or 2 for a setext `=` or `-` underline. */
33
39
  level: number;
34
- /** Heading text with the closing `#` run and surrounding whitespace removed. Empty for an untitled heading. */
40
+ /** Offset of the heading's first byte: its `#` line (indent included), or a setext heading's first text line. */
41
+ start: number;
42
+ /**
43
+ * Heading text as the document map keys it: the parser's text, trimmed.
44
+ * Empty for an untitled heading; a multi-line setext heading keeps its
45
+ * newlines.
46
+ */
35
47
  text: string;
36
48
  }
37
49
  /**
38
- * Parse one line as an ATX heading, or return `undefined` when it is not one.
39
- *
40
- * This is the ATX heading test the plugin's document map applies (its markdown
41
- * parser, `marked`), so every ATX locator the map emits names a heading this
42
- * scan finds under the same text. It follows CommonMark's ATX rules with the
43
- * parser's two measured differences: any whitespace separates the `#` run
44
- * from the text, and a closing `#` run is stripped only when a space — not a
45
- * tab — precedes it (`## Foo\t##` keeps `Foo\t##`). A bare `##`, `## ##`, and
46
- * `## ` are untitled headings; `#hashtag`, seven `#`, and a four-space
47
- * indent are not headings.
50
+ * Every heading in `content`, in document order, found the way the plugin's
51
+ * markdown-patch 2.0 finds them for its document map and PATCH targeting: the
52
+ * frontmatter-stripped body, line endings normalized, lexed with `marked`, and
53
+ * each top-level `heading` token located by accumulating token `raw` lengths.
54
+ * That reads setext headings and skips `#` lines inside fences, HTML blocks,
55
+ * list items, and blockquotes, exactly as the map does. Offsets are mapped
56
+ * back to `content`, so a slice between them is the note's own bytes, CRs
57
+ * included.
48
58
  */
49
- export declare function parseAtxHeading(line: string): AtxHeading | undefined;
59
+ export declare function scanHeadings(content: string): Heading[];
60
+ /** A section's own body, as markdown-patch 2.0 models it for a `within` write. */
61
+ export interface SectionBody {
62
+ /**
63
+ * `marked` token type of each top-level block in the section's direct body —
64
+ * below its heading line and above its first sub-heading — in order: the
65
+ * blocks a 2.0 `within` index counts (`paragraph`, `list`, `table`, `code`, …).
66
+ */
67
+ blocks: string[];
68
+ /**
69
+ * The section's `content` scope in the note's own bytes: below its heading
70
+ * line through its last subsection. What 2.0's `rejectIfContentPreexists`
71
+ * searches on a plain heading write.
72
+ */
73
+ content: string;
74
+ /** Whether sub-headings follow the direct body — a plain append lands below them. */
75
+ subsections: boolean;
76
+ }
50
77
  /**
51
- * Full `::`-joined path of every ATX heading in `content`, in document order,
52
- * repeats included. Deduplicated and with the `""` entry dropped, this is the
53
- * document map's `headings` array for a note whose headings are all top-level
54
- * ATX lines. The plugin's parser also reads setext headings, and reads no
55
- * heading in a line that continues a list item or sits inside an HTML block;
56
- * this line scan does neither.
78
+ * The body of the heading at full path `path` (its first occurrence), read
79
+ * from one lex of the note, or `undefined` when the note has no such heading.
80
+ * 2.0 assigns a section every top-level token between its heading and the
81
+ * next heading of any level; a `space` token is not a block.
82
+ */
83
+ export declare function sectionBody(content: string, path: string): SectionBody | undefined;
84
+ /** The `marked` token type of each top-level block in `markdown`, in order. */
85
+ export declare function blockKinds(markdown: string): string[];
86
+ /**
87
+ * Full `::`-joined path of every heading in `content`, in document order,
88
+ * repeats included — the markdown-patch 2.0 map's heading tree, flattened.
89
+ * Deduplicated and with the `""` entry dropped, it is the 1.x map's `headings`
90
+ * array.
57
91
  */
58
92
  export declare function listHeadingPaths(content: string): string[];
93
+ /**
94
+ * The level of the heading at full path `path` in `content` — its first
95
+ * occurrence. For a path the note does not have: with `create`, the level
96
+ * markdown-patch 2.0 gives it when `createTargetIfMissing` creates it — one
97
+ * below the deepest existing ancestor for each missing segment, counted from 0
98
+ * when no ancestor exists — and without, `undefined`.
99
+ */
100
+ export declare function sectionLevel(content: string, path: string, create: boolean): number | undefined;
101
+ /**
102
+ * True when `blockId` is referenced in `content` by an isolated marker: a
103
+ * `^blockId` line on its own, after a blank line (or at the body's start), so
104
+ * the parser reads it as its own paragraph and the id names the block above.
105
+ * A marker line with no blank line above it continues that block instead (a
106
+ * table row, a paragraph line, a list item), and a line inside a fence or
107
+ * indented as code is not a marker.
108
+ */
109
+ export declare function isIsolatedBlockId(content: string, blockId: string): boolean;
110
+ /** The `#` run opening a top-level ATX heading in a markdown fragment. */
111
+ export interface AtxHeadingMarker {
112
+ /** Length of the `#` run — the heading's level. */
113
+ hashes: number;
114
+ /** The heading's line, trimmed, for messages. */
115
+ line: string;
116
+ /** Offset of the run's first `#` in the fragment's `normalized` text. */
117
+ start: number;
118
+ }
119
+ /** A markdown fragment with its line endings read as `\n`, and its ATX heading markers. */
120
+ export interface AtxHeadingFragment {
121
+ markers: AtxHeadingMarker[];
122
+ normalized: string;
123
+ }
124
+ /**
125
+ * The `#` run of every top-level ATX heading in `markdown`, found as
126
+ * markdown-patch 2.0 finds the headings it re-levels in written content: line
127
+ * endings normalized, lexed with `marked`, and each top-level `heading` token
128
+ * whose raw text opens with a `#` run. A setext heading, a `#` line inside a
129
+ * fence or HTML block, and a hashtag carry none.
130
+ */
131
+ export declare function atxHeadingMarkers(markdown: string): AtxHeadingFragment;
59
132
  /**
60
133
  * Mark line indices that fall inside fenced code blocks (` ``` ` or `~~~`) so
61
134
  * downstream scanning doesn't false-match on markdown-about-markdown notes.
@@ -1 +1 @@
1
- {"version":3,"file":"section-extractor.d.ts","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK1D,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CASxF;AAYD,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,+GAA+G;IAC/G,IAAI,EAAE,MAAM,CAAC;CACd;AAeD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CASpE;AAsCD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1D;AAqID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,SAAI,GAAG,OAAO,EAAE,CA0BrE"}
1
+ {"version":3,"file":"section-extractor.d.ts","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK1D,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CASxF;AAYD,kFAAkF;AAClF,MAAM,WAAW,OAAO;IACtB;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AAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CActE;AAmJD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,SAAI,GAAG,OAAO,EAAE,CA0BrE"}
@@ -1,10 +1,12 @@
1
1
  /**
2
- * @fileoverview Client-side section extraction from a NoteJson body.
3
- * The upstream Local REST API exposes section *targeting* for PATCH but not
4
- * section-extracted GET, so we slice the markdown ourselves for `format: 'section'`.
2
+ * @fileoverview Client-side section extraction from a NoteJson body for
3
+ * `format: 'section'`. Headings are found the way the plugin's markdown-patch
4
+ * finds them for its document map and PATCH targeting, so a section read
5
+ * covers the span a section write edits, sliced from the note's own bytes.
5
6
  * @module services/obsidian/section-extractor
6
7
  */
7
8
  import { notFound } from '@cyanheads/mcp-ts-core/errors';
9
+ import { getDefaults, Lexer, Tokenizer } from 'marked';
8
10
  import { splice } from './frontmatter-ops.js';
9
11
  /** Delimiter joining a heading path, matching upstream's PATCH `Target-Delimiter`. */
10
12
  const HEADING_DELIMITER = '::';
@@ -32,51 +34,209 @@ function extractFrontmatterField(note, key) {
32
34
  return note.frontmatter[key];
33
35
  }
34
36
  /**
35
- * Up to three spaces of indent, one to six `#`, then whitespace or the end of
36
- * the line. The `s` flag lets `.` take the `\r` a CRLF line keeps after the
37
- * split on `\n`, so `##\r` is an untitled heading and `## Foo\r` reads `Foo`.
37
+ * The frontmatter block markdown-patch strips before it lexes: an opening
38
+ * `---` line, then either a `---` line at once or YAML and a closing `---`
39
+ * line, with CRLF, LF, or lone-CR endings. `splice` — the boundary block
40
+ * extraction and the body-scoped writers use — also closes on a `---` with
41
+ * more text after it on its line; the heading scan follows the plugin here so
42
+ * its paths match the plugin's map.
38
43
  */
39
- const ATX_HEADING = /^ {0,3}(#{1,6})(?:\s(.*))?$/s;
44
+ const PLUGIN_FRONTMATTER = /^---(?:\r\n|\r|\n)(?:---(?:\r\n|\r|\n|$)|[\s\S]*?(?:\r\n|\r|\n)---(?:\r\n|\r|\n|$))/;
40
45
  /**
41
- * Parse one line as an ATX heading, or return `undefined` when it is not one.
42
- *
43
- * This is the ATX heading test the plugin's document map applies (its markdown
44
- * parser, `marked`), so every ATX locator the map emits names a heading this
45
- * scan finds under the same text. It follows CommonMark's ATX rules with the
46
- * parser's two measured differences: any whitespace separates the `#` run
47
- * from the text, and a closing `#` run is stripped only when a space — not a
48
- * tab — precedes it (`## Foo\t##` keeps `Foo\t##`). A bare `##`, `## ##`, and
49
- * `## ` are untitled headings; `#hashtag`, seven `#`, and a four-space
50
- * indent are not headings.
46
+ * Every heading in `content`, in document order, found the way the plugin's
47
+ * markdown-patch 2.0 finds them for its document map and PATCH targeting: the
48
+ * frontmatter-stripped body, line endings normalized, lexed with `marked`, and
49
+ * each top-level `heading` token located by accumulating token `raw` lengths.
50
+ * That reads setext headings and skips `#` lines inside fences, HTML blocks,
51
+ * list items, and blockquotes, exactly as the map does. Offsets are mapped
52
+ * back to `content`, so a slice between them is the note's own bytes, CRs
53
+ * included.
54
+ */
55
+ export function scanHeadings(content) {
56
+ const { normalized, at } = pluginBody(content);
57
+ return [...topLevelTokens(normalized)].flatMap((top) => {
58
+ const heading = headingOf(normalized, top);
59
+ return heading ? [{ ...heading, start: at(heading.start), end: at(heading.end) }] : [];
60
+ });
61
+ }
62
+ /**
63
+ * The body markdown-patch lexes — `content` past its frontmatter, line endings
64
+ * read as `\n` — and a map from an offset in it back to `content`.
65
+ */
66
+ function pluginBody(content) {
67
+ const bodyStart = PLUGIN_FRONTMATTER.exec(content)?.[0].length ?? 0;
68
+ const { normalized, toOriginal } = normalizeLineEndings(content.slice(bodyStart));
69
+ return { normalized, at: (offset) => bodyStart + toOriginal(offset) };
70
+ }
71
+ /**
72
+ * The top-level token at `offset` in `normalized` as a heading, its offsets in
73
+ * `normalized`: `end` is just past its last line and that line's ending — or
74
+ * `undefined` when the token is not a heading.
51
75
  */
52
- export function parseAtxHeading(line) {
53
- const m = ATX_HEADING.exec(line);
54
- if (!m)
76
+ function headingOf(normalized, { token, offset }) {
77
+ if (token.type !== 'heading')
78
+ return;
79
+ const { depth, text } = token;
80
+ const lineEnd = normalized.indexOf('\n', offset + token.raw.trimEnd().length);
81
+ return {
82
+ level: depth,
83
+ text: text.trim(),
84
+ start: offset,
85
+ end: lineEnd === -1 ? normalized.length : lineEnd + 1,
86
+ };
87
+ }
88
+ /**
89
+ * The body of the heading at full path `path` (its first occurrence), read
90
+ * from one lex of the note, or `undefined` when the note has no such heading.
91
+ * 2.0 assigns a section every top-level token between its heading and the
92
+ * next heading of any level; a `space` token is not a block.
93
+ */
94
+ export function sectionBody(content, path) {
95
+ const { normalized, at } = pluginBody(content);
96
+ const tokens = [...topLevelTokens(normalized)];
97
+ const headings = tokens.flatMap((top, index) => {
98
+ const heading = headingOf(normalized, top);
99
+ return heading ? [{ ...heading, index }] : [];
100
+ });
101
+ const h = headingPaths(headings).indexOf(path);
102
+ const heading = headings[h];
103
+ if (!heading)
55
104
  return;
56
- let text = (m[2] ?? '').trim();
57
- if (text.endsWith('#')) {
58
- const open = text.replace(/#+$/, '');
59
- if (open === '' || open.endsWith(' '))
60
- text = open.trim();
105
+ const next = headings[h + 1];
106
+ const closing = headings.find((other, i) => i > h && other.level <= heading.level);
107
+ return {
108
+ blocks: tokens
109
+ .slice(heading.index + 1, next?.index)
110
+ .filter(({ token }) => token.type !== 'space')
111
+ .map(({ token }) => token.type),
112
+ content: content.slice(at(heading.end), at(closing?.start ?? normalized.length)),
113
+ subsections: next !== undefined && next.level > heading.level,
114
+ };
115
+ }
116
+ /** The `marked` token type of each top-level block in `markdown`, in order. */
117
+ export function blockKinds(markdown) {
118
+ return [...topLevelTokens(normalizeLineEndings(markdown).normalized)].flatMap(({ token }) => token.type === 'space' ? [] : [token.type]);
119
+ }
120
+ /**
121
+ * The top-level block tokens `marked` reads in `markdown` (line endings
122
+ * already `\n`), each with its offset — the running sum of the `raw` lengths
123
+ * before it, which cover the input exactly.
124
+ */
125
+ function* topLevelTokens(markdown) {
126
+ const tokenizer = new HeadingScanTokenizer();
127
+ const lexer = new Lexer({ ...getDefaults(), tokenizer });
128
+ const { rules } = tokenizer;
129
+ tokenizer.rules = { ...rules, block: { ...rules.block, paragraph: PARAGRAPH } };
130
+ let offset = 0;
131
+ for (const token of lexer.blockTokens(markdown)) {
132
+ yield { offset, token };
133
+ offset += token.raw.length;
61
134
  }
62
- return { level: (m[1] ?? '').length, text };
63
135
  }
64
136
  /**
65
- * Collect every ATX heading in the note body, in document order. Setext
66
- * headings are not markdown this extractor recognizes, and lines inside a
67
- * fenced code block or a frontmatter block are excluded.
137
+ * `marked`'s GFM paragraph rule, changed in cost and not in outcome. At every
138
+ * line a paragraph runs on to, the stock rule asks whether a table starts
139
+ * there, and its table pattern goes on through every following row before the
140
+ * answer comes back — a scan of the rest of the note per paragraph, so a note
141
+ * of pipe lines over one-dash lines (`| a | b |` / `| - |`, repeated) lexes in
142
+ * quadratic time. The rows cannot change the answer (the pattern accepts none
143
+ * of them), so here the check ends after the header and delimiter lines.
144
+ * Built from the stock rule's own source, so it follows the installed
145
+ * `marked`; a source that no longer embeds the table pattern fails at load.
68
146
  */
69
- function scanHeadings(lines, bodyStart) {
70
- const inFence = computeFenceMask(lines, bodyStart);
71
- const headings = [];
72
- for (let i = bodyStart; i < lines.length; i++) {
73
- if (inFence[i])
74
- continue;
75
- const heading = parseAtxHeading(lines[i] ?? '');
76
- if (heading)
77
- headings.push({ index: i, ...heading });
147
+ const PARAGRAPH = (() => {
148
+ const { paragraph, table } = Lexer.rules.block.gfm;
149
+ /** The table pattern as `marked` embeds it: every `^` outside a class dropped. */
150
+ const embedded = table.source.replace(/(^|[^[])\^/g, '$1');
151
+ const rows = embedded.indexOf('(?:\\n((?:');
152
+ const bounded = `${embedded.slice(0, rows)}(?:\\n|$)`;
153
+ const source = paragraph.source.replace(embedded, () => bounded);
154
+ if (rows === -1 || source === paragraph.source) {
155
+ throw new Error("marked's GFM paragraph rule no longer embeds its table rule as expected.");
156
+ }
157
+ return new RegExp(source, paragraph.flags);
158
+ })();
159
+ /**
160
+ * `marked`'s tokenizer, changed in cost and not in the top-level tokens'
161
+ * types and extents — all the heading scan reads.
162
+ *
163
+ * - `table`: the GFM table rule matches every following row before it checks
164
+ * the header and delimiter lines, so a line that looks like a header over
165
+ * one that looks like a delimiter but fails the column check (`t` over `-`,
166
+ * `a|b` over `-`) costs a scan of the rest of the note, repeated at each
167
+ * such pair. The header and delimiter lines decide the outcome on their
168
+ * own, so the rule runs on those two lines first and on the whole source
169
+ * only when they pass.
170
+ * - `blockquote`: the stock rule lexes a blockquote's content to find where
171
+ * it ends, and each nested level lexes it again, so `>` nested a thousand
172
+ * deep costs a thousand passes over every line after it. A run of lines
173
+ * that each open with `>` and that ends the note or meets an empty line is
174
+ * the whole blockquote whatever the lines hold, so its extent is known
175
+ * without lexing it. The token then carries no child tokens, which nothing
176
+ * here reads. Any other shape — a lazy continuation line — goes to the
177
+ * stock rule, which still costs a pass per nesting level.
178
+ */
179
+ class HeadingScanTokenizer extends Tokenizer {
180
+ table(src) {
181
+ const headerEnd = src.indexOf('\n');
182
+ const delimiterEnd = headerEnd === -1 ? -1 : src.indexOf('\n', headerEnd + 1);
183
+ if (delimiterEnd !== -1 && !super.table(src.slice(0, delimiterEnd + 1)))
184
+ return;
185
+ return super.table(src);
186
+ }
187
+ blockquote(src) {
188
+ const { blockquoteStart, blockquoteSetextReplace, blockquoteSetextReplace2 } = this.rules.other;
189
+ let end = -1;
190
+ let next = 0;
191
+ while (next < src.length) {
192
+ const newline = src.indexOf('\n', next);
193
+ const lineEnd = newline === -1 ? src.length : newline;
194
+ if (!blockquoteStart.test(src.slice(next, lineEnd)))
195
+ break;
196
+ end = lineEnd;
197
+ next = lineEnd + 1;
198
+ }
199
+ /**
200
+ * A run of `>` lines that ends the note or meets an empty line is the whole
201
+ * blockquote: only a non-empty line can continue it lazily.
202
+ */
203
+ if (end === -1 || (next < src.length && src[next] !== '\n'))
204
+ return super.blockquote(src);
205
+ const raw = src.slice(0, end);
206
+ const text = raw
207
+ .replace(blockquoteSetextReplace, '\n $1')
208
+ .replace(blockquoteSetextReplace2, '');
209
+ return { type: 'blockquote', raw, text, tokens: [] };
78
210
  }
79
- return headings;
211
+ }
212
+ /**
213
+ * `text` with every `\r\n` and lone `\r` read as `\n` — what `marked` lexes —
214
+ * and a map from an offset in that text back to the same position in `text`.
215
+ * A collapsed `\r\n` maps to its `\r`.
216
+ */
217
+ function normalizeLineEndings(text) {
218
+ /** Offsets in `normalized` of each `\n` that stands for a `\r\n`, ascending. */
219
+ const collapsed = [];
220
+ const normalized = text.replace(/\r\n?/g, (ending, at) => {
221
+ if (ending.length === 2)
222
+ collapsed.push(at - collapsed.length);
223
+ return '\n';
224
+ });
225
+ return {
226
+ normalized,
227
+ toOriginal: (offset) => {
228
+ let lo = 0;
229
+ let hi = collapsed.length;
230
+ while (lo < hi) {
231
+ const mid = (lo + hi) >>> 1;
232
+ if ((collapsed[mid] ?? 0) < offset)
233
+ lo = mid + 1;
234
+ else
235
+ hi = mid;
236
+ }
237
+ return offset + lo;
238
+ },
239
+ };
80
240
  }
81
241
  /**
82
242
  * Build the full `Parent::Child` path of every heading, in document order. A
@@ -99,15 +259,78 @@ function headingPaths(headings) {
99
259
  });
100
260
  }
101
261
  /**
102
- * Full `::`-joined path of every ATX heading in `content`, in document order,
103
- * repeats included. Deduplicated and with the `""` entry dropped, this is the
104
- * document map's `headings` array for a note whose headings are all top-level
105
- * ATX lines. The plugin's parser also reads setext headings, and reads no
106
- * heading in a line that continues a list item or sits inside an HTML block;
107
- * this line scan does neither.
262
+ * Full `::`-joined path of every heading in `content`, in document order,
263
+ * repeats included — the markdown-patch 2.0 map's heading tree, flattened.
264
+ * Deduplicated and with the `""` entry dropped, it is the 1.x map's `headings`
265
+ * array.
108
266
  */
109
267
  export function listHeadingPaths(content) {
110
- return headingPaths(scanHeadings(content.split('\n'), frontmatterEndLine(content)));
268
+ return headingPaths(scanHeadings(content));
269
+ }
270
+ /**
271
+ * The level of the heading at full path `path` in `content` — its first
272
+ * occurrence. For a path the note does not have: with `create`, the level
273
+ * markdown-patch 2.0 gives it when `createTargetIfMissing` creates it — one
274
+ * below the deepest existing ancestor for each missing segment, counted from 0
275
+ * when no ancestor exists — and without, `undefined`.
276
+ */
277
+ export function sectionLevel(content, path, create) {
278
+ const headings = scanHeadings(content);
279
+ const paths = headingPaths(headings);
280
+ const own = headings[paths.indexOf(path)];
281
+ if (own || !create)
282
+ return own?.level;
283
+ const segments = path.split(HEADING_DELIMITER);
284
+ for (let depth = segments.length - 1; depth >= 1; depth--) {
285
+ const found = headings[paths.indexOf(segments.slice(0, depth).join(HEADING_DELIMITER))];
286
+ if (found)
287
+ return found.level + segments.length - depth;
288
+ }
289
+ return segments.length;
290
+ }
291
+ /**
292
+ * True when `blockId` is referenced in `content` by an isolated marker: a
293
+ * `^blockId` line on its own, after a blank line (or at the body's start), so
294
+ * the parser reads it as its own paragraph and the id names the block above.
295
+ * A marker line with no blank line above it continues that block instead (a
296
+ * table row, a paragraph line, a list item), and a line inside a fence or
297
+ * indented as code is not a marker.
298
+ */
299
+ export function isIsolatedBlockId(content, blockId) {
300
+ const lines = content.split('\n').map((line) => line.replace(/\r$/, ''));
301
+ const bodyStart = frontmatterEndLine(content);
302
+ const inFence = computeFenceMask(lines, bodyStart);
303
+ const marker = `^${blockId}`;
304
+ return lines.some((line, i) => i >= bodyStart &&
305
+ !inFence[i] &&
306
+ line.trim() === marker &&
307
+ !/^(?: {4}|\t)/.test(line) &&
308
+ (i === bodyStart || (lines[i - 1] ?? '').trim() === ''));
309
+ }
310
+ /** An ATX heading's opening: up to three spaces or tabs, then its `#` run. */
311
+ const ATX_OPENING = /^([ \t]{0,3})(#+)/;
312
+ /**
313
+ * The `#` run of every top-level ATX heading in `markdown`, found as
314
+ * markdown-patch 2.0 finds the headings it re-levels in written content: line
315
+ * endings normalized, lexed with `marked`, and each top-level `heading` token
316
+ * whose raw text opens with a `#` run. A setext heading, a `#` line inside a
317
+ * fence or HTML block, and a hashtag carry none.
318
+ */
319
+ export function atxHeadingMarkers(markdown) {
320
+ const { normalized } = normalizeLineEndings(markdown);
321
+ const markers = [];
322
+ for (const { token, offset } of topLevelTokens(normalized)) {
323
+ const opening = token.type === 'heading' ? ATX_OPENING.exec(token.raw) : null;
324
+ if (!opening)
325
+ continue;
326
+ const [, indent = '', hashes = ''] = opening;
327
+ markers.push({
328
+ hashes: hashes.length,
329
+ line: token.raw.trim().split('\n')[0] ?? '',
330
+ start: offset + indent.length,
331
+ });
332
+ }
333
+ return { markers, normalized };
111
334
  }
112
335
  /**
113
336
  * Walk a `::`-split target one segment at a time: each segment matches the
@@ -162,8 +385,7 @@ function extractHeading(content, target) {
162
385
  if (!qualified && !leaf) {
163
386
  throw notFound('Empty heading target.', { target });
164
387
  }
165
- const lines = content.split('\n');
166
- const headings = scanHeadings(lines, frontmatterEndLine(content));
388
+ const headings = scanHeadings(content);
167
389
  const paths = headingPaths(headings);
168
390
  const exact = qualified ? paths.indexOf(parts.join(HEADING_DELIMITER)) : -1;
169
391
  const matched = exact >= 0 ? exact : walkSegments(headings, parts);
@@ -172,16 +394,13 @@ function extractHeading(content, target) {
172
394
  if (!hit || resolved === undefined) {
173
395
  throw notFound(`Heading '${target}' not found.`, { target });
174
396
  }
175
- // Slice from the matched heading line to the next heading at the same or shallower level.
397
+ // Slice from the matched heading to the next heading at the same or shallower level.
176
398
  const end = headings.find((h, i) => i > matched && h.level <= hit.level);
177
399
  const candidates = qualified
178
400
  ? paths.filter((p) => p === resolved)
179
401
  : paths.filter((_, i) => headings[i]?.text === leaf);
180
402
  return {
181
- value: lines
182
- .slice(hit.index, end?.index ?? lines.length)
183
- .join('\n')
184
- .replace(/\n+$/, ''),
403
+ value: content.slice(hit.start, end?.start).replace(/\n+$/, ''),
185
404
  sectionTarget: resolved,
186
405
  ...(candidates.length > 1 ? { candidates } : {}),
187
406
  };
@@ -189,12 +408,13 @@ function extractHeading(content, target) {
189
408
  /**
190
409
  * Match a block by its `^blockId` reference. Returns the line containing the
191
410
  * reference plus any preceding lines belonging to the same paragraph (until a
192
- * blank line or an ATX heading, untitled ones included).
411
+ * blank line or a heading line — a setext underline, an untitled heading).
193
412
  */
194
413
  function extractBlock(content, blockId) {
195
414
  const lines = content.split('\n');
196
415
  const bodyStart = frontmatterEndLine(content);
197
416
  const inFence = computeFenceMask(lines, bodyStart);
417
+ const isHeading = headingLineMask(content, lines);
198
418
  const escaped = blockId.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
199
419
  const ref = new RegExp(`(^|\\s)\\^${escaped}\\s*$`);
200
420
  for (let i = bodyStart; i < lines.length; i++) {
@@ -204,7 +424,7 @@ function extractBlock(content, blockId) {
204
424
  let start = i;
205
425
  while (start > bodyStart) {
206
426
  const prev = lines[start - 1] ?? '';
207
- if (prev.trim() === '' || parseAtxHeading(prev))
427
+ if (prev.trim() === '' || isHeading[start - 1])
208
428
  break;
209
429
  start--;
210
430
  }
@@ -213,12 +433,29 @@ function extractBlock(content, blockId) {
213
433
  }
214
434
  throw notFound(`Block reference '^${blockId}' not found.`, { blockId });
215
435
  }
436
+ /**
437
+ * Mark the indices of `lines` (`content` split on `\n`) that a heading
438
+ * occupies: an ATX heading's line, or a setext heading's text lines and
439
+ * underline.
440
+ */
441
+ function headingLineMask(content, lines) {
442
+ const headings = scanHeadings(content);
443
+ let h = 0;
444
+ let lineStart = 0;
445
+ return lines.map((line) => {
446
+ const lineEnd = lineStart + line.length;
447
+ while ((headings[h]?.end ?? Number.POSITIVE_INFINITY) <= lineStart)
448
+ h++;
449
+ const onHeading = (headings[h]?.start ?? Number.POSITIVE_INFINITY) <= lineEnd;
450
+ lineStart = lineEnd + 1;
451
+ return onHeading;
452
+ });
453
+ }
216
454
  /**
217
455
  * Return the line index where the document body starts, skipping a leading YAML
218
456
  * frontmatter block. Returns 0 when no frontmatter is present. Without this
219
- * guard, heading and block extraction would scan inside the frontmatter and
220
- * falsely match YAML comment lines or include the fence in a paragraph
221
- * walk-back.
457
+ * guard, block extraction would scan inside the frontmatter and falsely match a
458
+ * reference there or include the fence in a paragraph walk-back.
222
459
  *
223
460
  * The boundary comes from `splice` rather than a second line scan, so the read
224
461
  * path and every body-scoped write path agree on where the body starts —
@@ -1 +1 @@
1
- {"version":3,"file":"section-extractor.js","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,sFAAsF;AACtF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAoB/B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAc,EAAE,OAAsB;IACnE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,aAAa;YAChB,OAAO,EAAE,KAAK,EAAE,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClE,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,KAAK,OAAO;YACV,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACjE,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAc,EAAE,GAAW;IAC1D,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,oBAAoB,GAAG,kBAAkB,IAAI,CAAC,IAAI,GAAG,EAAE;YACpE,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG;SACJ,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GAAG,KAAK,CAAC,CAAC,CAAc,CAAC;gBACjC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;gBACvB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,SAAS;QACX,CAAC;QACD,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACf,IAAI,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC;gBACrD,QAAQ,GAAG,IAAI,CAAC;gBAChB,OAAO,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"section-extractor.js","sourceRoot":"","sources":["../../../src/services/obsidian/section-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAc,SAAS,EAAe,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,sFAAsF;AACtF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAoB/B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAc,EAAE,OAAsB;IACnE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,aAAa;YAChB,OAAO,EAAE,KAAK,EAAE,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClE,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,K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