md-tech-pdf 0.1.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/LICENSE +176 -0
- package/README.ja.md +330 -0
- package/README.md +315 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +96 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/config-resolver.d.ts +19 -0
- package/dist/config/config-resolver.d.ts.map +1 -0
- package/dist/config/config-resolver.js +41 -0
- package/dist/config/config-resolver.js.map +1 -0
- package/dist/config/document-options.d.ts +52 -0
- package/dist/config/document-options.d.ts.map +1 -0
- package/dist/config/document-options.js +8 -0
- package/dist/config/document-options.js.map +1 -0
- package/dist/config/error.d.ts +12 -0
- package/dist/config/error.d.ts.map +1 -0
- package/dist/config/error.js +12 -0
- package/dist/config/error.js.map +1 -0
- package/dist/config/frontmatter-parser.d.ts +16 -0
- package/dist/config/frontmatter-parser.d.ts.map +1 -0
- package/dist/config/frontmatter-parser.js +271 -0
- package/dist/config/frontmatter-parser.js.map +1 -0
- package/dist/core/converter.d.ts +34 -0
- package/dist/core/converter.d.ts.map +1 -0
- package/dist/core/converter.js +109 -0
- package/dist/core/converter.js.map +1 -0
- package/dist/html/default-style.d.ts +6 -0
- package/dist/html/default-style.d.ts.map +1 -0
- package/dist/html/default-style.js +237 -0
- package/dist/html/default-style.js.map +1 -0
- package/dist/html/google-fonts.d.ts +20 -0
- package/dist/html/google-fonts.d.ts.map +1 -0
- package/dist/html/google-fonts.js +50 -0
- package/dist/html/google-fonts.js.map +1 -0
- package/dist/html/html-builder.d.ts +20 -0
- package/dist/html/html-builder.d.ts.map +1 -0
- package/dist/html/html-builder.js +88 -0
- package/dist/html/html-builder.js.map +1 -0
- package/dist/html/html-renderer.d.ts +25 -0
- package/dist/html/html-renderer.d.ts.map +1 -0
- package/dist/html/html-renderer.js +148 -0
- package/dist/html/html-renderer.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/attributes-parser.d.ts +13 -0
- package/dist/parser/attributes-parser.d.ts.map +1 -0
- package/dist/parser/attributes-parser.js +110 -0
- package/dist/parser/attributes-parser.js.map +1 -0
- package/dist/parser/error.d.ts +15 -0
- package/dist/parser/error.d.ts.map +1 -0
- package/dist/parser/error.js +15 -0
- package/dist/parser/error.js.map +1 -0
- package/dist/parser/markdown-parser.d.ts +17 -0
- package/dist/parser/markdown-parser.d.ts.map +1 -0
- package/dist/parser/markdown-parser.js +86 -0
- package/dist/parser/markdown-parser.js.map +1 -0
- package/dist/pdf/default-options.d.ts +6 -0
- package/dist/pdf/default-options.d.ts.map +1 -0
- package/dist/pdf/default-options.js +12 -0
- package/dist/pdf/default-options.js.map +1 -0
- package/dist/pdf/error.d.ts +9 -0
- package/dist/pdf/error.d.ts.map +1 -0
- package/dist/pdf/error.js +10 -0
- package/dist/pdf/error.js.map +1 -0
- package/dist/pdf/pdf-generator.d.ts +16 -0
- package/dist/pdf/pdf-generator.d.ts.map +1 -0
- package/dist/pdf/pdf-generator.js +95 -0
- package/dist/pdf/pdf-generator.js.map +1 -0
- package/dist/pdf/types.d.ts +16 -0
- package/dist/pdf/types.d.ts.map +1 -0
- package/dist/pdf/types.js +2 -0
- package/dist/pdf/types.js.map +1 -0
- package/dist/renderer/diagram-renderer.d.ts +11 -0
- package/dist/renderer/diagram-renderer.d.ts.map +1 -0
- package/dist/renderer/diagram-renderer.js +2 -0
- package/dist/renderer/diagram-renderer.js.map +1 -0
- package/dist/renderer/error.d.ts +10 -0
- package/dist/renderer/error.d.ts.map +1 -0
- package/dist/renderer/error.js +10 -0
- package/dist/renderer/error.js.map +1 -0
- package/dist/renderer/mermaid-executor.d.ts +16 -0
- package/dist/renderer/mermaid-executor.d.ts.map +1 -0
- package/dist/renderer/mermaid-executor.js +99 -0
- package/dist/renderer/mermaid-executor.js.map +1 -0
- package/dist/renderer/mermaid-renderer.d.ts +25 -0
- package/dist/renderer/mermaid-renderer.d.ts.map +1 -0
- package/dist/renderer/mermaid-renderer.js +35 -0
- package/dist/renderer/mermaid-renderer.js.map +1 -0
- package/dist/renderer/plantuml-executor.d.ts +11 -0
- package/dist/renderer/plantuml-executor.d.ts.map +1 -0
- package/dist/renderer/plantuml-executor.js +100 -0
- package/dist/renderer/plantuml-executor.js.map +1 -0
- package/dist/renderer/plantuml-renderer.d.ts +26 -0
- package/dist/renderer/plantuml-renderer.d.ts.map +1 -0
- package/dist/renderer/plantuml-renderer.js +95 -0
- package/dist/renderer/plantuml-renderer.js.map +1 -0
- package/dist/types/diagram.d.ts +34 -0
- package/dist/types/diagram.d.ts.map +1 -0
- package/dist/types/diagram.js +2 -0
- package/dist/types/diagram.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or exemplary damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# md-tech-pdf
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 日本語
|
|
4
|
+
|
|
5
|
+
Markdownで作成した技術文書を、高品質なPDFへ変換するオープンソースツールです。
|
|
6
|
+
|
|
7
|
+
一般的なMarkdown PDF変換ツールとの差別化として、MermaidやPlantUMLなどのダイアグラム・図表をPDF向けに美しく、かつ柔軟にレイアウト・配置できることを目指しています。
|
|
8
|
+
|
|
9
|
+
将来的にはVSCode Extensionとしての提供も予定していますが、PDF生成コアロジックはCLIや特定のエディタ環境に依存しない独立した「Coreライブラリ」として設計されています。
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 主な特徴
|
|
14
|
+
|
|
15
|
+
- **Markdown → 高品質ベクターPDF**: Playwright Chromiumベースの高精度なレンダリングエンジン。
|
|
16
|
+
- **Mermaid & PlantUML 対応**: フローチャート、シーケンス図、クラス図などを鮮明なベクターSVGとして埋め込み。
|
|
17
|
+
- **柔軟なダイアグラム配置**: `width`, `height`, `fit` (contain / fill), `align` (left / center / right) による精密なサイズ・位置制御。
|
|
18
|
+
- **YAML Front Matter**: 用紙サイズ(A4)、向き(縦/横)、余白(margin)、フォント等をドキュメント単位で一括定義。
|
|
19
|
+
- **フォントカスタマイズ**: OSインストール済みのローカルフォントおよび Google Fonts のWebフォントを個別指定可能。
|
|
20
|
+
- **印刷品質のレイアウト制御**: 見出しの孤立抑止(Orphan Heading対策)、超長行コードブロックの自動折り返し、多列テーブルの可読性最適化。
|
|
21
|
+
- **使いやすいCLI**: 出力先指定、自動ディレクトリ作成、ヘルプ・バージョン表示をサポート。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 前提環境 (Requirements)
|
|
26
|
+
|
|
27
|
+
- **Node.js**: >= 20.0.0
|
|
28
|
+
- **Playwright / Chromium**: PDFレンダリングに必要です(依存関係に含まれます)。
|
|
29
|
+
- **Java ランタイム & PlantUML jar**: PlantUMLダイアグラムを描画する場合のみ必要です(Mermaidのみを使用する場合はJavaは不要です)。
|
|
30
|
+
- **インターネット接続**: Google Fontsを利用する場合のみ必要です(オフライン時はシステムフォントへ自動フォールバックします)。
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## インストール
|
|
35
|
+
|
|
36
|
+
グローバルインストールしてCLIコマンドとして利用できます。
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# npm を使用する場合
|
|
40
|
+
npm install -g md-tech-pdf
|
|
41
|
+
|
|
42
|
+
# pnpm を使用する場合
|
|
43
|
+
pnpm add -g md-tech-pdf
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
また、インストールせずに `npx` で即座に実行することも可能です。
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx md-tech-pdf document.md -o output.pdf
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## クイックスタート & CLIの使い方
|
|
55
|
+
|
|
56
|
+
### 基本コマンド
|
|
57
|
+
|
|
58
|
+
Markdownファイルを指定してPDFへ変換します。
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# 入力ファイルと同じディレクトリに document.pdf を生成
|
|
62
|
+
md-tech-pdf document.md
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 出力先パスの指定
|
|
66
|
+
|
|
67
|
+
`-o` または `--output` オプションで出力先PDFのファイルパスを指定できます。
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
md-tech-pdf document.md -o output.pdf
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
出力先ディレクトリが存在しない場合は、自動的に作成されます。
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
md-tech-pdf docs/architecture.md -o build/architecture.pdf
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ヘルプ・バージョン表示
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# ヘルプの表示
|
|
83
|
+
md-tech-pdf --help
|
|
84
|
+
md-tech-pdf -h
|
|
85
|
+
|
|
86
|
+
# バージョンの表示
|
|
87
|
+
md-tech-pdf --version
|
|
88
|
+
md-tech-pdf -v
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ドキュメント設定とダイアグラム記述例
|
|
94
|
+
|
|
95
|
+
### YAML Front Matter設定
|
|
96
|
+
|
|
97
|
+
Markdownファイルの先頭にFront Matterを記述することで、文書全体のPDF余白や図の規定サイズを設定できます。
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
---
|
|
101
|
+
pdf:
|
|
102
|
+
format: A4
|
|
103
|
+
landscape: false
|
|
104
|
+
margin:
|
|
105
|
+
top: 20mm
|
|
106
|
+
right: 20mm
|
|
107
|
+
bottom: 20mm
|
|
108
|
+
left: 20mm
|
|
109
|
+
|
|
110
|
+
diagram:
|
|
111
|
+
width: 120mm
|
|
112
|
+
height: 70mm
|
|
113
|
+
fit: contain
|
|
114
|
+
align: center
|
|
115
|
+
|
|
116
|
+
style:
|
|
117
|
+
font:
|
|
118
|
+
family: 'Noto Sans JP'
|
|
119
|
+
codeFamily: 'Roboto Mono'
|
|
120
|
+
google:
|
|
121
|
+
families:
|
|
122
|
+
- name: 'Noto Sans JP'
|
|
123
|
+
weights: [400, 500, 700]
|
|
124
|
+
- name: 'Roboto Mono'
|
|
125
|
+
weights: [400, 700]
|
|
126
|
+
---
|
|
127
|
+
# システム構成書
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### ダイアグラムの配置オプション
|
|
131
|
+
|
|
132
|
+
MermaidおよびPlantUMLブロックでは、中括弧 `{}` を用いて図ごとの属性を指定できます。指定可能な属性は以下の通りです。
|
|
133
|
+
|
|
134
|
+
- `width`: 幅の指定(単位: `mm`, `cm`, `in`, `px`, `pt`, `%`)
|
|
135
|
+
- `height`: 高さの指定(単位: `mm`, `cm`, `in`, `px`, `pt`, `%`)
|
|
136
|
+
- `fit`: リサイズ時の挙動(`contain`: アスペクト比を維持して収める / `fill`: 指定枠いっぱいに拡大縮小)
|
|
137
|
+
- `align`: 配置位置(`left` / `center` / `right`)
|
|
138
|
+
|
|
139
|
+
### Mermaidダイアグラム
|
|
140
|
+
|
|
141
|
+
フェンスブロックで `mermaid` を指定します。レンダリングは高解像度なベクターSVGとして行われ、PDF拡大時も線が劣化しません。
|
|
142
|
+
|
|
143
|
+
````markdown
|
|
144
|
+
```mermaid {width=140mm align=center}
|
|
145
|
+
graph TD
|
|
146
|
+
Client[クライアント] --> API[APIサーバー]
|
|
147
|
+
API --> DB[(データベース)]
|
|
148
|
+
```
|
|
149
|
+
````
|
|
150
|
+
|
|
151
|
+
### PlantUMLダイアグラム
|
|
152
|
+
|
|
153
|
+
フェンスブロックで `plantuml` を指定します。ローカルマシン上でJavaプロセスを直接起動してベクターSVGを生成するため、外部のPlantUMLサーバーへ社内機密情報や設計図が送信される心配はありません。
|
|
154
|
+
|
|
155
|
+
````markdown
|
|
156
|
+
```plantuml {width=100mm align=center}
|
|
157
|
+
@startuml
|
|
158
|
+
actor User
|
|
159
|
+
participant Server
|
|
160
|
+
User -> Server: リクエスト送信
|
|
161
|
+
Server --> User: レスポンス返却
|
|
162
|
+
@enduml
|
|
163
|
+
```
|
|
164
|
+
````
|
|
165
|
+
|
|
166
|
+
> **注意 (PlantUMLの前提要件)**:
|
|
167
|
+
> PlantUMLの描画には、ローカル環境に **Javaランタイム** および **PlantUMLのjarファイル** がインストールされている必要があります(Mermaidのみを使用する場合はJavaは不要です)。
|
|
168
|
+
> 必要に応じて、Front Matterでjavaおよびjarのパスを明示指定できます。
|
|
169
|
+
>
|
|
170
|
+
> ```yaml
|
|
171
|
+
> plantuml:
|
|
172
|
+
> javaPath: '/usr/bin/java'
|
|
173
|
+
> jarPath: '/path/to/plantuml.jar'
|
|
174
|
+
> ```
|
|
175
|
+
|
|
176
|
+
### フォント設定 (style.font)
|
|
177
|
+
|
|
178
|
+
文書の本文フォント(`family`)およびコードブロックフォント(`codeFamily`)を指定できます。
|
|
179
|
+
|
|
180
|
+
#### 1. ローカルフォントの指定
|
|
181
|
+
|
|
182
|
+
OSにインストールされているフォントを指定します。外部通信を行わずに高速かつオフラインで利用できます(実行環境に対象フォントがインストールされている必要があります)。
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
style:
|
|
186
|
+
font:
|
|
187
|
+
family: 'Hiragino Sans'
|
|
188
|
+
codeFamily: 'Menlo'
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- 本文フォントのフォールバックとして自動的に `sans-serif` が付与されます。
|
|
192
|
+
- コード用フォント(`code`, `pre`)のフォールバックとして自動的に `monospace` が付与されます。
|
|
193
|
+
|
|
194
|
+
#### 2. Google Fonts の指定
|
|
195
|
+
|
|
196
|
+
Google Fonts CSS2 APIを利用してWebフォントを読み込み、本文およびコードフォントとして適用します(生成時に外部ネットワークアクセスが必要です)。
|
|
197
|
+
|
|
198
|
+
```yaml
|
|
199
|
+
style:
|
|
200
|
+
font:
|
|
201
|
+
family: 'Noto Sans JP'
|
|
202
|
+
codeFamily: 'Roboto Mono'
|
|
203
|
+
google:
|
|
204
|
+
families:
|
|
205
|
+
- name: 'Noto Sans JP'
|
|
206
|
+
weights: [400, 500, 700]
|
|
207
|
+
- name: 'Roboto Mono'
|
|
208
|
+
weights: [400, 700]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
- `weights` には `100, 200, 300, 400, 500, 600, 700, 800, 900` の標準weightを指定できます。
|
|
212
|
+
- PDF生成時は `document.fonts.ready` によりWebフォントのロード完了を待機してからレンダリングが行われます。
|
|
213
|
+
- オフライン時や通信障害時はタイムアウト後にフォールバックフォントを用いてPDF生成を継続します。
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## アーキテクチャ概要
|
|
218
|
+
|
|
219
|
+
本プロジェクトは関心事の分離を重視し、UI層(CLI、将来のエディタ拡張)とコアエンジン層を明確に分離しています。
|
|
220
|
+
|
|
221
|
+
### レイヤー構造
|
|
222
|
+
|
|
223
|
+
```text
|
|
224
|
+
+---------------------------------------+
|
|
225
|
+
| Client Layer |
|
|
226
|
+
| +----------------+ +---------------+ |
|
|
227
|
+
| | CLI | | VSCode Ext | |
|
|
228
|
+
| | (src/cli) | | (Future) | |
|
|
229
|
+
| +-------+--------+ +-------+-------+ |
|
|
230
|
+
+----------|------------------|---------+
|
|
231
|
+
| (thin wrapper) |
|
|
232
|
+
v v
|
|
233
|
+
+---------------------------------------+
|
|
234
|
+
| Core Layer |
|
|
235
|
+
| (src/index.ts) |
|
|
236
|
+
| - Markdown Parser |
|
|
237
|
+
| - Diagram Engine (Mermaid/PlantUML) |
|
|
238
|
+
| - Layout Engine & PDF Generator |
|
|
239
|
+
+---------------------------------------+
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
- **CLI (`src/cli/index.ts`)**: コマンドライン引数のパースとCore APIの呼び出しのみを担当します。PDF生成ロジックは記述しません。
|
|
243
|
+
- **Core (`src/index.ts`)**: ドキュメント解析、図のレンダリング、レイアウト調整、PDF出力など、すべての生成ロジックを集約する独立ライブラリです。
|
|
244
|
+
|
|
245
|
+
### ディレクトリ構成
|
|
246
|
+
|
|
247
|
+
```text
|
|
248
|
+
md-tech-pdf/
|
|
249
|
+
├── .github/ # GitHub Actionsワークフローおよびテンプレート
|
|
250
|
+
├── docs/ # 設計資料・ドキュメント
|
|
251
|
+
├── examples/ # サンプルMarkdown文書・設定例
|
|
252
|
+
├── generated/ # 生成時の一時ファイル・出力先(.gitignore対象)
|
|
253
|
+
├── src/ # ソースコード
|
|
254
|
+
│ ├── cli/ # CLIエントリーポイント
|
|
255
|
+
│ └── index.ts # Coreライブラリ エントリーポイント
|
|
256
|
+
├── test/ # テストコード
|
|
257
|
+
├── CHANGELOG.md # リリース履歴
|
|
258
|
+
├── CODE_OF_CONDUCT.md# 行動規範
|
|
259
|
+
├── CONTRIBUTING.md # コントリビューションガイド
|
|
260
|
+
├── LICENSE # Apache-2.0 ライセンス
|
|
261
|
+
├── README.md # 英語版README
|
|
262
|
+
├── README.ja.md # 日本語版README
|
|
263
|
+
├── package.json # プロジェクト定義・依存関係
|
|
264
|
+
├── tsconfig.json # TypeScriptコンパイラ設定
|
|
265
|
+
└── vitest.config.ts # Vitestテストフレームワーク設定
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 開発方法
|
|
271
|
+
|
|
272
|
+
### 前提環境
|
|
273
|
+
|
|
274
|
+
- Node.js >= 20.0.0
|
|
275
|
+
- pnpm >= 9.0.0
|
|
276
|
+
|
|
277
|
+
### セットアップ
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# 依存関係のインストール
|
|
281
|
+
pnpm install
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### スクリプト一覧
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# TypeScriptのビルド (dist/ へ出力)
|
|
288
|
+
pnpm build
|
|
289
|
+
|
|
290
|
+
# Vitestによるユニットテストの実行
|
|
291
|
+
pnpm test
|
|
292
|
+
|
|
293
|
+
# ESLintによる静的解析
|
|
294
|
+
pnpm lint
|
|
295
|
+
|
|
296
|
+
# Prettierによるコードフォーマットチェック
|
|
297
|
+
pnpm format:check
|
|
298
|
+
|
|
299
|
+
# Prettierによるコード整形
|
|
300
|
+
pnpm format
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 既知の制約事項 (Known Limitations)
|
|
306
|
+
|
|
307
|
+
v0.1.0 リリース時点で把握されている仕様および制約事項です。
|
|
308
|
+
|
|
309
|
+
1. **ページまたぎテーブルでのヘッダー再描画 (`<thead>`)**: 行数の多い表が改ページされる際、2ページ目以降の先頭にテーブルヘッダーは自動再描画されません(実用上のデータ読解は可能です)。
|
|
310
|
+
2. **縦長ダイアグラム直前の余白**: 高さが150mmを超える縦長ダイアグラムは、途中で切断されるのを防ぐ安全策(`break-inside: avoid`)により次ページに送られるため、前ページ下部に空白が生じる場合があります。
|
|
311
|
+
3. **PlantUMLの前提環境**: PlantUMLの描画にはローカルのJavaランタイムおよびPlantUML jarが必要です(Mermaidのみ使用する場合は不要です)。
|
|
312
|
+
4. **Google Fontsのネットワーク要件**: Google Fontsの読み込みにはPDF生成時にインターネット接続が必要です(オフライン時や障害時はシステムフォントへ自動フォールバックします)。
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 変更履歴 (Changelog)
|
|
317
|
+
|
|
318
|
+
各バージョンの詳細な変更内容については [CHANGELOG.md](./CHANGELOG.md) をご覧ください。
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## コントリビューション (Contributing)
|
|
323
|
+
|
|
324
|
+
バグ報告や機能提案、プルリクエストを歓迎します。開発への参加方法やガイドラインについては [CONTRIBUTING.md](./CONTRIBUTING.md) をご確認ください。また、コミュニティ参加にあたっては [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) の遵守をお願いいたします。
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## ライセンス (License)
|
|
329
|
+
|
|
330
|
+
本プロジェクトは [Apache License 2.0](./LICENSE) のもとで公開されています。
|