@riebeckite/plugin-citations 0.0.31 → 0.0.33
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 +14 -0
- package/README_ja.md +29 -15
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/src/page.d.ts +2 -1
- package/dist/src/paths.d.ts +0 -2
- package/dist/src/render.d.ts +2 -1
- package/dist/src/state.d.ts +2 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -34,6 +34,20 @@ Riebeckite parses `:name` as a directive before this plugin runs. When that spli
|
|
|
34
34
|
|
|
35
35
|
Not transformed: inline code, fenced code blocks, HTML, frontmatter, normal Markdown links (at any nesting depth), and Obsidian WikiLinks.
|
|
36
36
|
|
|
37
|
+
## Live example
|
|
38
|
+
|
|
39
|
+
The citations below use the site bibliography.
|
|
40
|
+
|
|
41
|
+
Riebeckite builds on Markdown[@gruber2004] and ships its own plugin model.[@riebeckite2026]
|
|
42
|
+
|
|
43
|
+
Several sources can be cited together.[@riebeckite2026; @gruber2004]
|
|
44
|
+
|
|
45
|
+
An author-integrated citation: @gruber2004 argues that readable source matters.
|
|
46
|
+
|
|
47
|
+
A suppressed-author citation: [-@riebeckite2026] keeps the number.
|
|
48
|
+
|
|
49
|
+
A locator and prefix: [see @riebeckite2026, p. 42].
|
|
50
|
+
|
|
37
51
|
## Bibliography files
|
|
38
52
|
|
|
39
53
|
- `citations({ bibliography })` paths are relative to the content root.
|
package/README_ja.md
CHANGED
|
@@ -18,37 +18,51 @@ export default {
|
|
|
18
18
|
|
|
19
19
|
## 対応する引用の記法
|
|
20
20
|
|
|
21
|
-
Pandoc
|
|
21
|
+
Pandoc を参考にした、安定した記法のサブセットを扱います。
|
|
22
22
|
|
|
23
23
|
- `[@smith2024]`
|
|
24
24
|
- `[@smith2024; @doe2025]`:複数のキーは `;` で区切る
|
|
25
25
|
- `@smith2024 argues that ...`
|
|
26
26
|
- `[-@smith2024]`:著者名を出さない形の入力
|
|
27
|
-
- `[@smith2024, p. 42]` と `[see @doe2025]
|
|
27
|
+
- `[@smith2024, p. 42]` と `[see @doe2025]`:接頭辞と接尾辞を保持し、`[1, p. 42]` と `[see 2]` として表示する
|
|
28
28
|
|
|
29
29
|
同じ文献を何度も引用した場合は、最初に割り当てた番号を再利用します。番号形式の表示では `[-@smith2024]` と `[@smith2024]` のラベルは同じになります。
|
|
30
30
|
|
|
31
31
|
本文中の `@key` は、テキストの先頭、空白、`(` のいずれかの直後に書きます。`本文@smith2024` のように `@key` の左が文字でつながっている形は認識されないため、`[@smith2024]` を使ってください。
|
|
32
32
|
|
|
33
|
-
Riebeckite はこのプラグインより先に `:name`
|
|
33
|
+
Riebeckite はこのプラグインより先に `:name` をディレクティブとして解釈します。ディレクティブ化で引用キーが分断された場合はプラグインが組み直すため、`[@colon:2024]` と `@colon:2024 argues` の両方が動きます。キーに使えるのは英字、数字、`-`、`_`、`:`、`.` です。
|
|
34
34
|
|
|
35
|
-
変換しない対象:
|
|
35
|
+
変換しない対象: インラインコード、フェンス付きコードブロック、HTML、frontmatter、任意の階層にある通常の Markdown リンク、Obsidian の Wikilink。
|
|
36
|
+
|
|
37
|
+
## 実行例
|
|
38
|
+
|
|
39
|
+
以下の引用はサイトの文献ファイルを使っています。
|
|
40
|
+
|
|
41
|
+
Riebeckite は Markdown を基盤にしています[@gruber2004]。また独自のプラグインモデルを持ちます。[@riebeckite2026]
|
|
42
|
+
|
|
43
|
+
複数の文献をまとめて引用できます。[@riebeckite2026; @gruber2004]
|
|
44
|
+
|
|
45
|
+
著者名を文中に置く引用: @gruber2004 は、読みやすいソースの重要性を説いています。
|
|
46
|
+
|
|
47
|
+
著者名を省略する引用: [-@riebeckite2026] は番号だけを表示します。
|
|
48
|
+
|
|
49
|
+
位置情報と接頭辞: [see @riebeckite2026, p. 42]。
|
|
36
50
|
|
|
37
51
|
## 文献ファイルの読み込み
|
|
38
52
|
|
|
39
53
|
- `citations({ bibliography })` のパスはコンテンツルートからの相対パスです。
|
|
40
|
-
- frontmatter の `bibliography` は、まずページからの相対パス、次にコンテンツルートからの相対パスとして解決します。`/` と `\` の両区切りを受け付け、`../`
|
|
54
|
+
- frontmatter の `bibliography` は、まずページからの相対パス、次にコンテンツルートからの相対パスとして解決します。`/` と `\` の両区切りを受け付け、`../` は文字列内で正規化します。候補はいずれもコンテンツソースを通るため、設定されたコンテンツルートの外は読み込めません。
|
|
41
55
|
- 文献ファイルはビルド時に読み込むだけで、出力にはコピーされず、絶対パスも生成物に現れません。
|
|
42
56
|
|
|
43
57
|
## 対応する BibTeX の範囲
|
|
44
58
|
|
|
45
59
|
重点的に扱う文献種別は `article`、`book`、`inproceedings`、`misc` です。その他の種別も汎用フィールドとして読み込んで表示し、`citation-unsupported-entry-type` として報告します。
|
|
46
60
|
|
|
47
|
-
`@comment`、`@preamble`、`@string` は受け付けて読み飛ばします。壊れたエントリは `citation-malformed-bibliography` を出し、次の `@` から再開するため、1
|
|
61
|
+
`@comment`、`@preamble`、`@string` は受け付けて読み飛ばします。壊れたエントリは `citation-malformed-bibliography` を出し、次の `@` から再開するため、1 件の不正でファイルの残りが消えることはありません。
|
|
48
62
|
|
|
49
63
|
対応する構文: 複数行フィールド、引用符と波括弧の値、ネストした波括弧、値の中のカンマ、エスケープ文字、末尾カンマ、空白、CRLF。
|
|
50
64
|
|
|
51
|
-
|
|
65
|
+
次の構文は黙って無視せず、`citation-unsupported-bibliography-syntax` として報告します。
|
|
52
66
|
|
|
53
67
|
- `@string` のマクロ参照は展開せずそのまま文字列として表示する
|
|
54
68
|
- `#` による文字列連結は先頭の部分しか保持しない
|
|
@@ -71,18 +85,18 @@ citations({ bibliography: "references.bib", referencesHeading: "参考文献" })
|
|
|
71
85
|
citations({ bibliography: "references.bib", pagePath: "/bibliography" })
|
|
72
86
|
```
|
|
73
87
|
|
|
74
|
-
ページタイプ(`citations-bibliography`)は、次の2か所から文献を集めます。
|
|
88
|
+
ページタイプ(`citations-bibliography`)は、次の 2 か所から文献を集めます。
|
|
75
89
|
|
|
76
90
|
- プラグインの `bibliography` オプション(コンテンツルートからの相対パス)
|
|
77
91
|
- 公開(discoverable)ページの frontmatter `bibliography`
|
|
78
92
|
|
|
79
|
-
frontmatter の `bibliography` を取り込むのは `manifest.discoverableEntries`
|
|
93
|
+
frontmatter の `bibliography` を取り込むのは `manifest.discoverableEntries` だけです。下書き、unlisted、公開予定など、公開対象でないページは無視するため、それらの文献がページへ漏れることはありません。
|
|
80
94
|
|
|
81
|
-
各ファイルの文献は決定的な順序で統合します。内容まで同じ重複は黙って1件にまとめ、同じキーで内容が異なる場合は先に見つかった定義を採用し、`citation-duplicate-key` として報告します。ファイルが見つからない場合は `citation-missing-bibliography`、解析できない場合は `citation-malformed-bibliography` を報告します。文献が1件も集まらないときはページを生成しません。同じパスを Markdown ページやリダイレクトが既に持っている場合は Markdown を優先し、`citations-page-conflict` を報告してページを生成しません。
|
|
95
|
+
各ファイルの文献は決定的な順序で統合します。内容まで同じ重複は黙って 1 件にまとめ、同じキーで内容が異なる場合は先に見つかった定義を採用し、`citation-duplicate-key` として報告します。ファイルが見つからない場合は `citation-missing-bibliography`、解析できない場合は `citation-malformed-bibliography` を報告します。文献が 1 件も集まらないときはページを生成しません。同じパスを Markdown ページやリダイレクトが既に持っている場合は Markdown を優先し、`citations-page-conflict` を報告してページを生成しません。
|
|
82
96
|
|
|
83
|
-
ページ本文には専用の `<main>` と `<h1>`
|
|
97
|
+
ページ本文には専用の `<main>` と `<h1>` を持たせ、文献エントリのテキストはすべてエスケープします。`url` と `doi` は安全な `http(s)` のときだけリンクにします。文献はキー順に並べます。既存の本文中の引用と `References` セクションは変更しません。
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
参考文献ページはグローバルな出力依存(`global`)を宣言します。文献ファイル、frontmatter の `bibliography`、ページの公開状態、`pagePath` の変更で、影響する出力を無効化します。
|
|
86
100
|
|
|
87
101
|
## オプション
|
|
88
102
|
|
|
@@ -92,9 +106,9 @@ frontmatter の `bibliography` を取り込むのは `manifest.discoverableEntri
|
|
|
92
106
|
| `referencesHeading` | `"References"` | 生成する参考文献の見出し |
|
|
93
107
|
| `pagePath` | 未設定 | 参考文献一覧ページのパス。指定しないときは生成しない |
|
|
94
108
|
|
|
95
|
-
##
|
|
109
|
+
## 診断
|
|
96
110
|
|
|
97
|
-
以下を Riebeckite
|
|
111
|
+
以下を Riebeckite の診断として出力します。
|
|
98
112
|
|
|
99
113
|
- `citation-unknown-key`
|
|
100
114
|
- `citation-missing-bibliography`
|
|
@@ -103,7 +117,7 @@ frontmatter の `bibliography` を取り込むのは `manifest.discoverableEntri
|
|
|
103
117
|
- `citation-unsupported-entry-type`
|
|
104
118
|
- `citation-unsupported-bibliography-syntax`
|
|
105
119
|
|
|
106
|
-
引用番号、参考文献の並び、生成される HTML
|
|
120
|
+
引用番号、参考文献の並び、生成される HTML、診断の順序は決定的で、同じ入力からは同じ出力になります。
|
|
107
121
|
|
|
108
122
|
## ライセンス
|
|
109
123
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { parseBibliography } from "./src/bibliography.js";
|
|
|
3
3
|
export { remarkCitations } from "./src/remark.js";
|
|
4
4
|
export type { BibliographyEntry, CitationOccurrence, CitationReference, CitationSyntax, CitationsOptions, ResolvedCitation, } from "./src/types.js";
|
|
5
5
|
export declare function citations(options?: CitationsOptions): import("@riebeckite/core").RiebeckitePlugin<CitationsOptions>;
|
|
6
|
-
export declare const citationsPlugin: typeof citations;
|
package/dist/index.js
CHANGED
|
@@ -783,7 +783,7 @@ function renderCitation(references, bracketed, context) {
|
|
|
783
783
|
});
|
|
784
784
|
return {
|
|
785
785
|
type: "link",
|
|
786
|
-
url:
|
|
786
|
+
url: `#user-content-${referenceId2(references[0]?.key ?? "unknown", context)}`,
|
|
787
787
|
title: null,
|
|
788
788
|
children: [{ type: "text", value: label }]
|
|
789
789
|
};
|
|
@@ -949,7 +949,6 @@ function citations(options = {}) {
|
|
|
949
949
|
addDiagnostics: () => state.diagnostics
|
|
950
950
|
});
|
|
951
951
|
}
|
|
952
|
-
var citationsPlugin = citations;
|
|
953
952
|
function validateCitationsOptions(options) {
|
|
954
953
|
if (!options) return [];
|
|
955
954
|
const issues = [];
|
|
@@ -973,7 +972,6 @@ function validateCitationsOptions(options) {
|
|
|
973
972
|
}
|
|
974
973
|
export {
|
|
975
974
|
citations,
|
|
976
|
-
citationsPlugin,
|
|
977
975
|
parseBibliography,
|
|
978
976
|
remarkCitations
|
|
979
977
|
};
|
package/dist/src/page.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ContentManifest, type ContentSource, type Diagnostic, type PluginPage } from "@riebeckite/core";
|
|
2
2
|
import type { CitationsOptions } from "./types.js";
|
|
3
|
-
|
|
3
|
+
type BibliographyPageSource = {
|
|
4
4
|
readonly manifest: ContentManifest;
|
|
5
5
|
readonly contentSource?: ContentSource;
|
|
6
6
|
readonly diagnostics: Diagnostic[];
|
|
@@ -9,3 +9,4 @@ export declare function listBibliographyPagePaths(source: BibliographyPageSource
|
|
|
9
9
|
export declare function resolveBibliographyPage(context: BibliographyPageSource & {
|
|
10
10
|
readonly pathname: string;
|
|
11
11
|
}, options: CitationsOptions): Promise<PluginPage | null>;
|
|
12
|
+
export {};
|
package/dist/src/paths.d.ts
CHANGED
|
@@ -6,7 +6,5 @@ export declare function pathList(value: unknown): readonly string[];
|
|
|
6
6
|
* escape the configured content root.
|
|
7
7
|
*/
|
|
8
8
|
export declare function pageRelativeCandidates(path: string, sourceSlug: string | undefined): readonly string[];
|
|
9
|
-
export declare function isAbsoluteLikePath(path: string): boolean;
|
|
10
9
|
export declare function normalizeLogicalPath(path: string): string;
|
|
11
10
|
export declare function pushUniqueDiagnostics(target: Diagnostic[], diagnostics: readonly Diagnostic[], slug: string | undefined): void;
|
|
12
|
-
export declare function diagnosticSignature(diagnostic: Diagnostic): string;
|
package/dist/src/render.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BibliographyEntry } from "./types.js";
|
|
2
|
-
|
|
2
|
+
type RenderBibliographyInput = {
|
|
3
3
|
readonly title: string;
|
|
4
4
|
readonly entries: readonly (readonly [string, BibliographyEntry])[];
|
|
5
5
|
};
|
|
6
6
|
export declare function renderBibliographyPage(input: RenderBibliographyInput): string;
|
|
7
|
+
export {};
|
package/dist/src/state.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Diagnostic } from "@riebeckite/core";
|
|
2
2
|
import type { BibliographyCache } from "./types.js";
|
|
3
|
-
|
|
3
|
+
type CitationState = {
|
|
4
4
|
readonly bibliographies: BibliographyCache;
|
|
5
5
|
readonly diagnostics: Diagnostic[];
|
|
6
6
|
};
|
|
7
7
|
export declare function createCitationState(): CitationState;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-citations",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@riebeckite/core": "0.0.33",
|
|
8
9
|
"@types/mdast": "^4.0.4",
|
|
9
|
-
"unist-util-visit": "^5.1.0"
|
|
10
|
-
"@riebeckite/core": "0.0.31"
|
|
10
|
+
"unist-util-visit": "^5.1.0"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|