asciidoc-pubkit 1.3.1 → 1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -1
- data/README.md +27 -3
- data/data/writing/en/criteria.md +33 -0
- data/data/writing/ja/criteria.md +163 -2
- data/docs/image-commands.md +165 -0
- data/docs/installation.md +5 -1
- data/docs/prose-evaluation.md +31 -3
- data/docs/writing.md +63 -0
- data/examples/skills/review-asciidoc-manuscript/SKILL.md +5 -0
- data/lib/asciidoc_pubkit/cli.rb +6 -2
- data/lib/asciidoc_pubkit/document_commands.rb +1 -0
- data/lib/asciidoc_pubkit/image_commands.rb +364 -0
- data/lib/asciidoc_pubkit.rb +2 -1
- metadata +9 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 386d3aa0d4d50c3413fdbc1d647af5957d0529e7c1e484e18910f2fa2b9eb64f
|
|
4
|
+
data.tar.gz: a241475ff78f45aaecfe9f357a038fc0b38a088e7e1b2a081854c8d881eb610a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39c17658ac33cd69084270a3b9c2091241542061658295c4b47acbd55bf8a69888cf6c21cbea06fe81a8e14f9480521aabce7f48fc77e9a3cb04c78e03dee840
|
|
7
|
+
data.tar.gz: aee406c8c0c1947f5c832a0861f617457f70b5ef3774720d05487cbbea8780894f419b2b758e30a356ead5aa6fcda86878ba56e655b96d19de9a69560c392cc9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.4.0 - 2026-10-22
|
|
4
|
+
|
|
5
|
+
- Add document-based `image list`, `image stats` and `image width`. Resolve active
|
|
6
|
+
AsciiDoc includes, attributes, conditionals and per-image `imagesdir`; collect
|
|
7
|
+
referenced local block images and deduplicate physical files. Exclude artwork
|
|
8
|
+
by default with configurable selection. Report dimensions, aspect ratios,
|
|
9
|
+
file sizes and source references; summarize unique image statistics.
|
|
10
|
+
- Calculate `scaledwidth` from a configurable height/width coefficient and width
|
|
11
|
+
bounds. Preview by default, support JSON and unified diffs, and require explicit
|
|
12
|
+
`--in-place` to update source macros. Preserve image pixels and unrelated source
|
|
13
|
+
text, reject ambiguous reused references, stage multi-file edits and roll back
|
|
14
|
+
failed replacements. Replace the unreleased `epub image-width` prototype.
|
|
15
|
+
- Require ImageMagick 7 or 6 for image inspection; no Python dependency remains.
|
|
16
|
+
Image-file processing planned for v1.4.1 is tracked in
|
|
17
|
+
[issue #1](https://github.com/cybergarage/asciidoc-pubkit/issues/1).
|
|
18
|
+
|
|
19
|
+
- Add Japanese and English JSON example/prose comparisons for keys, schema
|
|
20
|
+
keywords, fixed values, explanatory strings and request/result references.
|
|
21
|
+
Follow each project's notation and edit scope; no universal emphasis policy,
|
|
22
|
+
detector, automatic inventory command, replacement or scoring change. New
|
|
23
|
+
sessions save the guidance; existing sessions retain their recorded criteria.
|
|
24
|
+
Prompt-delivery tests do not measure AI editing or translation quality.
|
|
25
|
+
|
|
26
|
+
- Clarify Japanese `示す` comparisons by explanatory role, with direct
|
|
27
|
+
method/outcome explanations, retained artifact/state examples and explicit
|
|
28
|
+
continuation targets. Deliver the guidance through writing and saved review
|
|
29
|
+
prompts without changing detectors, replacements, scores or old sessions.
|
|
30
|
+
Prompt-delivery regressions do not measure AI editing quality.
|
|
31
|
+
|
|
32
|
+
- Extend Japanese actor comparisons to explicit but vague role names, separating
|
|
33
|
+
system, internal recipient, execution environment and communication peer from
|
|
34
|
+
verb accuracy. Add ten calibration pairs, qualify the retained-return example,
|
|
35
|
+
and test writing/saved-review delivery without changing historical sessions.
|
|
36
|
+
No detector, replacement or scoring changes; AI editing quality is unmeasured.
|
|
37
|
+
|
|
38
|
+
- Add contextual Japanese retention/inclusion/storage/assignment and
|
|
39
|
+
representation/state-indication comparisons, including valid retained wording
|
|
40
|
+
and evidence-strength limits. Add manual comparison fixtures and saved-prompt
|
|
41
|
+
delivery regressions. No new detector rules, automatic replacements, scoring
|
|
42
|
+
changes or AI proofreading-quality claims.
|
|
4
43
|
|
|
5
44
|
## 1.3.1 - 2026-10-17
|
|
6
45
|
|
data/README.md
CHANGED
|
@@ -16,8 +16,9 @@ and books on health, exercise, and sports science published under
|
|
|
16
16
|
The experience informs the toolkit's writing criteria, contextual review prompts,
|
|
17
17
|
and checks for preserving manuscript content during revision.
|
|
18
18
|
|
|
19
|
-
Version 1.
|
|
20
|
-
|
|
19
|
+
Version 1.4.0 provides document-based image inspection and display sizing,
|
|
20
|
+
document inspection, explicit prose-only mechanical replacements, and Japanese
|
|
21
|
+
and English manuscript review. Inspect a book's outline,
|
|
21
22
|
metadata, and local cross-references; preview and apply your replacement rules;
|
|
22
23
|
then review and verify edits against a saved baseline.
|
|
23
24
|
|
|
@@ -30,6 +31,17 @@ Version 1.2.3 also compares `渡す` and `受け渡し` by their actual
|
|
|
30
31
|
operation; see [input, transmission, and handoff](docs/writing.md#input-transmission-and-handoff-v123).
|
|
31
32
|
These comparisons and skill routing do not automatically replace manuscript text.
|
|
32
33
|
|
|
34
|
+
Version 1.4.0 also compares explicit but vague actor names by their actual
|
|
35
|
+
responsibility; see [actor wording](docs/writing.md). This guidance adds no
|
|
36
|
+
detector or automatic replacement rules.
|
|
37
|
+
|
|
38
|
+
Version 1.4.0 adds document-based `image list`, `image stats`
|
|
39
|
+
and `image width`. Collect images referenced by `book.adoc`, summarize their
|
|
40
|
+
pixel dimensions and file sizes, or explicitly update source `scaledwidth`
|
|
41
|
+
attributes from aspect ratios. Image pixels are unchanged. See
|
|
42
|
+
[image commands](docs/image-commands.md) for selection, tuning, ImageMagick
|
|
43
|
+
requirements, preservation rules and Make integration.
|
|
44
|
+
|
|
33
45
|
The CLI, diagnostics, documentation, and generated instructions are in English.
|
|
34
46
|
Japanese manuscript excerpts and rule terms retain their original text.
|
|
35
47
|
|
|
@@ -49,12 +61,24 @@ for `わけではありません`; see [direct negation](docs/writing.md#direct-
|
|
|
49
61
|
Existing sessions retain their saved rules and criteria. No automatic rewriting
|
|
50
62
|
is added.
|
|
51
63
|
|
|
64
|
+
Version 1.4.0 also adds contextual Japanese comparisons for
|
|
65
|
+
retention, input inclusion, representation and state indication; see
|
|
66
|
+
[retention and representation wording](docs/writing.md#retention-and-representation-wording-v140).
|
|
67
|
+
These criteria do not add automatic replacements or change scoring.
|
|
68
|
+
Version 1.4.0 also compares `示す` by explanatory role; see
|
|
69
|
+
[explanation, presentation and state indication](docs/writing.md#explanation-presentation-and-state-indication-v140).
|
|
70
|
+
|
|
71
|
+
Version 1.4.0 Japanese and English criteria also compare JSON examples with their
|
|
72
|
+
prose explanations while preserving each project's notation and edit scope;
|
|
73
|
+
see [JSON identifiers and explanatory strings](docs/writing.md#json-identifiers-and-explanatory-strings-v140).
|
|
74
|
+
|
|
52
75
|
## Available features
|
|
53
76
|
|
|
54
|
-
The following commands are available in version 1.
|
|
77
|
+
The following commands are available in version 1.4.0.
|
|
55
78
|
|
|
56
79
|
| Feature | Commands | Behavior |
|
|
57
80
|
| --- | --- | --- |
|
|
81
|
+
| [Document images](docs/image-commands.md) | `image list`, `image stats`, `image width` | Inspect referenced block images; preview or explicitly apply source display widths |
|
|
58
82
|
| [Document outline](docs/document-commands.md#document-commands) | `document toc` | Print parsed section titles as text or JSON, including source locations, with optional depth and outline numbering |
|
|
59
83
|
| [Book metadata](docs/document-commands.md#document-commands) | `document info` | Extract book attributes as text or JSON |
|
|
60
84
|
| [Cross-reference checks](docs/document-commands.md#document-commands) | `document check-xrefs` | Report unresolved local cross-references with source locations |
|
data/data/writing/en/criteria.md
CHANGED
|
@@ -43,6 +43,39 @@ Words such as contract, boundary and robust can have specific technical meanings
|
|
|
43
43
|
Do not infer AI authorship from vocabulary. A phrase candidate is an invitation
|
|
44
44
|
to inspect, not a replacement instruction or a proven defect.
|
|
45
45
|
|
|
46
|
+
## Preserve JSON identifiers and explanatory strings
|
|
47
|
+
|
|
48
|
+
When prose explains a JSON example, distinguish keys, JSON Schema keywords,
|
|
49
|
+
fixed protocol values, tool names and example IDs from natural-language strings.
|
|
50
|
+
For example, in `{"name":"fetch_record","description":"Read a record"}`,
|
|
51
|
+
`name` and `description` are keys, `fetch_record` is the example tool name, and
|
|
52
|
+
`Read a record` describes its purpose. A string's JSON type alone does not make
|
|
53
|
+
it translatable or immutable. Resolve that role from the example and its use.
|
|
54
|
+
|
|
55
|
+
Keep each technical literal's spelling, case and separators, including compound
|
|
56
|
+
references such as `function.parameters` and JSON-RPC method names. Distinguish
|
|
57
|
+
`type` as a JSON key from a language keyword or ordinary prose, and distinguish
|
|
58
|
+
a schema keyword from a user-defined property with the same spelling. Record
|
|
59
|
+
the owning API, specification, implementation or example; do not assign another
|
|
60
|
+
project's identifiers to the book's implementation.
|
|
61
|
+
|
|
62
|
+
Compare the example with adjacent explanations and authorized tables/lists:
|
|
63
|
+
which field contains which value, whether an argument is required, where it is
|
|
64
|
+
nested, whether it is a JSON string or object, and how request/result IDs match.
|
|
65
|
+
Include later unmarked mentions. An occurrence inventory can help locate uses;
|
|
66
|
+
it must not infer roles by spelling alone, insert unused example fields into
|
|
67
|
+
prose, or turn every string into a fixed term. Record corrections, retained
|
|
68
|
+
uses and unresolved referents within the assignment's existing review evidence.
|
|
69
|
+
|
|
70
|
+
Follow the project's inline notation; no universal bold or monospace policy is
|
|
71
|
+
implied. Do not insert prose markup inside JSON/code blocks or change protected
|
|
72
|
+
blocks during prose review. Where an assigned translation explicitly permits
|
|
73
|
+
localizing explanatory strings, keep keys, technical values, structure and prose
|
|
74
|
+
references aligned; otherwise preserve the block and report the proposed change.
|
|
75
|
+
Keep parsing/block-preservation checks separate from meaning and translation
|
|
76
|
+
review. These comparisons add no detector or automatic replacement rule and do
|
|
77
|
+
not expand the session's editable scope.
|
|
78
|
+
|
|
46
79
|
## Honor the book's conventions
|
|
47
80
|
|
|
48
81
|
Preserve spelling variants unless the book specifies a locale. Follow its voice,
|
data/data/writing/ja/criteria.md
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
- Distinguish stopping, cancellation requests, and non-execution
|
|
11
11
|
- Distinguish decisions by the actual operation
|
|
12
12
|
- Distinguish rules, definitions, and configured values
|
|
13
|
+
- Distinguish retention from inclusion, storage, and assignment
|
|
14
|
+
- Distinguish representation from evidence and state indication
|
|
15
|
+
- Distinguish explanation, presentation, and state indication
|
|
13
16
|
- Distinguish receiving, returning, and their actual operations
|
|
14
17
|
- Distinguish communication responses from function returns
|
|
15
18
|
- Distinguish arrival wording by the actual operation
|
|
@@ -26,6 +29,7 @@
|
|
|
26
29
|
- Keep source uncertainty separate from editorial questions
|
|
27
30
|
- Remove generated-prose patterns without flattening the meaning
|
|
28
31
|
- Preserve exact technical terminology
|
|
32
|
+
- Preserve JSON identifiers and explanatory strings
|
|
29
33
|
- Revise the complete paragraph
|
|
30
34
|
- Compare revisions before delivery and respect passage roles
|
|
31
35
|
- Headings and the relation to figures and code
|
|
@@ -110,6 +114,37 @@ conditions, partial negation, capability, and the difference between a request
|
|
|
110
114
|
and its completion. Record the original, faithful alternative, and specific reason
|
|
111
115
|
for revising or retaining each assigned passage, even without detector candidates.
|
|
112
116
|
|
|
117
|
+
### Compare explicit actor names with the actual responsibility
|
|
118
|
+
|
|
119
|
+
A written subject can still hide its owner or role. Compare terms such as
|
|
120
|
+
`実行側` and `処理側` with the evidenced system, internal component, execution
|
|
121
|
+
environment, or communication peer. Establish the level of responsibility from
|
|
122
|
+
the full paragraph and implementation evidence before choosing a name. A system
|
|
123
|
+
name can suit behavior shared across its components; a component name can suit
|
|
124
|
+
an internal handoff. Neither is universally more precise.
|
|
125
|
+
|
|
126
|
+
| Passage and supported context | Comparison |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| The agent validates tool requests: `実行側は対象への操作が許可されるかを判定します。` | Compare `エージェントは対象への操作が許可されるかを判定します。`; preserve the target and permission owner. |
|
|
129
|
+
| A request is delegated inside the agent: `エージェントは要求を実行側へ引き渡します。` | Compare `エージェントは要求をツール実行処理へ引き渡します。` when that internal recipient is established; replacing the recipient with the same agent obscures the handoff. |
|
|
130
|
+
| The benchmark's environment executes commands: `実行側がコマンドを実行します。` | Compare `環境側の実行処理がコマンドを実行します。`; do not assign environment execution to the evaluated model or agent without evidence. |
|
|
131
|
+
| A request recipient sends a response: `実行側が結果を応答として送信します。` | Compare `要求を受信した相手が結果を応答として送信します。`; do not narrow the peer to a server if either endpoint can receive requests. |
|
|
132
|
+
| A preceding definition names one component `実行側` | Compare repeating the component's name, and retain the defined role when it identifies the same responsibility clearly and no author terminology preference requires a change. |
|
|
133
|
+
|
|
134
|
+
Do not replace every occurrence with `エージェント`, a product name, or
|
|
135
|
+
`実行処理`. Name only roles established by the assigned passage; keep formal
|
|
136
|
+
identifiers, book-specific terms, and other systems' ownership. Compare actor
|
|
137
|
+
specificity separately from whether a verb such as `戻します` describes the
|
|
138
|
+
correct operation. A valid verb does not settle an ambiguous actor, and a clear
|
|
139
|
+
actor does not settle an imprecise verb.
|
|
140
|
+
|
|
141
|
+
Compare the complete revised sentence and its neighbors after changing a name.
|
|
142
|
+
Check subject-predicate and particle relationships, modifier targets, repeated
|
|
143
|
+
words and unintended self-handoffs. In particular, naming the component applying
|
|
144
|
+
a configured rule must not also make it the component that configured the rule.
|
|
145
|
+
Retain conditions, capability, permission ownership and processing order. Record
|
|
146
|
+
the actual alternative and reason; missing actor evidence remains unresolved.
|
|
147
|
+
|
|
113
148
|
## Identify human actors by their supported roles
|
|
114
149
|
|
|
115
150
|
Treat `人` as a cue to identify the actor, not as a forbidden word or a
|
|
@@ -303,6 +338,97 @@ no detector candidate is emitted. Synchronize related authorized tables, figures
|
|
|
303
338
|
and alternative text separately from protected review scopes. Existing sessions
|
|
304
339
|
retain their saved criteria; these comparisons add no detector or replacement rule.
|
|
305
340
|
|
|
341
|
+
## Distinguish retention from inclusion, storage, and assignment
|
|
342
|
+
|
|
343
|
+
Compare `保持する` with the operation actually described. Identify the owner,
|
|
344
|
+
container, lifetime and processing stage. Input construction, storing a newly
|
|
345
|
+
obtained value, assigning an attribute, and keeping existing state are different
|
|
346
|
+
operations; do not replace them with one universal verb.
|
|
347
|
+
|
|
348
|
+
| Context | Faithful comparison when supported |
|
|
349
|
+
| --- | --- |
|
|
350
|
+
| Input construction | `成否の情報も入力へ保持します` → `成否の情報も入力に含めます`; supplying input does not establish storage across calls. |
|
|
351
|
+
| Contents of a summary | `すべての情報を要約に保持する必要はありません` → `すべての情報を要約に含める必要はありません`; preserve the necessity and negation. |
|
|
352
|
+
| Putting a retrieved value in a container | `取得した名前を結果用の変数に保持します` → `取得した名前を結果用の変数に格納します` when the insertion is the subject. |
|
|
353
|
+
| Assigning an identifier | `結果へ識別子を付与します` describes assignment; retaining an existing identifier is a different operation. |
|
|
354
|
+
| Adding information to a record | Compare `ノートに時刻を記録します` or `検索結果に出典を添えます` when recording or attachment is established. |
|
|
355
|
+
| Keeping original data or state | Retain `元の応答を保持し、次の呼び出しへ引き継ぎます` and `ロックを終了まで保持します`; inclusion or insertion alone loses continuity or ownership. |
|
|
356
|
+
|
|
357
|
+
Compare complete sentences, including retained uses. `入力に含めます` does not
|
|
358
|
+
mean `モデルへ送信します`; `格納します` does not establish file persistence.
|
|
359
|
+
A type declaring fields does not itself execute storage or assignment. Use
|
|
360
|
+
`付与` for an established attribute or identifier assignment, not as a blanket
|
|
361
|
+
replacement for input inclusion. Keep original values, duration, negation,
|
|
362
|
+
conditions, ownership and capability; do not add persistence, delete history,
|
|
363
|
+
or shorten the lifetime of a lock or snapshot. Keeping source facts does not
|
|
364
|
+
require keeping the word `保持`; record the actual alternative and reason.
|
|
365
|
+
|
|
366
|
+
## Distinguish representation from evidence and state indication
|
|
367
|
+
|
|
368
|
+
For `表す` and its inflections, identify whether the passage describes a
|
|
369
|
+
representation (notation, format, role or data model), contents, or a result
|
|
370
|
+
indicating a fact or state. Compare `示す` for the latter, honoring the author's
|
|
371
|
+
terminology preference without treating all uses of `表す` as unnatural.
|
|
372
|
+
|
|
373
|
+
| Context | Faithful comparison when supported |
|
|
374
|
+
| --- | --- |
|
|
375
|
+
| A result indicating failure | `失敗を表す結果` → `失敗を示す結果`; do not turn failure into an unknown outcome or vice versa. |
|
|
376
|
+
| Status information | `成否を表す情報` → `成否を示す情報` when information indicates success or failure. |
|
|
377
|
+
| What a record establishes | `要求の記録は、操作を要求したことを表します` → `要求の記録は、操作を要求したことを示します`; a request record alone does not establish execution. |
|
|
378
|
+
| Contents of a result | Compare `結果に含まれる情報` with `結果が表す情報` when describing included data rather than its interpretation. |
|
|
379
|
+
| Symbolic or structural representation | Retain `工程をノードで表します`, `引数をJSONで表します` and `利用者をUと表します`; `示す` is not required for notation or encoding. |
|
|
380
|
+
|
|
381
|
+
`裏付ける` may make a stronger evidence claim than `示す`. Use it only when the
|
|
382
|
+
source establishes that evidential role; do not upgrade a reported state into
|
|
383
|
+
proof, a correlation into causation, or request acceptance into successful work.
|
|
384
|
+
Preserve uncertainty, negation, conditions, actors and capability. Review the
|
|
385
|
+
whole paragraph and related authorized tables, figures and alternative text;
|
|
386
|
+
record each original, alternative and reason. These comparisons add no detector
|
|
387
|
+
or automatic replacement rule, do not change scoring or mechanical verification,
|
|
388
|
+
and do not measure AI proofreading quality. Existing sessions keep their saved
|
|
389
|
+
criteria; use a separate new session for updated guidance.
|
|
390
|
+
|
|
391
|
+
## Distinguish explanation, presentation, and state indication
|
|
392
|
+
|
|
393
|
+
For `示す` and its inflections, identify the sentence's role before choosing
|
|
394
|
+
its predicate. A content guide, a technical explanation, a displayed output,
|
|
395
|
+
a figure or example being presented, and a value indicating a state are different
|
|
396
|
+
uses. Read the complete paragraph and the referenced content when available;
|
|
397
|
+
these comparisons do not prescribe a blanket change to `説明します`.
|
|
398
|
+
|
|
399
|
+
| Role and wording to inspect | Faithful comparison when supported |
|
|
400
|
+
| --- | --- |
|
|
401
|
+
| Announcing explanatory content: `反復を継続・終了する条件を示します。` | Compare `反復を継続・終了する条件を説明します。` when the section explains those conditions; keep both continuation and termination. |
|
|
402
|
+
| Repeating one explanatory action: `保存方法を説明し、再開する条件を示します。` | Compare `保存方法と再開する条件を説明します。` when both are explanatory subjects. Preserve a meaningful order, separate artifact or distinct presentation purpose instead of merging merely to vary endings. |
|
|
403
|
+
| Naming an unspecified aid: `判断材料を示します。` | Name what is being selected or checked and which information supports that judgment. Use only criteria evidenced in the paragraph; do not invent a fixed decision rule. |
|
|
404
|
+
| Describing a screen: `画面には、使用を停止する範囲を示します。` | Compare `画面には、使用を停止する範囲を表示します。` when screen output is the operation. Do not assign display to a service that only returns data. |
|
|
405
|
+
| Describing a definition: `ツール定義は、引数の入力条件を示します。` | Compare `ツール定義には、引数の入力条件を記述します。` for authoring a definition, or `記述されています` for its existing contents. Preserve the distinction between writing a definition and enforcing it. |
|
|
406
|
+
| Recording scope: `計測した区間を示します。` | Compare `計測した区間を記録します。` when the passage specifies what to record; keep the measured interval and clock conditions. |
|
|
407
|
+
| Presenting an actual artifact: `次の表に、検査対象と確認内容を示します。` or `設定ファイルの例を示します。` | Retain these when the table or following example actually presents that content. `説明します` would shift from presenting the artifact to describing it. |
|
|
408
|
+
| Indicating a state: `結果は、返答を記録したことを示します。` | Retain the indication when that is the result's meaning. Compare contents wording such as `結果に記録の成否が含まれます` only when included data is the subject; recorded acceptance does not establish successful execution. |
|
|
409
|
+
| Leaving the indicated target implicit: `結果が継続を示します。` | Compare `一回分の処理結果が、次の回へ進むことを示します。` when that is the continuation being described. Keeping `示します` can be the clearest revision. |
|
|
410
|
+
|
|
411
|
+
In the middle or at the end of a technical explanation, compare stating the
|
|
412
|
+
relationship directly instead of promising another explanation. For example,
|
|
413
|
+
`プロセス内の順序制御で防ぐ競合と、外部からの変更に備えて検査する競合を示します。`
|
|
414
|
+
can become `プロセス内の競合は、操作の順序を制御して防ぎます。外部からの変更による競合には、検査で確認する状態と検査のタイミングを明確にして備えます。`
|
|
415
|
+
when the surrounding paragraph establishes both methods. Preserve the scope of
|
|
416
|
+
the controlled operations; neither ordering nor checking guarantees prevention
|
|
417
|
+
of every external change. If the original also names the inspected state and
|
|
418
|
+
timing, retain them in the revised paragraph.
|
|
419
|
+
|
|
420
|
+
Compare the full paragraph before replacing the verb. Resolve vague subjects,
|
|
421
|
+
comparison axes, repeated guidance and the relationship between methods and
|
|
422
|
+
outcomes; exchanging `示します` for `説明します` alone may leave those problems
|
|
423
|
+
unchanged. Keep valid figure/table introductions and state indications after a
|
|
424
|
+
specific comparison, not because all occurrences must share one ending. Check
|
|
425
|
+
related authorized tables, figures and alternative text without inventing
|
|
426
|
+
actors, processing, evidence, guarantees or successful checks.
|
|
427
|
+
|
|
428
|
+
These criteria add no detector, automatic replacement or scoring change.
|
|
429
|
+
Existing sessions retain their saved criteria; mechanical verification remains
|
|
430
|
+
separate from meaning review and does not measure AI proofreading quality.
|
|
431
|
+
|
|
306
432
|
## Give weak predicates a concrete action or consequence
|
|
307
433
|
|
|
308
434
|
Predicates such as `利用します`, `決めます`, `示します`, `扱います`, `整理します`,
|
|
@@ -647,8 +773,10 @@ outcome is not an established failure.
|
|
|
647
773
|
`利用者は候補Aと候補Bから選択できます` retains that choice while using technical
|
|
648
774
|
selection wording. Compare this faithful alternative before keeping the plain verb.
|
|
649
775
|
`利用者は候補Aと候補Bから選びます` would instead assert that selection occurs. Retain
|
|
650
|
-
`実行側はツール結果をモデルへ戻します` when it
|
|
651
|
-
|
|
776
|
+
the verb `戻します` in `実行側はツール結果をモデルへ戻します` when it
|
|
777
|
+
accurately describes the transfer; assess `実行側` separately using the actor
|
|
778
|
+
criteria above. `実行結果のフィードバック` would lose the sentence's actor
|
|
779
|
+
and predicate.
|
|
652
780
|
|
|
653
781
|
Do not mechanically convert `別です` to `とは限りません`. For example,
|
|
654
782
|
`AはJSONを、BはCSVを受け付けます。両者の入力形式は別です` establishes a
|
|
@@ -1075,6 +1203,39 @@ and implementation requirements. Do not add an actor, cause, mechanism, or
|
|
|
1075
1203
|
effect that the source evidence does not establish. Making prose more specific
|
|
1076
1204
|
requires evidence, not a guess.
|
|
1077
1205
|
|
|
1206
|
+
## Preserve JSON identifiers and explanatory strings
|
|
1207
|
+
|
|
1208
|
+
When prose explains a JSON example, distinguish keys, JSON Schema keywords,
|
|
1209
|
+
fixed protocol values, tool names and example IDs from natural-language strings.
|
|
1210
|
+
For example, in `{"name":"fetch_record","description":"Read a record"}`,
|
|
1211
|
+
`name` and `description` are keys, `fetch_record` is the example tool name, and
|
|
1212
|
+
`Read a record` describes its purpose. A string's JSON type alone does not make
|
|
1213
|
+
it translatable or immutable. Resolve that role from the example and its use.
|
|
1214
|
+
|
|
1215
|
+
Keep each technical literal's spelling, case and separators, including compound
|
|
1216
|
+
references such as `function.parameters` and JSON-RPC method names. Distinguish
|
|
1217
|
+
`type` as a JSON key from a language keyword or ordinary prose, and distinguish
|
|
1218
|
+
a schema keyword from a user-defined property with the same spelling. Record
|
|
1219
|
+
the owning API, specification, implementation or example; do not assign another
|
|
1220
|
+
project's identifiers to the book's implementation.
|
|
1221
|
+
|
|
1222
|
+
Compare the example with adjacent explanations and authorized tables/lists:
|
|
1223
|
+
which field contains which value, whether an argument is required, where it is
|
|
1224
|
+
nested, whether it is a JSON string or object, and how request/result IDs match.
|
|
1225
|
+
Include later unmarked mentions. An occurrence inventory can help locate uses;
|
|
1226
|
+
it must not infer roles by spelling alone, insert unused example fields into
|
|
1227
|
+
prose, or turn every string into a fixed term. Record corrections, retained
|
|
1228
|
+
uses and unresolved referents within the assignment's existing review evidence.
|
|
1229
|
+
|
|
1230
|
+
Follow the project's inline notation; no universal bold or monospace policy is
|
|
1231
|
+
implied. Do not insert prose markup inside JSON/code blocks or change protected
|
|
1232
|
+
blocks during prose review. Where an assigned translation explicitly permits
|
|
1233
|
+
localizing explanatory strings, keep keys, technical values, structure and prose
|
|
1234
|
+
references aligned; otherwise preserve the block and report the proposed change.
|
|
1235
|
+
Keep parsing/block-preservation checks separate from meaning and translation
|
|
1236
|
+
review. These comparisons add no detector or automatic replacement rule and do
|
|
1237
|
+
not expand the session's editable scope.
|
|
1238
|
+
|
|
1078
1239
|
## Revise the complete paragraph
|
|
1079
1240
|
|
|
1080
1241
|
Use a finding to understand the intended claim, then rewrite the paragraph so
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Document-based image commands (v1.4.0)
|
|
2
|
+
|
|
3
|
+
All commands take an AsciiDoc entry document, such as `book.adoc`. They do not
|
|
4
|
+
accept a standalone image file or scan an arbitrary directory. They require Ruby
|
|
5
|
+
3.2 or later and ImageMagick 7 (`magick identify`) or 6 (`identify`) on PATH.
|
|
6
|
+
No Python, MeCab, AI, network fetch, or pixel modification is involved.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
asciidoc-pubkit image list book.adoc
|
|
10
|
+
asciidoc-pubkit image list book.adoc --json
|
|
11
|
+
asciidoc-pubkit image stats book.adoc --json
|
|
12
|
+
asciidoc-pubkit image width book.adoc
|
|
13
|
+
asciidoc-pubkit image width book.adoc --diff
|
|
14
|
+
asciidoc-pubkit image width book.adoc --in-place
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Discovery and selection
|
|
18
|
+
|
|
19
|
+
Asciidoctor resolves active includes, attributes, conditional directives, and the
|
|
20
|
+
`imagesdir` value at each block image. Paths are relative to the document's base
|
|
21
|
+
directory, as in Asciidoctor, rather than each included file. Only parsed block
|
|
22
|
+
`image::` macros are collected. Inline `image:` macros, image text inside code or
|
|
23
|
+
comments, cover attributes without a block reference, and unreferenced files are
|
|
24
|
+
outside the v1.4.0 collection scope. An AsciiDoc table's separate inner documents
|
|
25
|
+
are not traversed in this version.
|
|
26
|
+
|
|
27
|
+
The default boundary is the entry document's directory. `--base-dir DIR` changes
|
|
28
|
+
both the parsing base and the permitted source/image boundary. Includes and
|
|
29
|
+
images outside it, including symlink escapes, are rejected. Direct symlink source
|
|
30
|
+
files are rejected. Image symlinks within the boundary are resolved and deduplicated.
|
|
31
|
+
Remote image references are reported as excluded without fetching; remote
|
|
32
|
+
includes and `allow-uri-read` are rejected. Missing or unsupported selected
|
|
33
|
+
images fail the command with exit 2 before source writes.
|
|
34
|
+
|
|
35
|
+
By default, block images whose basenames match `cover*`, `chapter-*`, `part-*`,
|
|
36
|
+
or `profile*`, and block references to `front-cover-image`, `back-cover-image`,
|
|
37
|
+
or `title-logo-image` assets, are excluded. `--include-artwork` disables these
|
|
38
|
+
built-in artwork exclusions; it does not collect assets that only appear in
|
|
39
|
+
attributes. Use `--exclude` for artwork with other names. Patterns match an image
|
|
40
|
+
basename or its path relative to the base directory. Repeat the flag for multiple
|
|
41
|
+
patterns. `--only FILE` selects references from one included source; it does not
|
|
42
|
+
mean one image, and the file must be part of the parsed document.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
asciidoc-pubkit image list book.adoc --exclude 'special-*.png' --json
|
|
46
|
+
asciidoc-pubkit image width book.adoc --only chapters/intro.adoc --diff
|
|
47
|
+
asciidoc-pubkit image list book.adoc -a edition-en -a diagrams=1
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## List and stats
|
|
51
|
+
|
|
52
|
+
`image list` reports each selected physical image once, in first-reference order:
|
|
53
|
+
absolute path, pixel width/height, full-precision width/height ratio, byte size,
|
|
54
|
+
and every reference's source file, line, target and current `scaledwidth`.
|
|
55
|
+
Text output rounds aspect ratios for display; JSON preserves the calculation
|
|
56
|
+
value. Source editability and exclusions are included in JSON.
|
|
57
|
+
|
|
58
|
+
`image stats` counts physical images and references separately. It reports the
|
|
59
|
+
sum of unique image bytes and minimum, maximum and arithmetic mean of width,
|
|
60
|
+
height, aspect ratio and bytes. Repeated references are not counted twice in
|
|
61
|
+
image statistics. With no selected images, totals are zero and min/max/mean are
|
|
62
|
+
null. Both commands are read-only; redirect stdout to save their reports.
|
|
63
|
+
|
|
64
|
+
## Width calculation and source edits
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
raw width (%) = 100 × height-width-ratio × pixel width / pixel height
|
|
68
|
+
width (%) = clamp(raw width, min-width, max-width), rounded to one decimal
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Rounding is clamped again so it never crosses a bound. A fractional bound may
|
|
72
|
+
therefore retain more than one decimal place. Defaults are coefficient 0.8,
|
|
73
|
+
minimum 40%, maximum 100%. A square uses 80%, a 3:4 image 60%, and width/height
|
|
74
|
+
>= 1.25 reaches 100%. Until a bound applies, the displayed image height approaches
|
|
75
|
+
0.8 times the text area's width. This is not a percentage of screen height.
|
|
76
|
+
|
|
77
|
+
| Option | Default | Behavior |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `--height-width-ratio NUMBER` | `0.8` | Display height / text-area width coefficient |
|
|
80
|
+
| `--min-width PERCENT` | `40` | Smallest permitted display width |
|
|
81
|
+
| `--max-width PERCENT` | `100` | Largest permitted display width |
|
|
82
|
+
| `--dry-run` | default behavior | Report planned changes without writing |
|
|
83
|
+
| `--diff` | off | Print a unified source diff without writing |
|
|
84
|
+
| `--in-place` | off | Explicitly update the source image references |
|
|
85
|
+
| `--json` | off | Structured inventory, settings and before/after changes |
|
|
86
|
+
|
|
87
|
+
Coefficients must be finite and positive, and widths must satisfy
|
|
88
|
+
`0 < min-width <= max-width <= 100`. `--in-place` cannot be combined with
|
|
89
|
+
`--dry-run` or `--diff`; `--diff` cannot be combined with `--json`.
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
asciidoc-pubkit image width book.adoc --height-width-ratio 0.7 \
|
|
93
|
+
--min-width 50 --max-width 100 --exclude 'manual.png' --diff
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The result is written to the physical source macro, including included files:
|
|
97
|
+
|
|
98
|
+
```adoc
|
|
99
|
+
image::diagram.png[Existing description,align=center,scaledwidth=87.9%]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Existing `scaledwidth` is updated; otherwise it is appended. Alt text, target
|
|
103
|
+
attribute references, other attributes, line endings, surrounding text and image
|
|
104
|
+
bytes are preserved. Explicit pixel width/height attributes are retained.
|
|
105
|
+
Backends that honor `scaledwidth`, including asciidoctor-epub3, consume it during
|
|
106
|
+
conversion; this does not impose a universal CSS width on every backend.
|
|
107
|
+
|
|
108
|
+
Source provenance is attached only in the parser's memory before include
|
|
109
|
+
lookahead can lose its location. No internal metadata is written to source.
|
|
110
|
+
Unsupported or unmapped source forms are not guessed: list/stats can report them,
|
|
111
|
+
but width refuses an unsafe edit. Duplicate `scaledwidth` declarations are rejected.
|
|
112
|
+
A reused source macro can be edited once when all references request the same
|
|
113
|
+
result; conflicting expansions or an excluded reuse block the edit. Separate
|
|
114
|
+
attributes or macros across multiple lines are not reconstructed.
|
|
115
|
+
|
|
116
|
+
All edits and image inspections complete before writing. Changed files are
|
|
117
|
+
staged in their own directories with their modes preserved. Source snapshots
|
|
118
|
+
are checked for concurrent changes. A failed multi-file replacement rolls back
|
|
119
|
+
already installed changes, without overwriting a later concurrent writer's edits.
|
|
120
|
+
Repeated execution with the same inputs is idempotent. There is no `--output`
|
|
121
|
+
or `--output-dir` mode in v1.4.0; a single output file cannot represent updates
|
|
122
|
+
across several included files. Use preview/diff to review changes first.
|
|
123
|
+
|
|
124
|
+
Image whitespace is included in the pixel dimensions. At the minimum width a
|
|
125
|
+
very tall figure can still exceed a page, and text may require a larger width.
|
|
126
|
+
The coefficient and bounds are tuning values, not KDP requirements. Run the
|
|
127
|
+
book build, EPUBCheck and Kindle Previewer after applying source changes.
|
|
128
|
+
|
|
129
|
+
Successful commands, previews and empty collections return 0. Invalid arguments,
|
|
130
|
+
parse errors, missing images and unsafe/unwritable source edits return 2. This
|
|
131
|
+
does not replace manuscript review verification or establish publication readiness.
|
|
132
|
+
|
|
133
|
+
## Make integration
|
|
134
|
+
|
|
135
|
+
Call width adjustment before the converter reads the source document:
|
|
136
|
+
|
|
137
|
+
```make
|
|
138
|
+
ASCIIDOC_PUBKIT ?= asciidoc-pubkit
|
|
139
|
+
IMAGE_HEIGHT_WIDTH_RATIO ?= 0.8
|
|
140
|
+
IMAGE_MIN_WIDTH ?= 40
|
|
141
|
+
IMAGE_MAX_WIDTH ?= 100
|
|
142
|
+
IMAGE_SELECTION_OPTS ?=
|
|
143
|
+
IMAGE_WIDTH_OPTS = --height-width-ratio $(IMAGE_HEIGHT_WIDTH_RATIO) --min-width $(IMAGE_MIN_WIDTH) --max-width $(IMAGE_MAX_WIDTH) $(IMAGE_SELECTION_OPTS)
|
|
144
|
+
|
|
145
|
+
.PHONY: image-list image-stats image-width
|
|
146
|
+
image-list:
|
|
147
|
+
$(ASCIIDOC_PUBKIT) image list book.adoc $(IMAGE_SELECTION_OPTS)
|
|
148
|
+
image-stats:
|
|
149
|
+
$(ASCIIDOC_PUBKIT) image stats book.adoc $(IMAGE_SELECTION_OPTS)
|
|
150
|
+
image-width:
|
|
151
|
+
$(ASCIIDOC_PUBKIT) image width book.adoc $(IMAGE_WIDTH_OPTS) --in-place
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Use your build's pre-generation prerequisite hook to run `image-width`. It must
|
|
155
|
+
finish before conversion, rather than running alongside the converter. No EPUB
|
|
156
|
+
postprocessing is needed. The earlier unreleased `epub image-width` prototype is
|
|
157
|
+
replaced by this document-based interface; it was not a released public command.
|
|
158
|
+
|
|
159
|
+
## Later scope
|
|
160
|
+
|
|
161
|
+
Image-file processing (`resize`, `trim`, `pad`, `quantize`, and possible composite
|
|
162
|
+
preparation) is planned for v1.4.1 and tracked in
|
|
163
|
+
[GitHub issue #1](https://github.com/cybergarage/asciidoc-pubkit/issues/1).
|
|
164
|
+
Those commands are not implemented in v1.4.0. Their input will also be the
|
|
165
|
+
AsciiDoc document, rather than a standalone image.
|
data/docs/installation.md
CHANGED
|
@@ -8,6 +8,10 @@ asciidoc-pubkit --version
|
|
|
8
8
|
asciidoc-pubkit --help
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
The v1.4.0 `image list`, `image stats` and `image width` commands additionally
|
|
12
|
+
require ImageMagick 7 (`magick`) or 6 (`identify`). They do not require Python or
|
|
13
|
+
MeCab. See [image commands](image-commands.md).
|
|
14
|
+
|
|
11
15
|
Ruby 3.2 or later is required. RubyGems installs the required Ruby dependencies;
|
|
12
16
|
no repository clone or Node.js installation is needed. MeCab and IPADIC must be
|
|
13
17
|
installed separately when using Japanese review or scoring in the default mode.
|
|
@@ -41,7 +45,7 @@ Add the gem to your project's `Gemfile` to manage its version with Bundler:
|
|
|
41
45
|
|
|
42
46
|
```ruby
|
|
43
47
|
source 'https://rubygems.org'
|
|
44
|
-
gem 'asciidoc-pubkit', '~> 1.
|
|
48
|
+
gem 'asciidoc-pubkit', '~> 1.4.0'
|
|
45
49
|
```
|
|
46
50
|
|
|
47
51
|
Then install dependencies and run the CLI through Bundler:
|
data/docs/prose-evaluation.md
CHANGED
|
@@ -26,6 +26,20 @@ limits. This implementation uses pubkit's own selected AsciiDoc scope and
|
|
|
26
26
|
preservation contracts; upstream performance and model-evaluation results are
|
|
27
27
|
not measurements of pubkit.
|
|
28
28
|
|
|
29
|
+
<a id="explicit-actor-names-unreleased"></a>
|
|
30
|
+
|
|
31
|
+
## Explicit actor names (v1.4.0)
|
|
32
|
+
|
|
33
|
+
Ten additional calibration pairs compare explicit role names with the supported
|
|
34
|
+
system, internal component, execution environment or communication peer. They
|
|
35
|
+
include valid defined roles, accurate return verbs, unintended self-handoffs,
|
|
36
|
+
unsupported owners and a rule applier incorrectly made its configuration owner.
|
|
37
|
+
The existing retained-transfer example now defines its actor first; its historical
|
|
38
|
+
ID remains unchanged. Judge actor specificity independently from verb accuracy.
|
|
39
|
+
Tests cover fixture integrity, writing and saved prompts in all three review
|
|
40
|
+
scopes, immutable session criteria and unchanged sources. They do not invoke an
|
|
41
|
+
AI evaluator, measure editing quality or establish semantic correctness.
|
|
42
|
+
|
|
29
43
|
## Actor clarity comparisons (v1.2.3)
|
|
30
44
|
|
|
31
45
|
Twelve additional calibration pairs cover conditional actor changes, user refusal
|
|
@@ -42,8 +56,8 @@ criteria changes against a project-defined baseline. Keep detection performance,
|
|
|
42
56
|
readability, and meaning preservation separate so that a clearer rewrite cannot
|
|
43
57
|
hide a lost condition or invented fact.
|
|
44
58
|
|
|
45
|
-
This guide describes
|
|
46
|
-
`technical-prose-v3` corpus and
|
|
59
|
+
This guide describes version 1.4.0, including the
|
|
60
|
+
`technical-prose-v3` corpus and 165 revision calibration pairs. The sentence-ending
|
|
47
61
|
criteria and twelve additional pairs, plus the flow guidance and four further
|
|
48
62
|
pairs, are included in version 1.2.0.
|
|
49
63
|
The evaluation runner is not an
|
|
@@ -111,7 +125,7 @@ of Japanese writing.
|
|
|
111
125
|
| [prose_benchmark.ja.adoc](../test/fixtures/prose_benchmark.ja.adoc) | 26 paragraphs used as the actual AsciiDoc input |
|
|
112
126
|
| [prose_benchmark.ja.json](../test/fixtures/prose_benchmark.ja.json) | Matching paragraph IDs and text, 11 annotated detector targets, and preservation checklists |
|
|
113
127
|
| [prose_benchmark.yml](../test/fixtures/prose_benchmark.yml) | Fixed empty configuration that isolates the benchmark from discovered manuscript settings |
|
|
114
|
-
| [prose_evaluation.ja.json](../test/fixtures/prose_evaluation.ja.json) | Detection examples and
|
|
128
|
+
| [prose_evaluation.ja.json](../test/fixtures/prose_evaluation.ja.json) | Detection examples and 165 manual revision pairs with expected `accept`, `reject`, or `needs-evidence` dispositions |
|
|
115
129
|
|
|
116
130
|
The corpus includes framing such as `重要なのは`, metaphorical operations such
|
|
117
131
|
as `地味に効く`, inflected and negative forms, and repeated endings. Controls
|
|
@@ -468,3 +482,17 @@ of criteria to writing and saved review prompts, including historical-session
|
|
|
468
482
|
preservation; they do not establish AI judgment accuracy. The updated judge rubric
|
|
469
483
|
requires a compatible fresh baseline for future AI comparisons. No AI evaluation
|
|
470
484
|
was run; improvement remains unmeasured and `meaning_verified` remains false.
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
<a id="retention-and-representation-comparisons-unreleased"></a>
|
|
488
|
+
|
|
489
|
+
## Retention and representation comparisons (v1.4.0)
|
|
490
|
+
|
|
491
|
+
`test/fixtures/retention_representation_wording.ja.json` contains 24 manually
|
|
492
|
+
labeled comparisons covering input inclusion, storage, recording, assignment,
|
|
493
|
+
retained history/locks/snapshots, result/state indication and valid notation.
|
|
494
|
+
Rejection examples cover invented persistence, lost identity or lifetime,
|
|
495
|
+
capability changes, unknown results treated as failure, and stronger evidence
|
|
496
|
+
or causation claims. The fixture is separate from the evaluation runner's corpus.
|
|
497
|
+
Its tests check data integrity and saved-prompt behavior, not the correctness of
|
|
498
|
+
these language judgments. No model judge or AI-quality measurement is run.
|
data/docs/writing.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Writing commands
|
|
2
2
|
|
|
3
|
+
Version 1.4.0 extends the [actor criteria](../data/writing/ja/criteria.md#compare-explicit-actor-names-with-the-actual-responsibility)
|
|
4
|
+
to explicit but vague role names such as `実行側` and `処理側`. Compare the
|
|
5
|
+
evidenced system, internal component, execution environment or communication
|
|
6
|
+
peer, and judge actor specificity separately from verb accuracy. Recheck the
|
|
7
|
+
whole sentence for self-handoffs and changed modifier or configuration ownership.
|
|
8
|
+
These are contextual instructions, with no new detector or replacement rules;
|
|
9
|
+
saved sessions retain their original criteria.
|
|
10
|
+
|
|
3
11
|
The v1.2.3 [actor-change criteria](../data/writing/ja/criteria.md#clarify-omitted-subjects-when-actors-change)
|
|
4
12
|
compare omitted and explicit subjects across clauses, sentences and table roles.
|
|
5
13
|
They distinguish requesting, approving, executing and investigating, preserve
|
|
@@ -241,3 +249,58 @@ their scope. The bundled review skill routes these assignments to the saved
|
|
|
241
249
|
criteria. Writing commands and new heading, prose and list sessions include the
|
|
242
250
|
guidance; existing sessions keep their original criteria. Regression checks cover
|
|
243
251
|
criteria delivery and source preservation, not measured AI proofreading quality.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
<a id="retention-and-representation-wording-unreleased"></a>
|
|
255
|
+
|
|
256
|
+
## Retention and representation wording (v1.4.0)
|
|
257
|
+
|
|
258
|
+
The shared Japanese criteria now compare `保持` with input inclusion, container
|
|
259
|
+
storage, recording and attribute assignment, and `表す` with state indication,
|
|
260
|
+
evidence and contents. Preserve valid retention of history, original values,
|
|
261
|
+
locks and snapshots, and valid representation by symbols, JSON, code or graphs.
|
|
262
|
+
See [retention](../data/writing/ja/criteria.md#distinguish-retention-from-inclusion-storage-and-assignment)
|
|
263
|
+
and [representation](../data/writing/ja/criteria.md#distinguish-representation-from-evidence-and-state-indication).
|
|
264
|
+
|
|
265
|
+
These are contextual comparisons, not blanket replacements or new detector rules.
|
|
266
|
+
They reach writing commands and new Japanese heading, prose and list sessions;
|
|
267
|
+
existing sessions keep their saved criteria. English guidance, scoring and
|
|
268
|
+
mechanical verification are unchanged. Manual comparison fixtures and delivery
|
|
269
|
+
regressions do not measure AI editing quality or semantic correctness.
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
<a id="explanation-presentation-and-state-indication-unreleased"></a>
|
|
273
|
+
|
|
274
|
+
## Explanation, presentation and state indication (v1.4.0)
|
|
275
|
+
|
|
276
|
+
The [shared Japanese criteria](../data/writing/ja/criteria.md#distinguish-explanation-presentation-and-state-indication)
|
|
277
|
+
compare `示す` by its role: announcing an explanation, stating technical behavior,
|
|
278
|
+
displaying or recording information, presenting an actual figure/table/example,
|
|
279
|
+
or indicating a value's meaning. Compare whole paragraphs, including repeated
|
|
280
|
+
`説明し…示します` guidance and method/outcome relationships. Preserve valid
|
|
281
|
+
presentation and state-indication wording; do not replace every use with
|
|
282
|
+
`説明します` or strengthen an inspection into a guarantee.
|
|
283
|
+
|
|
284
|
+
Writing commands and new Japanese heading, prose and list sessions include the
|
|
285
|
+
guidance; existing sessions retain their saved criteria. No detector, automatic
|
|
286
|
+
replacement, score or semantic-verification behavior changes. Delivery tests
|
|
287
|
+
check prompt contents and source preservation, not AI proofreading quality.
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
<a id="json-identifiers-and-explanatory-strings-unreleased"></a>
|
|
291
|
+
|
|
292
|
+
## JSON identifiers and explanatory strings (v1.4.0)
|
|
293
|
+
|
|
294
|
+
The [Japanese](../data/writing/ja/criteria.md#preserve-json-identifiers-and-explanatory-strings)
|
|
295
|
+
and [English](../data/writing/en/criteria.md#preserve-json-identifiers-and-explanatory-strings)
|
|
296
|
+
criteria distinguish JSON keys, schema keywords and technical values from
|
|
297
|
+
natural-language descriptions. Compare examples with their explanations,
|
|
298
|
+
including field/value ownership, nesting, required arguments, string/object
|
|
299
|
+
representation and request/result IDs. Follow the book's notation rather than
|
|
300
|
+
requiring emphasis or monospace. JSON/code blocks remain protected in prose
|
|
301
|
+
review; translation of explanatory strings requires its own assigned scope.
|
|
302
|
+
|
|
303
|
+
Writing commands and new review sessions include these comparisons. Existing
|
|
304
|
+
sessions retain their saved criteria. This is prompt guidance, not an automatic
|
|
305
|
+
JSON inventory or rewriting command; parsing and preservation checks do not
|
|
306
|
+
establish semantic correctness or translation fidelity.
|
|
@@ -80,6 +80,11 @@ without forcing repetition. Inspect related authorized table/figure roles in the
|
|
|
80
80
|
own scopes; report missing actor evidence rather than assigning a plausible role.
|
|
81
81
|
If the selected CLI lacks the actor-change examples, report that criteria limitation
|
|
82
82
|
and retain saved sessions; keep the canonical examples in pubkit.
|
|
83
|
+
Review explicit actor names through those criteria too, recording the supported
|
|
84
|
+
responsibility and recipient rather than treating a written subject as sufficient.
|
|
85
|
+
Assess actor specificity and verb accuracy separately and compare the full revised
|
|
86
|
+
sentence before finalizing the decision; preserve defined roles and unresolved
|
|
87
|
+
owners. Do not copy book-specific actor replacements into this shared skill.
|
|
83
88
|
|
|
84
89
|
For an assigned content guide or learning objective, record the whole-paragraph
|
|
85
90
|
viewpoint and any repeated guidance along with the source, alternative and reason.
|
data/lib/asciidoc_pubkit/cli.rb
CHANGED
|
@@ -14,6 +14,9 @@ module AsciidocPubkit
|
|
|
14
14
|
document info FILE Extract book metadata
|
|
15
15
|
document check-xrefs FILE Report unresolved local cross-references
|
|
16
16
|
document index DIRECTORY Generate an English-title AsciiDoc index
|
|
17
|
+
image list FILE List images referenced by an AsciiDoc document
|
|
18
|
+
image stats FILE Summarize document-referenced image dimensions and sizes
|
|
19
|
+
image width FILE Preview or explicitly apply display widths to source image macros
|
|
17
20
|
writing criteria Print the shared Japanese or English prose criteria
|
|
18
21
|
writing prompt Generate a technical writing prompt
|
|
19
22
|
review scan FILE Collect Japanese or English prose, headings, or list text and review candidates
|
|
@@ -31,7 +34,7 @@ module AsciidocPubkit
|
|
|
31
34
|
Use --lang ja (default) or en with writing commands and review commands. Other
|
|
32
35
|
languages and regional tags are unsupported and return an error.
|
|
33
36
|
skill install and upgrade write only the selected skill directory.
|
|
34
|
-
|
|
37
|
+
replace apply and image width --in-place explicitly edit manuscript sources. review score --agent explicitly invokes a
|
|
35
38
|
local Codex or Claude CLI, which may connect to its configured AI service.
|
|
36
39
|
TEXT
|
|
37
40
|
|
|
@@ -46,11 +49,12 @@ module AsciidocPubkit
|
|
|
46
49
|
out.puts VERSION
|
|
47
50
|
return 0
|
|
48
51
|
end
|
|
49
|
-
if args.empty? || args == ['--help'] || args == ['-h'] || %w[review writing replace document skill].any? { |group| args == [group, '--help'] }
|
|
52
|
+
if args.empty? || args == ['--help'] || args == ['-h'] || %w[review writing replace document skill image].any? { |group| args == [group, '--help'] }
|
|
50
53
|
out.puts HELP
|
|
51
54
|
return 0
|
|
52
55
|
end
|
|
53
56
|
group, command = args.shift(2)
|
|
57
|
+
return ImageCommands.run(command, args, out: out, err: err) if group == 'image'
|
|
54
58
|
return SkillCommands.run(command, args, out: out, err: err) if group == 'skill'
|
|
55
59
|
if group == 'document' && %w[toc info check-xrefs index].include?(command)
|
|
56
60
|
return DocumentCommands.run(command, args, out: out, err: err)
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'tempfile'
|
|
5
|
+
|
|
6
|
+
module AsciidocPubkit
|
|
7
|
+
# Only document-referenced block images are selected; image pixels stay unchanged.
|
|
8
|
+
class ImageCommands
|
|
9
|
+
ARTWORK = %w[cover* chapter-* part-* profile*].freeze
|
|
10
|
+
MACRO = /\A(image::[^\[]+\[)(.*)(\][ \t]*)(\r?\n)?\z/
|
|
11
|
+
|
|
12
|
+
class SourceLoader < DocumentCommands
|
|
13
|
+
attr_reader :sources, :image_sources, :source_key
|
|
14
|
+
|
|
15
|
+
def initialize(options, err)
|
|
16
|
+
super
|
|
17
|
+
@sources, @image_sources = {}, {}
|
|
18
|
+
@source_key = "pubkit-image-source-#{object_id}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def load(file)
|
|
22
|
+
raise Error, "Symlinked source is unsupported: #{file}" if File.symlink?(file)
|
|
23
|
+
owner = self
|
|
24
|
+
super(file) do |doc|
|
|
25
|
+
# Asciidoctor can lose a cursor at an include boundary after lookahead.
|
|
26
|
+
# Attach provenance in memory before parsing, never to the source file.
|
|
27
|
+
doc.reader.define_singleton_method(:process_line) do |line|
|
|
28
|
+
location = cursor
|
|
29
|
+
result = super(line)
|
|
30
|
+
annotated = owner.annotate(result, location)
|
|
31
|
+
replace_next_line(annotated) if annotated && annotated != result
|
|
32
|
+
annotated
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def annotate(line, cursor)
|
|
38
|
+
return line unless line && !line.include?(@source_key) && (match = line.match(MACRO))
|
|
39
|
+
token = @image_sources.length.to_s
|
|
40
|
+
@image_sources[token] = { 'file' => cursor.file && File.realpath(cursor.file), 'line' => cursor.lineno }
|
|
41
|
+
attrs = match[2].empty? ? "#{@source_key}=#{token}" : "#{match[2]},#{@source_key}=#{token}"
|
|
42
|
+
match[1] + attrs + match[3] + match[4].to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def check_source(file, root)
|
|
46
|
+
super
|
|
47
|
+
raise Error, "Symlinked source is unsupported: #{file}" if File.symlink?(file)
|
|
48
|
+
@sources[File.realpath(file)] ||= AsciidocPubkit.read_text(file)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.run(command, args, out:, err:)
|
|
53
|
+
raise Error, 'Unknown image command. Use --help.' unless %w[list stats width].include?(command)
|
|
54
|
+
options = { attributes: {}, exclude: [], ratio: 0.8, min: 40.0, max: 100.0 }
|
|
55
|
+
parser = OptionParser.new do |opts|
|
|
56
|
+
opts.banner = "Usage: asciidoc-pubkit image #{command} DOCUMENT.adoc [options]"
|
|
57
|
+
opts.on('--base-dir DIR', 'Local include and image boundary (default: document directory)') { |v| options[:base_dir] = v }
|
|
58
|
+
opts.on('-a', '--attribute NAME=VALUE', 'Asciidoctor attribute; repeat as needed') do |v|
|
|
59
|
+
key, value = v.split('=', 2)
|
|
60
|
+
raise Error, 'Attribute name cannot be empty.' if key.empty?
|
|
61
|
+
raise Error, 'Remote includes are not supported.' if key == 'allow-uri-read'
|
|
62
|
+
options[:attributes][key] = value || ''
|
|
63
|
+
end
|
|
64
|
+
opts.on('--only FILE', 'Select image references from one included source file') { |v| options[:only] = v }
|
|
65
|
+
opts.on('--exclude GLOB', 'Exclude image basename or document-relative path; repeatable') { |v| options[:exclude] << v }
|
|
66
|
+
opts.on('--include-artwork', 'Include block images matching default artwork exclusions') { options[:artwork] = true }
|
|
67
|
+
opts.on('--json', 'Print a structured report') { options[:json] = true }
|
|
68
|
+
if command == 'width'
|
|
69
|
+
opts.on('--height-width-ratio NUMBER', Float, 'Target image height / text width (default: 0.8)') { |v| options[:ratio] = v }
|
|
70
|
+
opts.on('--min-width PERCENT', Float, 'Minimum display width (default: 40)') { |v| options[:min] = v }
|
|
71
|
+
opts.on('--max-width PERCENT', Float, 'Maximum display width (default: 100)') { |v| options[:max] = v }
|
|
72
|
+
opts.on('--dry-run', 'Preview only (default)') { options[:dry_run] = true }
|
|
73
|
+
opts.on('--diff', 'Preview a unified source diff') { options[:diff] = true }
|
|
74
|
+
opts.on('--in-place', 'Explicitly update source image macros') { options[:in_place] = true }
|
|
75
|
+
end
|
|
76
|
+
opts.on('-h', '--help', 'Show command help') { options[:help] = true }
|
|
77
|
+
end
|
|
78
|
+
parser.parse!(args)
|
|
79
|
+
if options[:help]
|
|
80
|
+
out.puts parser
|
|
81
|
+
return 0
|
|
82
|
+
end
|
|
83
|
+
raise Error, 'Exactly one AsciiDoc document is required.' unless args.length == 1
|
|
84
|
+
raise Error, 'Expected an AsciiDoc document (.adoc or .asciidoc), not an image.' unless %w[.adoc .asciidoc].include?(File.extname(args.first).downcase)
|
|
85
|
+
if command == 'width'
|
|
86
|
+
unless [options[:ratio], options[:min], options[:max]].all?(&:finite?) &&
|
|
87
|
+
options[:ratio].positive? && options[:min].positive? && options[:min] <= options[:max] && options[:max] <= 100
|
|
88
|
+
raise Error, 'Require finite ratio > 0 and 0 < min-width <= max-width <= 100.'
|
|
89
|
+
end
|
|
90
|
+
raise Error, '--in-place cannot be combined with --dry-run or --diff.' if options[:in_place] && (options[:dry_run] || options[:diff])
|
|
91
|
+
raise Error, '--diff cannot be combined with --json.' if options[:diff] && options[:json]
|
|
92
|
+
end
|
|
93
|
+
tool = new(args.first, options, err)
|
|
94
|
+
report = command == 'stats' ? tool.stats : command == 'width' ? tool.width : tool.report
|
|
95
|
+
if options[:diff]
|
|
96
|
+
out.write(tool.diff)
|
|
97
|
+
elsif options[:json]
|
|
98
|
+
out.puts JSON.pretty_generate(report)
|
|
99
|
+
else
|
|
100
|
+
out.write(tool.format(command, report))
|
|
101
|
+
end
|
|
102
|
+
0
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def initialize(entry, options, err)
|
|
106
|
+
@options, @err = options, err
|
|
107
|
+
@entry = File.realpath(entry)
|
|
108
|
+
@root = File.realpath(options[:base_dir] || File.dirname(@entry))
|
|
109
|
+
@loader = SourceLoader.new(options, err)
|
|
110
|
+
@doc = @loader.load(entry)
|
|
111
|
+
@sources = @loader.sources
|
|
112
|
+
@only = options[:only] && File.realpath(options[:only])
|
|
113
|
+
raise Error, '--only must be a source included in the parsed document.' if @only && !@sources.key?(@only)
|
|
114
|
+
@images, @excluded, @references, @changes, @revised = {}, [], [], [], {}
|
|
115
|
+
covers = %w[front-cover-image back-cover-image title-logo-image].filter_map do |key|
|
|
116
|
+
value = @doc.attr(key)
|
|
117
|
+
next unless value && (match = value.match(/\Aimage:{1,2}([^\[]+)\[/))
|
|
118
|
+
resolve_image(match[1], @doc.attr('imagesdir', '')) unless remote?(match[1]) || remote?(@doc.attr('imagesdir', ''))
|
|
119
|
+
end
|
|
120
|
+
@doc.find_by(context: :image).each do |node|
|
|
121
|
+
target, directory = node.attr('target'), node.attr('imagesdir', '')
|
|
122
|
+
cursor = node.source_location
|
|
123
|
+
provenance = @loader.image_sources[node.attr(@loader.source_key)] || {}
|
|
124
|
+
reference = { 'file' => provenance['file'] || (cursor&.file && File.realpath(cursor.file)),
|
|
125
|
+
'line' => provenance['line'] || cursor&.lineno,
|
|
126
|
+
'target' => target, 'current_scaledwidth' => node.attr('scaledwidth'),
|
|
127
|
+
'mapped' => !provenance.empty? }
|
|
128
|
+
@references << reference
|
|
129
|
+
reason = if remote?(target) || remote?(directory)
|
|
130
|
+
'remote image'
|
|
131
|
+
elsif @only && reference['file'] != @only
|
|
132
|
+
'outside --only source'
|
|
133
|
+
end
|
|
134
|
+
unless reason
|
|
135
|
+
path = resolve_image(target, directory)
|
|
136
|
+
reference['image'] = path
|
|
137
|
+
relative = Pathname.new(path).relative_path_from(Pathname.new(@root)).to_s
|
|
138
|
+
if !options[:artwork] && (covers.include?(path) || ARTWORK.any? { |glob| File.fnmatch?(glob, File.basename(path)) })
|
|
139
|
+
reason = 'artwork'
|
|
140
|
+
elsif options[:exclude].any? { |glob| File.fnmatch?(glob, File.basename(path)) || File.fnmatch?(glob, relative, File::FNM_PATHNAME | File::FNM_EXTGLOB) }
|
|
141
|
+
reason = 'excluded by pattern'
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
if reason
|
|
145
|
+
reference['excluded'] = reason
|
|
146
|
+
@excluded << reference
|
|
147
|
+
next
|
|
148
|
+
end
|
|
149
|
+
path = reference.fetch('image')
|
|
150
|
+
raise Error, "Image does not exist: #{path}" unless File.file?(path)
|
|
151
|
+
real = File.realpath(path)
|
|
152
|
+
raise Error, "Image is outside the base directory: #{path}" unless inside?(real)
|
|
153
|
+
reference['image'] = real
|
|
154
|
+
image = @images[real] ||= inspect_image(real)
|
|
155
|
+
reference['editable'] = !!source_macro(reference)
|
|
156
|
+
image['references'] << reference
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def remote?(path)
|
|
161
|
+
Asciidoctor::Helpers.uriish?(path.to_s)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def inside?(path)
|
|
165
|
+
path.start_with?(@root.end_with?('/') ? @root : @root + '/')
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def resolve_image(target, directory)
|
|
169
|
+
path = File.expand_path(target, File.expand_path(directory, @root))
|
|
170
|
+
raise Error, "Image is outside the base directory: #{path}" unless inside?(path)
|
|
171
|
+
path
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def inspect_image(path)
|
|
175
|
+
command = executable?('magick') ? %w[magick identify] : ['identify']
|
|
176
|
+
stdout, stderr, status = Open3.capture3(*command, '-format', '%w %h\n', '--', path)
|
|
177
|
+
raise Error, "Cannot inspect image #{path}: #{stderr.strip}" unless status.success?
|
|
178
|
+
lines = stdout.lines
|
|
179
|
+
match = lines.length == 1 && lines.first.match(/\A([1-9][0-9]*) ([1-9][0-9]*)\s*\z/)
|
|
180
|
+
raise Error, "Unsupported image dimensions or multiple frames: #{path}" unless match
|
|
181
|
+
w, h = match[1].to_i, match[2].to_i
|
|
182
|
+
{ 'path' => path, 'width' => w, 'height' => h, 'aspect_ratio' => w.fdiv(h),
|
|
183
|
+
'bytes' => File.size(path), 'references' => [] }
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def executable?(name)
|
|
187
|
+
ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).any? { |dir| File.file?(path = File.join(dir, name)) && File.executable?(path) }
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def report
|
|
191
|
+
{ 'document' => @entry, 'base_dir' => @root, 'images' => @images.values,
|
|
192
|
+
'image_count' => @images.length, 'reference_count' => @images.values.sum { |i| i['references'].length },
|
|
193
|
+
'excluded' => @excluded, 'scope' => 'parsed block image macros; inline images are not included' }
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def stats
|
|
197
|
+
result = report.reject { |key, _| key == 'images' }
|
|
198
|
+
result['total_bytes'] = @images.values.sum { |i| i['bytes'] }
|
|
199
|
+
%w[width height aspect_ratio bytes].each do |key|
|
|
200
|
+
values = @images.values.map { |i| i[key] }
|
|
201
|
+
result[key] = { 'min' => values.min, 'max' => values.max,
|
|
202
|
+
'mean' => values.empty? ? nil : values.sum.fdiv(values.length) }
|
|
203
|
+
end
|
|
204
|
+
result
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def source_macro(reference)
|
|
208
|
+
file, line = reference.values_at('file', 'line')
|
|
209
|
+
return unless reference['mapped'] && file && line && @sources.key?(file)
|
|
210
|
+
@sources[file].lines[line - 1]&.match(MACRO)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Split only top-level attribute commas, retaining the original spelling.
|
|
214
|
+
def attributes(text)
|
|
215
|
+
parts, start, quote, index = [], 0, nil, 0
|
|
216
|
+
while index < text.length
|
|
217
|
+
char = text[index]
|
|
218
|
+
if char == '\\'
|
|
219
|
+
index += 2
|
|
220
|
+
next
|
|
221
|
+
elsif quote
|
|
222
|
+
quote = nil if char == quote
|
|
223
|
+
elsif (char == '"' || char == "'") && text[start...index].strip.match?(/\A(?:[^\s=,]+\s*=\s*)?\z/)
|
|
224
|
+
quote = char
|
|
225
|
+
elsif char == ','
|
|
226
|
+
parts << text[start...index]
|
|
227
|
+
start = index + 1
|
|
228
|
+
end
|
|
229
|
+
index += 1
|
|
230
|
+
end
|
|
231
|
+
raise Error, 'Unclosed quote in source image attributes.' if quote
|
|
232
|
+
parts << text[start..]
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def with_width(match, width)
|
|
236
|
+
parts = attributes(match[2])
|
|
237
|
+
positions = parts.each_index.select { |index| parts[index].match?(/\A\s*scaledwidth\s*=/) }
|
|
238
|
+
raise Error, 'Duplicate scaledwidth attributes are unsupported.' if positions.length > 1
|
|
239
|
+
value = "#{number(width)}%"
|
|
240
|
+
if positions.empty?
|
|
241
|
+
content = match[2].empty? ? "scaledwidth=#{value}" : "#{match[2]},scaledwidth=#{value}"
|
|
242
|
+
else
|
|
243
|
+
index = positions.first
|
|
244
|
+
token = parts[index].match(/\A(\s*scaledwidth\s*=\s*)(.*?)(\s*)\z/)
|
|
245
|
+
old = token[2]
|
|
246
|
+
value = "#{old[0]}#{value}#{old[0]}" if ['"', "'"].include?(old[0]) && old[-1] == old[0]
|
|
247
|
+
parts[index] = token[1] + value + token[3]
|
|
248
|
+
content = parts.join(',')
|
|
249
|
+
end
|
|
250
|
+
match[1] + content + match[3] + match[4].to_s
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def number(value)
|
|
254
|
+
value.to_s.delete_suffix('.0')
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def width
|
|
258
|
+
desired = {}
|
|
259
|
+
@images.each_value do |image|
|
|
260
|
+
raw = 100 * @options[:ratio] * image['aspect_ratio']
|
|
261
|
+
value = [[[[raw, @options[:min]].max, @options[:max]].min.round(1), @options[:min]].max, @options[:max]].min
|
|
262
|
+
image['width_percent'], image['minimum_limited'] = value, raw < @options[:min]
|
|
263
|
+
image['references'].each do |reference|
|
|
264
|
+
match = source_macro(reference)
|
|
265
|
+
raise Error, "Cannot safely map image macro: #{reference['file']}:#{reference['line']}" unless match
|
|
266
|
+
before = match[0]
|
|
267
|
+
after = with_width(match, value)
|
|
268
|
+
file, line = reference.values_at('file', 'line')
|
|
269
|
+
key = [file, line]
|
|
270
|
+
prior = desired[key]
|
|
271
|
+
raise Error, "Reused source image needs conflicting widths: #{file}:#{line}" if prior && prior != after
|
|
272
|
+
desired[key] = after
|
|
273
|
+
next if prior || before == after
|
|
274
|
+
if @excluded.any? { |r| r['file'] == file && r['line'] == line }
|
|
275
|
+
raise Error, "Reused source also has excluded references: #{file}:#{line}"
|
|
276
|
+
end
|
|
277
|
+
@changes << { 'file' => file, 'line' => line, 'image' => image['path'],
|
|
278
|
+
'width_percent' => value, 'before' => before, 'after' => after }
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
@changes.group_by { |c| c['file'] }.each do |file, changes|
|
|
282
|
+
lines = @sources.fetch(file).lines
|
|
283
|
+
changes.each { |c| lines[c['line'] - 1] = c['after'] }
|
|
284
|
+
@revised[file] = lines.join
|
|
285
|
+
end
|
|
286
|
+
apply if @options[:in_place]
|
|
287
|
+
report.merge('settings' => { 'height_width_ratio' => @options[:ratio], 'min_width' => @options[:min], 'max_width' => @options[:max] },
|
|
288
|
+
'changes' => @changes, 'changed_files' => @revised.keys, 'applied' => !!@options[:in_place])
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def unchanged?(file, content)
|
|
292
|
+
File.file?(file) && !File.symlink?(file) && File.realpath(file) == file && File.binread(file) == content.b
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def apply
|
|
296
|
+
staged, backups, installed = {}, {}, []
|
|
297
|
+
begin
|
|
298
|
+
@sources.each do |file, content|
|
|
299
|
+
raise Error, "Source changed during analysis: #{file}" unless unchanged?(file, content)
|
|
300
|
+
end
|
|
301
|
+
@revised.each do |file, content|
|
|
302
|
+
raise Error, "Source changed during analysis: #{file}" unless unchanged?(file, @sources.fetch(file))
|
|
303
|
+
staged[file] = stage(file, content)
|
|
304
|
+
backups[file] = stage(file, @sources.fetch(file))
|
|
305
|
+
end
|
|
306
|
+
@revised.each_key do |file|
|
|
307
|
+
raise Error, "Source changed during analysis: #{file}" unless unchanged?(file, @sources.fetch(file))
|
|
308
|
+
File.rename(staged.fetch(file).path, file)
|
|
309
|
+
installed << file
|
|
310
|
+
end
|
|
311
|
+
rescue StandardError
|
|
312
|
+
installed.reverse_each do |file|
|
|
313
|
+
# Do not replace another writer's changes while rolling back.
|
|
314
|
+
if File.binread(file) == @revised.fetch(file).b
|
|
315
|
+
File.rename(backups.fetch(file).path, file)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
raise
|
|
319
|
+
ensure
|
|
320
|
+
(staged.values + backups.values).each(&:close!)
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def stage(file, content)
|
|
325
|
+
temp = Tempfile.new(['.pubkit-image-', '.adoc'], File.dirname(file))
|
|
326
|
+
temp.binmode
|
|
327
|
+
temp.write(content)
|
|
328
|
+
temp.flush
|
|
329
|
+
temp.chmod(File.stat(file).mode & 0o777)
|
|
330
|
+
temp
|
|
331
|
+
rescue StandardError
|
|
332
|
+
temp&.close!
|
|
333
|
+
raise
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def diff
|
|
337
|
+
@revised.map do |file, content|
|
|
338
|
+
relative = Pathname.new(file).relative_path_from(Pathname.new(@root)).to_s
|
|
339
|
+
Tempfile.create('pubkit-before') do |a|
|
|
340
|
+
Tempfile.create('pubkit-after') do |b|
|
|
341
|
+
a.write(@sources.fetch(file)); a.flush
|
|
342
|
+
b.write(content); b.flush
|
|
343
|
+
stdout, stderr, status = Open3.capture3('diff', '-u', '--label', "a/#{relative}", '--label', "b/#{relative}", a.path, b.path)
|
|
344
|
+
raise Error, stderr unless [0, 1].include?(status.exitstatus)
|
|
345
|
+
stdout
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end.join
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def format(command, result)
|
|
352
|
+
if command == 'stats'
|
|
353
|
+
"Images: #{result['image_count']}; references: #{result['reference_count']}; bytes: #{result['total_bytes']}\n" +
|
|
354
|
+
%w[width height aspect_ratio bytes].map { |key| "#{key}: #{result[key].to_json}\n" }.join
|
|
355
|
+
else
|
|
356
|
+
result['images'].map do |image|
|
|
357
|
+
"#{image['path']}\t#{image['width']}x#{image['height']}\taspect=#{image['aspect_ratio'].round(4)}\tbytes=#{image['bytes']}\treferences=#{image['references'].length}" +
|
|
358
|
+
(command == 'width' ? "\twidth=#{number(image['width_percent'])}%" : '') + "\n"
|
|
359
|
+
end.join + "Images: #{result['image_count']}; references: #{result['reference_count']}; excluded: #{@excluded.length}" +
|
|
360
|
+
(command == 'width' ? "; changes: #{@changes.length}; #{result['applied'] ? 'applied' : 'preview'}" : '') + "\n"
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|
data/lib/asciidoc_pubkit.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'pathname'
|
|
|
9
9
|
require 'optparse'
|
|
10
10
|
|
|
11
11
|
module AsciidocPubkit
|
|
12
|
-
VERSION = '1.
|
|
12
|
+
VERSION = '1.4.0'
|
|
13
13
|
class Error < StandardError; end
|
|
14
14
|
|
|
15
15
|
def self.hash_text(text)
|
|
@@ -40,4 +40,5 @@ require_relative 'asciidoc_pubkit/score'
|
|
|
40
40
|
require_relative 'asciidoc_pubkit/replacement'
|
|
41
41
|
require_relative 'asciidoc_pubkit/document_commands'
|
|
42
42
|
require_relative 'asciidoc_pubkit/skill_commands'
|
|
43
|
+
require_relative 'asciidoc_pubkit/image_commands'
|
|
43
44
|
require_relative 'asciidoc_pubkit/cli'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asciidoc-pubkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CyberGarage
|
|
@@ -37,11 +37,11 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '1.0'
|
|
40
|
-
description: Inspect
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
replacements.
|
|
40
|
+
description: Inspect document-referenced images and explicitly set source image display
|
|
41
|
+
widths, inspect AsciiDoc outlines, book metadata, and local cross-references, generate
|
|
42
|
+
English document-title indexes, and generate Japanese and English technical writing
|
|
43
|
+
prompts, review AsciiDoc prose, section headings, and list text separately, verify
|
|
44
|
+
protected manuscript content, and explicitly apply prose-only mechanical replacements.
|
|
45
45
|
executables:
|
|
46
46
|
- asciidoc-pubkit
|
|
47
47
|
extensions: []
|
|
@@ -70,6 +70,7 @@ files:
|
|
|
70
70
|
- docs/english-review-research.md
|
|
71
71
|
- docs/english-review.md
|
|
72
72
|
- docs/explanatory-guidance-research.md
|
|
73
|
+
- docs/image-commands.md
|
|
73
74
|
- docs/installation.md
|
|
74
75
|
- docs/list-review.md
|
|
75
76
|
- docs/outline-review.md
|
|
@@ -93,6 +94,7 @@ files:
|
|
|
93
94
|
- lib/asciidoc_pubkit/document_commands.rb
|
|
94
95
|
- lib/asciidoc_pubkit/english.rb
|
|
95
96
|
- lib/asciidoc_pubkit/heading_rules.rb
|
|
97
|
+
- lib/asciidoc_pubkit/image_commands.rb
|
|
96
98
|
- lib/asciidoc_pubkit/japanese_verification.rb
|
|
97
99
|
- lib/asciidoc_pubkit/language.rb
|
|
98
100
|
- lib/asciidoc_pubkit/local_evaluator.rb
|
|
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
127
|
- !ruby/object:Gem::Version
|
|
126
128
|
version: '0'
|
|
127
129
|
requirements: []
|
|
128
|
-
rubygems_version: 4.0.
|
|
130
|
+
rubygems_version: 4.0.23
|
|
129
131
|
specification_version: 4
|
|
130
132
|
summary: Document inspection, replacement, and Japanese/English review tools for AsciiDoc
|
|
131
133
|
books
|