Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.4.01085.8 KB2026-10-160.3.21087.6 KB2026-10-160.3.11087.5 KB2026-10-160.3.0117.8 KB2026-10-160.2.1106.1 KB2026-10-150.2.0105.5 KB2026-10-15
Version
0.3.0
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-10-16
Size
117.8 KB
Downloads
24
Checksum
91f9899559d38e059baa788310473f349f3d218d16f6afbd045fc9d087ba00c3
Dependencies
rust/[email protected]
rust/[email protected]

serve.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hongo</title>
<style>
body {
	margin: 0;
	padding: 40px 32px 64px;
	color: #1f1f1f;
	background: #fff;
	font-family: system-ui, -apple-system, sans-serif;
	font-size: 14px;
	line-height: 1.9;
}

.page {
	max-width: 1440px;
	margin: 0 auto;
}

[hidden] {
	display: none !important;
}

h1 {
	font-size: 19px;
	font-weight: 500;
	margin: 0 0 6px;
}

.note {
	color: #767676;
	font-size: 13px;
	margin: 0 0 28px;
}

.split {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 28px;
	align-items: start;
}

.source {
	display: block;
	width: 100%;
	height: 62vh;
	min-height: 380px;
	box-sizing: border-box;
	padding: 14px 16px;
	color: #1f1f1f;
	background: #fff;
	border: 1px solid #dcdcdc;
	border-radius: 3px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
	line-height: 1.75;
	resize: vertical;
}

.source:focus {
	outline: none;
	border-color: #1f1f1f;
}

.bar {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 14px;
}

button {
	padding: 9px 18px;
	color: #fff;
	background: #1f1f1f;
	border: 0;
	border-radius: 3px;
	font-family: inherit;
	font-size: 13px;
	cursor: pointer;
}

button.quiet {
	color: #1f1f1f;
	background: #efefef;
}

button:disabled {
	opacity: 0.4;
	cursor: default;
}

.state {
	color: #767676;
	font-size: 12px;
}

.wrong {
	margin: 14px 0 0;
	padding: 12px 14px;
	color: #a33;
	background: #fcf4f4;
	border-radius: 3px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
	line-height: 1.7;
	white-space: pre-wrap;
	word-break: break-all;
}

.view {
	display: block;
	width: 100%;
	height: 62vh;
	min-height: 380px;
	background: #f4f4f4;
	border: 0;
	border-radius: 3px;
}

.empty {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 62vh;
	min-height: 380px;
	color: #767676;
	background: #f4f4f4;
	border-radius: 3px;
	font-size: 13px;
}

.link {
	display: flex;
	gap: 20px;
	margin-top: 14px;
}

.save {
	color: #1f1f1f;
	font-size: 13px;
}

@media (max-width: 900px) {
	.split {
		grid-template-columns: 1fr;
	}
}
</style>
</head>
<body>
<div class="page">
	<h1>hongo</h1>
	<p class="note">LaTeX の原稿を貼って押すと PDF になります。組むのは Rust の hongo で、TeX は使いません。</p>
	<div class="split">
		<div>
			<textarea id="source" class="source" spellcheck="false"></textarea>
			<div class="bar">
				<button id="convert" type="button">PDF にする</button>
				<button id="reset" class="quiet" type="button">見本に戻す</button>
				<span id="state" class="state"></span>
			</div>
			<pre id="wrong" class="wrong" hidden></pre>
		</div>
		<div>
			<div id="empty" class="empty">ここに出来上がりが出ます</div>
			<iframe id="view" class="view" title="出来上がり" hidden></iframe>
			<div class="link">
				<a id="save" class="save" download="hongo.pdf" hidden>PDF を保存する</a>
				<a id="open" class="save" target="_blank" rel="noopener" hidden>別のタブで開く</a>
			</div>
		</div>
	</div>
</div>
<script>
	const source = document.getElementById('source')
	const convert = document.getElementById('convert')
	const reset = document.getElementById('reset')
	const state = document.getElementById('state')
	const wrong = document.getElementById('wrong')
	const view = document.getElementById('view')
	const empty = document.getElementById('empty')
	const save = document.getElementById('save')
	const open = document.getElementById('open')
	let address = ''

	async function loadSample() {
		const answer = await fetch('/sample')
		source.value = await answer.text()
	}

	async function make() {
		convert.disabled = true
		state.textContent = '組んでいます'
		wrong.hidden = true

		try {
			const answer = await fetch('/pdf', {method: 'POST', body: source.value})

			if (!answer.ok) {
				wrong.textContent = await answer.text()
				wrong.hidden = false
				state.textContent = ''

				return
			}

			const data = await answer.blob()

			if (address) {
				URL.revokeObjectURL(address)
			}

			address = URL.createObjectURL(data)
			view.src = address
			view.hidden = false
			empty.hidden = true
			save.href = address
			save.hidden = false
			open.href = address
			open.hidden = false

			const page = answer.headers.get('X-Page') || '?'
			const missing = decodeURIComponent(answer.headers.get('X-Missing') || '')
			const size = Math.round(data.size / 1024)
			state.textContent = missing
				? page + ' ページ / ' + size + ' キロバイト - 書体にない字: ' + missing
				: page + ' ページ / ' + size + ' キロバイト'

		} catch (reason) {
			wrong.textContent = String(reason)
			wrong.hidden = false
			state.textContent = ''

		} finally {
			convert.disabled = false
		}
	}

	convert.addEventListener('click', make)
	reset.addEventListener('click', loadSample)
	source.addEventListener('keydown', (event) => {
		if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
			make()
		}
	})

	loadSample().then(make)
</script>
</body>
</html>