@osdlc/markdown-link 0.5.0 → 0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @osdlc/markdown-link
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 743c7bf: Export `percentDecode`, the decoding `mdLinkTarget` already uses, as the Rust crate exports `percent_decode`. Each valid `%XX` decodes on its own, a `%` that is not valid hex stays as written, and a result that is not UTF-8 leaves the whole string as written.
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -73,6 +73,8 @@ bodyLinksSpanned('See [[Note#h|alias]] and `[[not a link]]`')
73
73
  alias; `targetRange` is where the target sits in it.
74
74
  - Markdown link URLs: `isVaultLinkUrl` says whether a URL is a note or an
75
75
  attachment; `mdLinkTarget` percent-decodes it and drops `.md`.
76
+ `percentDecode` is that decoding alone: `percentDecode('My%20Note')` is
77
+ `'My Note'`, and a `%` that is not valid hex or UTF-8 stays as written.
76
78
  - A body: `bodyLinksSpanned` finds every wikilink, embed and relative markdown
77
79
  link, with its span; `bodyLinks` is the same scan without spans.
78
80
  - Display text: `displayText` replaces each wikilink and embed with what a
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@
8
8
  * The Rust crate reports byte offsets.
9
9
  */
10
10
  export { type CodeRules, stripCode, stripCodeWith } from './code.ts';
11
- export { ATTACHMENT_EXTENSIONS, type TextRange, type WikiLink, isVaultLinkUrl, mdLinkTarget, parseInner, targetRange, } from './parse.ts';
11
+ export { ATTACHMENT_EXTENSIONS, type TextRange, type WikiLink, isVaultLinkUrl, mdLinkTarget, parseInner, percentDecode, targetRange, } from './parse.ts';
12
12
  export { type TypedRef, displayText, parseTypedRef } from './display.ts';
13
13
  export { type BodyLink, type BodyLinkKind, type LinkKind, type RawLink, bodyLinks, bodyLinksSpanned, } from './body-links.ts';
package/dist/index.js CHANGED
@@ -8,6 +8,6 @@
8
8
  * The Rust crate reports byte offsets.
9
9
  */
10
10
  export { stripCode, stripCodeWith } from "./code.js";
11
- export { ATTACHMENT_EXTENSIONS, isVaultLinkUrl, mdLinkTarget, parseInner, targetRange, } from "./parse.js";
11
+ export { ATTACHMENT_EXTENSIONS, isVaultLinkUrl, mdLinkTarget, parseInner, percentDecode, targetRange, } from "./parse.js";
12
12
  export { displayText, parseTypedRef } from "./display.js";
13
13
  export { bodyLinks, bodyLinksSpanned, } from "./body-links.js";
package/dist/parse.d.ts CHANGED
@@ -66,3 +66,10 @@ export declare function isVaultLinkUrl(url: string): boolean;
66
66
  * off.
67
67
  */
68
68
  export declare function mdLinkTarget(url: string): string;
69
+ /**
70
+ * Percent-decode a string over its UTF-8 bytes, as the Rust crate's
71
+ * `percent_decode` does. Each valid `%XX` decodes on its own, so a stray `%`
72
+ * (`100%`) stays as written. Bytes that do not decode to UTF-8 leave the whole
73
+ * string as written, rather than becoming U+FFFD.
74
+ */
75
+ export declare function percentDecode(s: string): string;
package/dist/parse.js CHANGED
@@ -165,10 +165,12 @@ function stripMdExt(s) {
165
165
  }
166
166
  const utf8Decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
167
167
  /**
168
- * Percent-decode a URL over its UTF-8 bytes. Bytes that do not decode to UTF-8
169
- * leave the URL as written, rather than becoming U+FFFD.
168
+ * Percent-decode a string over its UTF-8 bytes, as the Rust crate's
169
+ * `percent_decode` does. Each valid `%XX` decodes on its own, so a stray `%`
170
+ * (`100%`) stays as written. Bytes that do not decode to UTF-8 leave the whole
171
+ * string as written, rather than becoming U+FFFD.
170
172
  */
171
- function percentDecode(s) {
173
+ export function percentDecode(s) {
172
174
  if (!s.includes('%'))
173
175
  return s;
174
176
  const bytes = new TextEncoder().encode(s);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdlc/markdown-link",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Wikilink parsing that follows documented link-resolution conventions: every [[link]], ![[embed]] and relative markdown link in a note body, with spans, and the code lexer that keeps links in code out. The TypeScript twin of the parsing half of the Rust markdown-link crate, held to it by a shared case file. No dependencies.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "sksizer",