@jpeakai/prose-gates 0.3.1 → 0.4.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.
package/dist/bin.js CHANGED
@@ -37539,12 +37539,17 @@ var visitParagraph = (state, p5, ancestors) => {
37539
37539
  var visitText = (state, t3, ancestors, paragraph) => {
37540
37540
  const start2 = t3.position?.start.offset;
37541
37541
  const end2 = t3.position?.end.offset;
37542
+ let language;
37542
37543
  state.texts.push({
37543
37544
  value: t3.value,
37544
37545
  line: t3.position?.start.line ?? 0,
37545
37546
  start: start2,
37546
37547
  end: end2,
37547
- block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell")
37548
+ block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell"),
37549
+ get language() {
37550
+ language ??= languageOf(t3.value, state.concepts);
37551
+ return language;
37552
+ }
37548
37553
  });
37549
37554
  if (!paragraph)
37550
37555
  return;
package/dist/index.js CHANGED
@@ -37534,12 +37534,17 @@ var visitParagraph = (state, p5, ancestors) => {
37534
37534
  var visitText = (state, t3, ancestors, paragraph) => {
37535
37535
  const start2 = t3.position?.start.offset;
37536
37536
  const end2 = t3.position?.end.offset;
37537
+ let language;
37537
37538
  state.texts.push({
37538
37539
  value: t3.value,
37539
37540
  line: t3.position?.start.line ?? 0,
37540
37541
  start: start2,
37541
37542
  end: end2,
37542
- block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell")
37543
+ block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell"),
37544
+ get language() {
37545
+ language ??= languageOf(t3.value, state.concepts);
37546
+ return language;
37547
+ }
37543
37548
  });
37544
37549
  if (!paragraph)
37545
37550
  return;
package/dist/testing.js CHANGED
@@ -37352,12 +37352,17 @@ var visitParagraph = (state, p5, ancestors) => {
37352
37352
  var visitText = (state, t3, ancestors, paragraph) => {
37353
37353
  const start2 = t3.position?.start.offset;
37354
37354
  const end2 = t3.position?.end.offset;
37355
+ let language;
37355
37356
  state.texts.push({
37356
37357
  value: t3.value,
37357
37358
  line: t3.position?.start.line ?? 0,
37358
37359
  start: start2,
37359
37360
  end: end2,
37360
- block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell")
37361
+ block: ancestors.findLast((a2) => a2.type === "paragraph" || a2.type === "heading" || a2.type === "tableCell"),
37362
+ get language() {
37363
+ language ??= languageOf(t3.value, state.concepts);
37364
+ return language;
37365
+ }
37361
37366
  });
37362
37367
  if (!paragraph)
37363
37368
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpeakai/prose-gates",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Deterministic prose gates for markdown documentation",
6
6
  "license": "MIT",
package/src/model.ts CHANGED
@@ -55,6 +55,9 @@ export interface TextView {
55
55
  start: number | undefined;
56
56
  end: number | undefined;
57
57
  block: Node | undefined; // nearest paragraph, heading or table cell
58
+ // Its sentences, words, tags and lemmas, read from `value` on first use. A
59
+ // text node is a fragment, so emphasis or a link splits a sentence across texts.
60
+ readonly language: LanguageView;
58
61
  }
59
62
 
60
63
  // A fenced code block tagged markdown/md: a template whose body is itself
@@ -184,12 +187,17 @@ const visitParagraph = (state: WalkState, p: Paragraph, ancestors: Node[]): void
184
187
  const visitText = (state: WalkState, t: Text, ancestors: Node[], paragraph: Paragraph | undefined): void => {
185
188
  const start = t.position?.start.offset;
186
189
  const end = t.position?.end.offset;
190
+ let language: LanguageView | undefined;
187
191
  state.texts.push({
188
192
  value: t.value,
189
193
  line: t.position?.start.line ?? 0,
190
194
  start,
191
195
  end,
192
196
  block: ancestors.findLast((a) => a.type === "paragraph" || a.type === "heading" || a.type === "tableCell"),
197
+ get language() {
198
+ language ??= languageOf(t.value, state.concepts);
199
+ return language;
200
+ },
193
201
  });
194
202
  if (!paragraph) return;
195
203
  state.proseParts.get(paragraph)?.push(t.value);