@riebeckite/plugin-code-annotations 0.0.32 → 0.0.34

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
@@ -44,6 +44,16 @@ An empty, malformed, or missing target language leaves the fence as an ordinary
44
44
  `diff` code block. A target language that the syntax highlighter does not know
45
45
  falls back to its normal unhighlighted rendering and does not fail the build.
46
46
 
47
+ ## Live example
48
+
49
+ A `diff` fence with a target language renders additions and removals with the normal code block UI.
50
+
51
+ ~~~diff js
52
+ const kept = true;
53
+ + const added = "new line";
54
+ - const removed = false;
55
+ ~~~
56
+
47
57
  ## Integration
48
58
 
49
59
  The plugin transforms Markdown in its remark phase, records each line marker in
@@ -54,7 +64,7 @@ not import it, so the two packages remain independently configurable.
54
64
 
55
65
  ## Exports
56
66
 
57
- - `codeAnnotations()` / `codeAnnotationsPlugin()` — plugin factory
67
+ - `codeAnnotations()` / `codeAnnotations()` — plugin factory
58
68
  - `remarkCodeAnnotations()` — Markdown transform
59
69
  - `rehypeCodeAnnotations()` — HTML transform
60
70
  - `collectCodeDiff(code)` — separates diff markers from source text
package/README_ja.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- Generated from docs/docs/plugins/code-annotations.ja.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
4
 
5
- 差分のコードブロックを、対象言語のシンタックスハイライトとRiebeckiteのコードブロックUIで表示します。
5
+ コードの差分を、対象言語のシンタックスハイライトと Riebeckite のコードブロック UI で表示するプラグインです。
6
6
 
7
7
  [English](./README.md)
8
8
 
@@ -33,23 +33,33 @@ const unchanged = true;
33
33
  ```
34
34
  ````
35
35
 
36
- `+` と `-` はコード本体とは別に描画されます。そのためJavaScript、TypeScript、Python、JSON
36
+ `+` と `-` はコード本体とは別に描画されます。そのため JavaScript、TypeScript、Python、JSON
37
37
  などのシンタックスハイライトを妨げません。コピー操作では、表示された差分と同じくマーカーも含めてコピーします。
38
38
 
39
39
  対象言語が空、形式が不正、または指定されていないフェンスは、通常の `diff` コードブロックとして扱います。
40
40
  シンタックスハイライトが対応していない言語を指定しても、ハイライトなしで表示され、ビルドは失敗しません。
41
41
 
42
+ ## 実行例
43
+
44
+ 対象言語を指定した `diff` フェンスは、通常のコードブロック UI のまま追加行と削除行を表示します。
45
+
46
+ ~~~diff js
47
+ const kept = true;
48
+ + const added = "new line";
49
+ - const removed = false;
50
+ ~~~
51
+
42
52
  ## 連携
43
53
 
44
- このプラグインはremark段階で差分マーカーをコード本体から分離し、フェンスメタ情報に記録します。rehype段階では、
45
- マーカーと既存の `rr-code__line--add` / `rr-code__line--remove` クラスを戻します。行ラッパーやコードブロックUIは
46
- `code-enhance` が提供します。両パッケージはimportで依存していないため、個別に設定できます。
54
+ このプラグインは remark 段階で差分マーカーをコード本体から分離し、フェンスのメタ情報に記録します。rehype 段階では、
55
+ マーカーと既存の `rr-code__line--add` / `rr-code__line--remove` クラスを戻します。行ラッパーやコードブロック UI は
56
+ `code-enhance` が提供します。両パッケージは相互に import していないため、個別に設定できます。
47
57
 
48
- ## 公開API
58
+ ## 公開 API
49
59
 
50
- - `codeAnnotations()` / `codeAnnotationsPlugin()`:プラグインファクトリ
51
- - `remarkCodeAnnotations()`:Markdown変換
52
- - `rehypeCodeAnnotations()`:HTML変換
60
+ - `codeAnnotations()` / `codeAnnotations()`:プラグインファクトリ
61
+ - `remarkCodeAnnotations()`:Markdown 変換
62
+ - `rehypeCodeAnnotations()`:HTML 変換
53
63
  - `collectCodeDiff(code)`:差分マーカーとコード本体を分離
54
64
  - `serializeCodeDiff(plan)` / `deserializeCodeDiff(value)`:行情報の変換
55
65
  - `encodeCodeDiffMeta(plan)` / `extractCodeDiffMeta(meta)`:メタ情報の変換
package/dist/index.d.ts CHANGED
@@ -3,4 +3,3 @@ export { appendCodeDiffMeta, collectCodeDiff, deserializeCodeDiff, encodeCodeDif
3
3
  export { rehypeCodeAnnotations } from "./src/rehype.js";
4
4
  export { remarkCodeAnnotations } from "./src/remark.js";
5
5
  export declare function codeAnnotations(): import("@riebeckite/core").RiebeckitePlugin<unknown>;
6
- export declare const codeAnnotationsPlugin: typeof codeAnnotations;
package/dist/index.js CHANGED
@@ -249,11 +249,9 @@ function codeAnnotations() {
249
249
  }
250
250
  });
251
251
  }
252
- var codeAnnotationsPlugin = codeAnnotations;
253
252
  export {
254
253
  appendCodeDiffMeta,
255
254
  codeAnnotations,
256
- codeAnnotationsPlugin,
257
255
  collectCodeDiff,
258
256
  deserializeCodeDiff,
259
257
  encodeCodeDiffMeta,
@@ -1,4 +1,3 @@
1
- export declare const DIFF_META_PREFIX = "rb-diff=";
2
1
  export type DiffMarker = "+" | "-" | null;
3
2
  export type CodeDiffPlan = {
4
3
  markers: DiffMarker[];
@@ -5,7 +5,5 @@ export declare function element(tagName: string, properties?: Record<string, unk
5
5
  export declare function visitElementTree(node: HastNode, visitor: (node: ElementNode, ancestors: ElementNode[]) => void, ancestors?: ElementNode[]): void;
6
6
  export declare function getStringProperty(node: ElementNode, key: string): string | null;
7
7
  export declare function getBooleanProperty(node: ElementNode, key: string): boolean;
8
- export declare function hasProperty(node: ElementNode, key: string): boolean;
9
8
  export declare function mergeClassName(current: unknown, next: string): string;
10
9
  export declare function getDataMeta(node: ElementNode | null | undefined): string | null;
11
- export declare function getTextContent(node: HastNode): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-code-annotations",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,11 +14,11 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@riebeckite/core": "0.0.32"
17
+ "@riebeckite/core": "0.0.34"
18
18
  },
19
19
  "devDependencies": {
20
- "tsx": "^4.22.4",
21
- "@riebeckite/test": "0.0.32"
20
+ "@riebeckite/test": "0.0.34",
21
+ "tsx": "^4.22.4"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"