@hardlydifficult/text 1.0.41 → 1.0.42

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
@@ -21,8 +21,8 @@ import {
21
21
  buildFileTree,
22
22
  convertFormat,
23
23
  healYaml,
24
- createLinker,
25
- escapeFence,
24
+ linkText,
25
+ codeBlock,
26
26
  stripAnsi
27
27
  } from "@hardlydifficult/text";
28
28
 
@@ -63,13 +63,12 @@ healYaml('description: "Text with: colon"');
63
63
  // 'description: "Text with: colon"'
64
64
 
65
65
  // Linkify issue references
66
- const linker = createLinker().linear("fairmint");
67
- linker.apply("Fix ENG-533", { format: "slack" });
66
+ linkText("Fix ENG-533", { linear: "fairmint", for: "slack" });
68
67
  // "Fix <https://linear.app/fairmint/issue/ENG-533|ENG-533>"
69
68
 
70
- // Escape markdown fences
71
- escapeFence("code with ``` backticks").fence;
72
- // "````"
69
+ // Build a safe markdown code block
70
+ codeBlock("code with ``` backticks", "ts");
71
+ // "````ts\ncode with ``` backticks\n````"
73
72
 
74
73
  // Strip ANSI codes
75
74
  stripAnsi("\x1b[31mRed text\x1b[0m");
@@ -309,84 +308,88 @@ healYaml("description: Text: with colons");
309
308
  // 'description: "Text: with colons"'
310
309
  ```
311
310
 
312
- ## Linker (Text Linkification)
311
+ ## Linkifying References
313
312
 
314
- Transforms text by replacing issue/PR references with formatted links.
313
+ Turns issue and PR references into links without builder ceremony.
315
314
 
316
- ### Linker
315
+ ### linkText
317
316
 
318
- Stateful linker with configurable rules, idempotent linkification, and multi-platform support.
317
+ Best for one-off calls. Built-in presets cover the formats used in this repo.
319
318
 
320
319
  ```typescript
321
- import { createLinker, LinkerPlatform, LinkerApplyOptions } from "@hardlydifficult/text";
322
-
323
- interface LinkerApplyOptions {
324
- format?: LinkerPlatform; // "slack" | "discord" | "markdown" | "plaintext"
325
- platform?: LinkerPlatform;
326
- skipCode?: boolean; // default: true
327
- skipExistingLinks?: boolean; // default: true
328
- linkifyPlainHref?: boolean; // default: false
320
+ import { linkText } from "@hardlydifficult/text";
321
+
322
+ linkText("Fix ENG-533 PR#42", {
323
+ linear: "fairmint",
324
+ githubPrs: "Fairmint/api",
325
+ for: "slack",
326
+ });
327
+ // "Fix <https://linear.app/fairmint/issue/ENG-533|ENG-533> <https://github.com/Fairmint/api/pull/42|PR#42>"
328
+ ```
329
+
330
+ ```typescript
331
+ interface LinkTextOptions {
332
+ linear?: string;
333
+ githubPrs?: string;
334
+ rules?: LinkRule[];
335
+ for?: LinkStyle; // "slack" | "discord" | "markdown" | "plain"
336
+ ignoreCode?: boolean; // default: true
337
+ ignoreExistingLinks?: boolean; // default: true
329
338
  }
330
339
  ```
331
340
 
332
341
  ### createLinker
333
342
 
334
- Creates a linker with optional initial rules.
343
+ Use this when the same link rules are applied repeatedly.
335
344
 
336
345
  ```typescript
337
346
  import { createLinker } from "@hardlydifficult/text";
338
347
 
339
- const linker = createLinker();
340
-
341
- // Fluent API
342
- linker
343
- .linear("fairmint")
344
- .githubPr("Fairmint/api")
345
- .custom(/\bINC-\d+\b/g, ({ match }) => `https://incident.io/${match}`);
346
-
347
- // Linkify text
348
- linker.linkText("Fix ENG-533 PR#42 INC-99", { format: "slack" });
348
+ const linker = createLinker({
349
+ linear: "fairmint",
350
+ githubPrs: "Fairmint/api",
351
+ rules: [
352
+ {
353
+ name: "incident",
354
+ match: /\bINC-\d+\b/g,
355
+ to: ({ text }) => `https://incident.io/${text}`,
356
+ },
357
+ ],
358
+ });
359
+
360
+ linker.link("Fix ENG-533 PR#42 INC-99", { for: "slack" });
349
361
  // "Fix <https://linear.app/fairmint/issue/ENG-533|ENG-533> <https://github.com/Fairmint/api/pull/42|PR#42> <https://incident.io/INC-99|INC-99>"
350
362
  ```
351
363
 
352
- ### Rule API
364
+ ### LinkRule
353
365
 
354
- Custom rules support patterns, href templates or callbacks, priorities, and match metadata.
366
+ Custom rules are small and direct: match text, map it to a URL, optionally set a priority.
355
367
 
356
368
  ```typescript
357
369
  interface LinkRule {
358
- id: string;
359
- priority: number;
360
- pattern: RegExp;
361
- href: string | ((ctx: { match: string; groups?: string[] }) => string);
362
- skipCode?: boolean;
363
- skipExistingLinks?: boolean;
370
+ name?: string;
371
+ match: RegExp;
372
+ to: string | ((ctx: { text: string; groups: string[] }) => string);
373
+ priority?: number;
364
374
  }
365
375
  ```
366
376
 
367
- ### Methods
368
-
369
- - `custom(pattern, href, options)`: Add custom rule
370
- - `linear(orgOrProject)`: Link Linear issues
371
- - `githubPr(repo)`: Link GitHub PRs
372
- - `apply(text, options)`: Linkify and preserve format
373
- - `linkText(text, options)`: Linkify plain text
374
- - `linkMarkdown(text, options)`: Linkify markdown content
375
- - `reset()`: Clear rules
376
-
377
377
  ## Markdown Utilities
378
378
 
379
379
  Tools for working with markdown fences and formatting.
380
380
 
381
- ### escapeFence
381
+ ### codeBlock
382
382
 
383
- Selects the minimal fence length to safely escape content.
383
+ Wraps content in a safe fenced code block and picks a longer fence automatically when needed.
384
384
 
385
385
  ```typescript
386
- import { escapeFence } from "@hardlydifficult/text";
386
+ import { codeBlock } from "@hardlydifficult/text";
387
+
388
+ codeBlock("hello");
389
+ // "```\nhello\n```"
387
390
 
388
- escapeFence("hello"); // { fence: "```", content: "hello" }
389
- escapeFence("code ``` here"); // { fence: "````", content: "code ``` here" }
391
+ codeBlock("const x = 1;", "ts");
392
+ // "```ts\nconst x = 1;\n```"
390
393
  ```
391
394
 
392
395
  ### stripAnsi
@@ -401,4 +404,4 @@ stripAnsi("\x1b[31mRed\x1b[0m"); // "Red"
401
404
 
402
405
  ## License
403
406
 
404
- MIT
407
+ MIT
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Wrap content in a safe fenced markdown code block.
3
+ */
4
+ export declare function codeBlock(content: string, language?: string): string;
5
+ //# sourceMappingURL=codeBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeBlock.d.ts","sourceRoot":"","sources":["../src/codeBlock.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAMpE"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.codeBlock = codeBlock;
4
+ function pickFence(content) {
5
+ let maxBackticks = 3;
6
+ const backtickMatches = content.match(/`+/g);
7
+ if (backtickMatches === null) {
8
+ return "`".repeat(maxBackticks);
9
+ }
10
+ for (const match of backtickMatches) {
11
+ if (match.length >= maxBackticks) {
12
+ maxBackticks = match.length + 1;
13
+ }
14
+ }
15
+ return "`".repeat(maxBackticks);
16
+ }
17
+ /**
18
+ * Wrap content in a safe fenced markdown code block.
19
+ */
20
+ function codeBlock(content, language) {
21
+ const fence = pickFence(content);
22
+ const openingLine = language !== undefined && language !== "" ? `${fence}${language}` : fence;
23
+ const closingPrefix = content.endsWith("\n") ? "" : "\n";
24
+ return `${openingLine}\n${content}${closingPrefix}${fence}`;
25
+ }
26
+ //# sourceMappingURL=codeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeBlock.js","sourceRoot":"","sources":["../src/codeBlock.ts"],"names":[],"mappings":";;AAmBA,8BAMC;AAzBD,SAAS,SAAS,CAAC,OAAe;IAChC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YACjC,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,OAAe,EAAE,QAAiB;IAC1D,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,WAAW,GACf,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,OAAO,GAAG,WAAW,KAAK,OAAO,GAAG,aAAa,GAAG,KAAK,EAAE,CAAC;AAC9D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -10,8 +10,8 @@ export type { TextFormat } from "./convertFormat.js";
10
10
  export { formatWithLineNumbers } from "./formatWithLineNumbers.js";
11
11
  export { formatYaml } from "./formatYaml.js";
12
12
  export { healYaml } from "./healYaml.js";
13
- export { Linker, createLinker, type LinkRule, type LinkHrefBuilder, type LinkMatchContext, type LinkerApplyOptions, type LinkerPlatform, } from "./linker.js";
14
- export { escapeFence } from "./escapeFence.js";
13
+ export { Linker, createLinker, linkText, type LinkRule, type LinkTarget, type LinkContext, type LinkerConfig, type LinkOptions, type LinkStyle, type LinkTextOptions, } from "./linker.js";
14
+ export { codeBlock } from "./codeBlock.js";
15
15
  export { stripAnsi } from "./stripAnsi.js";
16
16
  export { isWaitingForInput } from "./questionDetection.js";
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO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AAoB,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWaitingForInput = exports.stripAnsi = exports.escapeFence = exports.createLinker = exports.Linker = exports.healYaml = exports.formatYaml = exports.formatWithLineNumbers = exports.convertFormat = exports.FILE_TREE_DEFAULTS = exports.buildFileTree = exports.formatDuration = exports.slugify = exports.chunkText = exports.extractPlaceholders = exports.replaceTemplate = exports.formatErrorForLog = exports.formatError = exports.getErrorMessage = void 0;
3
+ exports.isWaitingForInput = exports.stripAnsi = exports.codeBlock = exports.linkText = exports.createLinker = exports.Linker = exports.healYaml = exports.formatYaml = exports.formatWithLineNumbers = exports.convertFormat = exports.FILE_TREE_DEFAULTS = exports.buildFileTree = exports.formatDuration = exports.slugify = exports.chunkText = exports.extractPlaceholders = exports.replaceTemplate = exports.formatErrorForLog = exports.formatError = exports.getErrorMessage = void 0;
4
4
  var errors_js_1 = require("./errors.js");
5
5
  Object.defineProperty(exports, "getErrorMessage", { enumerable: true, get: function () { return errors_js_1.getErrorMessage; } });
6
6
  Object.defineProperty(exports, "formatError", { enumerable: true, get: function () { return errors_js_1.formatError; } });
@@ -28,8 +28,9 @@ Object.defineProperty(exports, "healYaml", { enumerable: true, get: function ()
28
28
  var linker_js_1 = require("./linker.js");
29
29
  Object.defineProperty(exports, "Linker", { enumerable: true, get: function () { return linker_js_1.Linker; } });
30
30
  Object.defineProperty(exports, "createLinker", { enumerable: true, get: function () { return linker_js_1.createLinker; } });
31
- var escapeFence_js_1 = require("./escapeFence.js");
32
- Object.defineProperty(exports, "escapeFence", { enumerable: true, get: function () { return escapeFence_js_1.escapeFence; } });
31
+ Object.defineProperty(exports, "linkText", { enumerable: true, get: function () { return linker_js_1.linkText; } });
32
+ var codeBlock_js_1 = require("./codeBlock.js");
33
+ Object.defineProperty(exports, "codeBlock", { enumerable: true, get: function () { return codeBlock_js_1.codeBlock; } });
33
34
  var stripAnsi_js_1 = require("./stripAnsi.js");
34
35
  Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return stripAnsi_js_1.stripAnsi; } });
35
36
  var questionDetection_js_1 = require("./questionDetection.js");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA8E;AAArE,4GAAA,eAAe,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AACxD,6CAAqE;AAA5D,8GAAA,eAAe,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAC7C,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,2CAAuC;AAA9B,qGAAA,OAAO,OAAA;AAChB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,uDAAuE;AAA9D,iHAAA,aAAa,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAE1C,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,yCAQqB;AAPnB,mGAAA,MAAM,OAAA;AACN,yGAAA,YAAY,OAAA;AAOd,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA8E;AAArE,4GAAA,eAAe,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AACxD,6CAAqE;AAA5D,8GAAA,eAAe,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAC7C,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,2CAAuC;AAA9B,qGAAA,OAAO,OAAA;AAChB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,uDAAuE;AAA9D,iHAAA,aAAa,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAE1C,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,yCAWqB;AAVnB,mGAAA,MAAM,OAAA;AACN,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AASV,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA"}
package/dist/linker.d.ts CHANGED
@@ -1,90 +1,76 @@
1
- export type LinkerPlatform = "slack" | "discord" | "markdown" | "plaintext";
2
- export interface LinkerApplyOptions {
1
+ export type LinkStyle = "slack" | "discord" | "markdown" | "plain";
2
+ export interface LinkOptions {
3
3
  /**
4
- * Target output format.
5
- * Alias: `platform`.
4
+ * Target output style.
6
5
  * Default: "markdown"
7
6
  */
8
- format?: LinkerPlatform;
9
- platform?: LinkerPlatform;
7
+ for?: LinkStyle;
10
8
  /**
11
9
  * When true (default), skips linkification inside inline/fenced code spans.
12
10
  */
13
- skipCode?: boolean;
11
+ ignoreCode?: boolean;
14
12
  /**
15
13
  * When true (default), skips linkification inside existing links.
16
14
  */
17
- skipExistingLinks?: boolean;
15
+ ignoreExistingLinks?: boolean;
18
16
  }
19
- export interface LinkMatchContext {
20
- /** Full regex match text. */
21
- match: string;
17
+ export interface LinkContext {
18
+ /** Full matched text. */
19
+ text: string;
22
20
  /** Positional capture groups. */
23
21
  groups: string[];
24
22
  /** Rule name assigned at registration time. */
25
- ruleName: string;
23
+ name: string;
26
24
  /** Match start index in the original input. */
27
25
  index: number;
28
26
  /** Original input string. */
29
27
  input: string;
30
28
  }
31
- export type LinkHrefBuilder = (context: LinkMatchContext) => string;
29
+ export type LinkTarget = (context: LinkContext) => string;
32
30
  export interface LinkRule {
33
31
  /** Optional stable name for diagnostics and conflict visibility. */
34
32
  name?: string;
35
33
  /** Match pattern. Global matching is enforced automatically. */
36
- pattern: RegExp;
34
+ match: RegExp;
37
35
  /**
38
- * URL template string (supports $0/$& for full match, $1..$N for groups).
39
- * Convenience alias for `toHref`.
36
+ * Either a URL template string or a callback that builds a URL from match
37
+ * context. Template strings support `$0`/`$&` for the full match and
38
+ * `$1..$N` for groups.
40
39
  */
41
- href?: string;
42
- /**
43
- * Either a URL template string or a callback that builds an href from match context.
44
- * If both `href` and `toHref` are provided, `toHref` wins.
45
- */
46
- toHref?: string | LinkHrefBuilder;
40
+ to: string | LinkTarget;
47
41
  /**
48
42
  * Higher priority wins for overlapping matches that start at the same index.
49
43
  * Default: 0
50
44
  */
51
45
  priority?: number;
52
46
  }
47
+ export interface LinkerConfig {
48
+ /** Linear workspace slug, used for issue references like `ENG-533`. */
49
+ linear?: string;
50
+ /** GitHub repository for PR references like `PR#42`. */
51
+ githubPrs?: string;
52
+ /** Additional custom rules appended after built-in presets. */
53
+ rules?: readonly LinkRule[];
54
+ }
55
+ export interface LinkTextOptions extends LinkerConfig, LinkOptions {
56
+ }
53
57
  /**
54
- * Stateful linker utility that applies configured rules to text.
58
+ * Compiled linker utility.
55
59
  *
56
- * Behavior highlights:
57
- * - idempotent by default (skips existing links)
58
- * - skips code spans by default
59
- * - deterministic overlap resolution (priority, length, then declaration order)
60
+ * Built-in presets cover the repo references used in this workspace.
61
+ * For one-off usage, prefer the top-level `linkText()` helper.
60
62
  */
61
63
  export declare class Linker {
62
64
  private readonly rules;
63
- constructor(initialRules?: LinkRule[]);
64
- private addRule;
65
- rule(rule: LinkRule): this;
66
- rule(name: string, rule: Omit<LinkRule, "name">): this;
67
- custom(pattern: RegExp, toHref: string | LinkHrefBuilder, options?: {
68
- name?: string;
69
- priority?: number;
70
- }): this;
71
- linear(workspace: string, options?: {
72
- name?: string;
73
- priority?: number;
74
- }): this;
75
- githubPr(repository: string, options?: {
76
- name?: string;
77
- priority?: number;
78
- }): this;
79
- apply(input: string, options?: LinkerApplyOptions): string;
80
- linkText(input: string, options?: LinkerApplyOptions): string;
65
+ constructor(config?: LinkerConfig);
66
+ link(input: string, options?: LinkOptions): string;
81
67
  }
82
68
  /**
83
- * Create a linker with optional initial rules.
84
- *
85
- * - `href` accepts template substitutions (`$0`/`$&`, `$1..$N`)
86
- * - `toHref` callback, when provided, takes precedence over `href`
87
- * - omitted `priority` defaults to `0`
69
+ * Create a reusable text linker with compiled matching rules.
70
+ */
71
+ export declare function createLinker(config?: LinkerConfig): Linker;
72
+ /**
73
+ * Link known ticket/PR references in text using one-shot linker options.
88
74
  */
89
- export declare function createLinker(initialRules?: LinkRule[]): Linker;
75
+ export declare function linkText(input: string, options?: LinkTextOptions): string;
90
76
  //# sourceMappingURL=linker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../src/linker.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAE5E,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC;AAEpE,MAAM,WAAW,QAAQ;IACvB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA2JD;;;;;;;GAOG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBAEhC,YAAY,GAAE,QAAQ,EAAO;IAMzC,OAAO,CAAC,OAAO;IAKf,IAAI,CAAC,IAAI,EAAE,QAAQ,GAA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AAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC;AAE1D,MAAM,WAAW,QAAQ;IACvB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY,EAAE,WAAW;CAAG;AAmKrE;;;;;GAKG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;gBAE3B,MAAM,GAAE,YAAiB;IAIrC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM;CAkFvD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,YAAiB,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,CAgB7E"}
package/dist/linker.js CHANGED
@@ -2,19 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Linker = void 0;
4
4
  exports.createLinker = createLinker;
5
+ exports.linkText = linkText;
5
6
  function ensureGlobal(pattern) {
6
7
  if (pattern.flags.includes("g")) {
7
8
  return new RegExp(pattern.source, pattern.flags);
8
9
  }
9
10
  return new RegExp(pattern.source, `${pattern.flags}g`);
10
11
  }
11
- function templateToHref(template) {
12
- return ({ match, groups }) => template.replace(/\$\$|\$(\d+|&|0)/g, (token, capture) => {
12
+ function templateToTarget(template) {
13
+ return ({ text, groups }) => template.replace(/\$\$|\$(\d+|&|0)/g, (token, capture) => {
13
14
  if (token === "$$") {
14
15
  return "$";
15
16
  }
16
17
  if (capture === "&" || capture === "0") {
17
- return match;
18
+ return text;
18
19
  }
19
20
  const index = Number(capture);
20
21
  if (!Number.isInteger(index) || index < 0) {
@@ -24,16 +25,11 @@ function templateToHref(template) {
24
25
  });
25
26
  }
26
27
  function compileRule(rule, index) {
27
- const source = rule.toHref ?? rule.href;
28
- if (source === undefined) {
29
- throw new Error(`Invalid linker rule "${rule.name ?? `rule-${String(index + 1)}`}": missing href/toHref`);
30
- }
31
- const toHref = typeof source === "string" ? templateToHref(source) : source;
32
28
  return {
33
29
  name: rule.name ?? `rule-${String(index + 1)}`,
34
- pattern: ensureGlobal(rule.pattern),
30
+ match: ensureGlobal(rule.match),
35
31
  priority: rule.priority ?? 0,
36
- toHref,
32
+ to: typeof rule.to === "string" ? templateToTarget(rule.to) : rule.to,
37
33
  };
38
34
  }
39
35
  function pushSpans(source, pattern, spans) {
@@ -71,17 +67,13 @@ function normalizeSpans(spans) {
71
67
  }
72
68
  function getProtectedSpans(input, options) {
73
69
  const spans = [];
74
- if (options.skipCode) {
75
- // Fenced code blocks first, then inline spans.
70
+ if (options.ignoreCode) {
76
71
  pushSpans(input, /```[\s\S]*?```/g, spans);
77
72
  pushSpans(input, /`[^`\n]+`/g, spans);
78
73
  }
79
- if (options.skipExistingLinks) {
80
- // Slack and angle-bracket links/mentions.
74
+ if (options.ignoreExistingLinks) {
81
75
  pushSpans(input, /<[^>\n]+>/g, spans);
82
- // Markdown links.
83
76
  pushSpans(input, /\[[^\]]+\]\([^)]+\)/g, spans);
84
- // Plain URLs.
85
77
  pushSpans(input, /https?:\/\/[^\s<>()]+/g, spans);
86
78
  }
87
79
  return normalizeSpans(spans);
@@ -98,80 +90,64 @@ function overlapsProtected(spans, start, end) {
98
90
  }
99
91
  return false;
100
92
  }
101
- function formatLink(href, text, platform) {
102
- switch (platform) {
93
+ function formatLink(href, text, style) {
94
+ switch (style) {
103
95
  case "slack":
104
96
  return `<${href}|${text}>`;
105
97
  case "discord":
106
98
  case "markdown":
107
99
  return `[${text}](${href})`;
108
- case "plaintext":
100
+ case "plain":
109
101
  return href;
110
102
  default:
111
103
  return text;
112
104
  }
113
105
  }
114
- function resolvePlatform(options) {
115
- return options.format ?? options.platform ?? "markdown";
106
+ function buildRules(config) {
107
+ const rules = [];
108
+ const linearWorkspace = config.linear;
109
+ const githubRepo = config.githubPrs;
110
+ if (linearWorkspace !== undefined && linearWorkspace !== "") {
111
+ rules.push({
112
+ name: "linear",
113
+ match: /\b([A-Z]{2,6}-\d+)\b/g,
114
+ to: ({ text }) => `https://linear.app/${linearWorkspace}/issue/${text}`,
115
+ });
116
+ }
117
+ if (githubRepo !== undefined && githubRepo !== "") {
118
+ rules.push({
119
+ name: "github-prs",
120
+ match: /\bPR#(\d+)\b/g,
121
+ to: ({ groups }) => `https://github.com/${githubRepo}/pull/${groups[0] ?? ""}`,
122
+ });
123
+ }
124
+ rules.push(...(config.rules ?? []));
125
+ return rules.map(compileRule);
116
126
  }
117
127
  /**
118
- * Stateful linker utility that applies configured rules to text.
128
+ * Compiled linker utility.
119
129
  *
120
- * Behavior highlights:
121
- * - idempotent by default (skips existing links)
122
- * - skips code spans by default
123
- * - deterministic overlap resolution (priority, length, then declaration order)
130
+ * Built-in presets cover the repo references used in this workspace.
131
+ * For one-off usage, prefer the top-level `linkText()` helper.
124
132
  */
125
133
  class Linker {
126
- rules = [];
127
- constructor(initialRules = []) {
128
- for (const rule of initialRules) {
129
- this.addRule(rule);
130
- }
131
- }
132
- addRule(rule) {
133
- this.rules.push(compileRule(rule, this.rules.length));
134
- return this;
135
- }
136
- rule(ruleOrName, maybeRule) {
137
- if (typeof ruleOrName === "string") {
138
- if (maybeRule === undefined) {
139
- throw new Error(`Missing rule config for "${ruleOrName}"`);
140
- }
141
- return this.addRule({ ...maybeRule, name: ruleOrName });
142
- }
143
- return this.addRule(ruleOrName);
134
+ rules;
135
+ constructor(config = {}) {
136
+ this.rules = buildRules(config);
144
137
  }
145
- custom(pattern, toHref, options = {}) {
146
- return this.addRule({
147
- name: options.name,
148
- pattern,
149
- toHref,
150
- priority: options.priority,
151
- });
152
- }
153
- linear(workspace, options = {}) {
154
- return this.custom(/\b([A-Z]{2,6}-\d+)\b/g, ({ match }) => `https://linear.app/${workspace}/issue/${match}`, { name: options.name ?? "linear", priority: options.priority });
155
- }
156
- githubPr(repository, options = {}) {
157
- return this.custom(/\bPR#(\d+)\b/g, ({ groups }) => `https://github.com/${repository}/pull/${groups[0] ?? ""}`, { name: options.name ?? "github-pr", priority: options.priority });
158
- }
159
- apply(input, options = {}) {
160
- return this.linkText(input, options);
161
- }
162
- linkText(input, options = {}) {
138
+ link(input, options = {}) {
163
139
  if (this.rules.length === 0 || input === "") {
164
140
  return input;
165
141
  }
166
- const platform = resolvePlatform(options);
142
+ const style = options.for ?? "markdown";
167
143
  const protectedSpans = getProtectedSpans(input, {
168
- skipCode: options.skipCode ?? true,
169
- skipExistingLinks: options.skipExistingLinks ?? true,
144
+ ignoreCode: options.ignoreCode ?? true,
145
+ ignoreExistingLinks: options.ignoreExistingLinks ?? true,
170
146
  });
171
147
  const candidates = [];
172
148
  for (let ruleOrder = 0; ruleOrder < this.rules.length; ruleOrder++) {
173
149
  const rule = this.rules[ruleOrder];
174
- const matcher = rule.pattern;
150
+ const matcher = rule.match;
175
151
  matcher.lastIndex = 0;
176
152
  let match = matcher.exec(input);
177
153
  while (match !== null) {
@@ -190,7 +166,7 @@ class Linker {
190
166
  text: matchedText,
191
167
  groups: match.slice(1),
192
168
  ruleOrder,
193
- ruleName: rule.name,
169
+ name: rule.name,
194
170
  priority: rule.priority,
195
171
  });
196
172
  }
@@ -218,19 +194,15 @@ class Linker {
218
194
  for (const candidate of selected) {
219
195
  output += input.slice(inputCursor, candidate.start);
220
196
  const rule = this.rules[candidate.ruleOrder];
221
- const href = rule.toHref({
222
- match: candidate.text,
197
+ const href = rule.to({
198
+ text: candidate.text,
223
199
  groups: candidate.groups,
224
- ruleName: candidate.ruleName,
200
+ name: candidate.name,
225
201
  index: candidate.start,
226
202
  input,
227
203
  });
228
- if (href === "") {
229
- output += candidate.text;
230
- }
231
- else {
232
- output += formatLink(href, candidate.text, platform);
233
- }
204
+ output +=
205
+ href === "" ? candidate.text : formatLink(href, candidate.text, style);
234
206
  inputCursor = candidate.end;
235
207
  }
236
208
  output += input.slice(inputCursor);
@@ -239,13 +211,21 @@ class Linker {
239
211
  }
240
212
  exports.Linker = Linker;
241
213
  /**
242
- * Create a linker with optional initial rules.
243
- *
244
- * - `href` accepts template substitutions (`$0`/`$&`, `$1..$N`)
245
- * - `toHref` callback, when provided, takes precedence over `href`
246
- * - omitted `priority` defaults to `0`
214
+ * Create a reusable text linker with compiled matching rules.
247
215
  */
248
- function createLinker(initialRules = []) {
249
- return new Linker(initialRules);
216
+ function createLinker(config = {}) {
217
+ return new Linker(config);
218
+ }
219
+ /**
220
+ * Link known ticket/PR references in text using one-shot linker options.
221
+ */
222
+ function linkText(input, options = {}) {
223
+ const { linear, githubPrs, rules, for: style, ignoreCode, ignoreExistingLinks, } = options;
224
+ const linker = createLinker({ linear, githubPrs, rules });
225
+ return linker.link(input, {
226
+ for: style,
227
+ ignoreCode,
228
+ ignoreExistingLinks,
229
+ });
250
230
  }
251
231
  //# sourceMappingURL=linker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"linker.js","sourceRoot":"","sources":["../src/linker.ts"],"names":[],"mappings":";;;AA6XA,oCAEC;AAhTD,SAAS,YAAY,CAA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AmB;KACpB,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardlydifficult/text",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -1,9 +0,0 @@
1
- /**
2
- * Escapes markdown code fences by wrapping content with more backticks than it contains.
3
- * If content has ```, wraps with ````. If content has ````, wraps with `````, etc.
4
- */
5
- export declare function escapeFence(content: string): {
6
- fence: string;
7
- content: string;
8
- };
9
- //# sourceMappingURL=escapeFence.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escapeFence.d.ts","sourceRoot":"","sources":["../src/escapeFence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAeA"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeFence = escapeFence;
4
- /**
5
- * Escapes markdown code fences by wrapping content with more backticks than it contains.
6
- * If content has ```, wraps with ````. If content has ````, wraps with `````, etc.
7
- */
8
- function escapeFence(content) {
9
- let maxBackticks = 3; // Start with triple backticks (standard markdown fence)
10
- // Find the longest sequence of consecutive backticks in the content
11
- const backtickMatches = content.match(/`+/g);
12
- if (backtickMatches) {
13
- for (const match of backtickMatches) {
14
- if (match.length >= maxBackticks) {
15
- maxBackticks = match.length + 1;
16
- }
17
- }
18
- }
19
- const fence = "`".repeat(maxBackticks);
20
- return { fence, content };
21
- }
22
- //# sourceMappingURL=escapeFence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escapeFence.js","sourceRoot":"","sources":["../src/escapeFence.ts"],"names":[],"mappings":";;AAIA,kCAkBC;AAtBD;;;GAGG;AACH,SAAgB,WAAW,CAAC,OAAe;IAIzC,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC,wDAAwD;IAE9E,oEAAoE;IACpE,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,eAAe,EAAE,CAAC;QACpB,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;gBACjC,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}