@unana_dev/doxen 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -218,7 +218,7 @@ guide/
218
218
  └── 01-config.md
219
219
  ```
220
220
 
221
- - 하위 폴더는 탐색 목록에 **경로 형태로** 표시됩니다.
221
+ - 하위 폴더는 탐색 목록에 **경로 형태로** 표시됩니다. 폴더의 `.xlsx` 파일도 목록에서 열어 시트별 셀 값을 확인하고 원본을 다운로드할 수 있습니다. 수식은 저장된 결과값을 표시하며 서식과 차트는 표시하지 않습니다.
222
222
  - 숨김 파일(`.`으로 시작), `node_modules`, 심볼릭 링크 문서는 **제외**됩니다.
223
223
 
224
224
  > ⚠️ **보안 메모**
@@ -234,7 +234,7 @@ guide/
234
234
  - Mermaid 코드 블록(`mermaid`): 시퀀스·흐름도 등을 다이어그램으로 표시합니다. 언어 지정 없이 `sequenceDiagram`으로 시작하는 코드 블록도 지원합니다. 문법 오류가 있으면 안내와 원본 코드를 표시합니다.
235
235
  - 다른 문서로의 상대 링크 (`[설치 방법](./02-installation.md)`)
236
236
  - 한국어 제목 앵커 (`#설치-방법`)
237
- - 이미지·PDF 첨부: PNG / JPEG / GIF / WebP / AVIF / ICO / PDF
237
+ - 이미지·파일 첨부: PNG / JPEG / GIF / WebP / AVIF / ICO / PDF / XLSX
238
238
 
239
239
  ### 지원하지 않는 것 ❌
240
240
 
package/client/app.js CHANGED
@@ -189,6 +189,397 @@ function renderFolder(folderPath) {
189
189
  window.scrollTo(0, 0);
190
190
  }
191
191
 
192
+ const columnLetter = (index) => {
193
+ let name = "";
194
+ for (let n = index + 1; n > 0; n = Math.floor((n - 1) / 26))
195
+ name = String.fromCharCode(65 + ((n - 1) % 26)) + name;
196
+ return name;
197
+ };
198
+ const ROW_HEAD = 46;
199
+ const COL_HEAD = 26;
200
+
201
+ function prepareSheet(sheet) {
202
+ const source = Array.isArray(sheet.data) ? sheet.data : [];
203
+ const columns = Math.max(1, ...source.map((row) => row.length));
204
+ const rows = (source.length ? source : [[]]).map((row) =>
205
+ Array.from({ length: columns }, (_, c) => row[c] ?? null),
206
+ );
207
+ const widths = Array.from({ length: columns }, (_, c) => {
208
+ let longest = 0;
209
+ for (const row of rows.slice(0, 200)) {
210
+ for (const line of String(row[c] ?? "").split("\n")) {
211
+ let width = 0;
212
+ for (const char of line) width += /[\u1100-\u11ff\u2e80-\ua4cf\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/.test(char) ? 14 : 8;
213
+ longest = Math.max(longest, width);
214
+ }
215
+ }
216
+ return Math.min(340, Math.max(72, longest + 24));
217
+ });
218
+ return { name: String(sheet.sheet ?? ""), rows, widths };
219
+ }
220
+
221
+ function spreadsheetViewer(doc, rawSheets) {
222
+ const sheets = (rawSheets.length ? rawSheets : [{ sheet: "Sheet1", data: [] }]).map(prepareSheet);
223
+ const selection = sheets.map((sheet) => ({ r: sheet.rows.length > 1 ? 1 : 0, c: 0 }));
224
+ const state = { sheet: 0, wrap: false, full: false, query: "", matches: [], matchIndex: -1, expanded: null };
225
+ const button = (text, className, title) => {
226
+ const node = el("button", text, className);
227
+ node.type = "button";
228
+ if (title) node.title = title;
229
+ return node;
230
+ };
231
+
232
+ const viewer = el("div", undefined, "sheet-viewer");
233
+ const toolbar = el("div", undefined, "sheet-toolbar");
234
+ const finder = el("label", undefined, "sheet-find");
235
+ const findInput = el("input");
236
+ findInput.type = "search";
237
+ findInput.placeholder = "시트에서 찾기 (Enter: 다음)";
238
+ findInput.setAttribute("aria-label", "시트에서 찾기");
239
+ const matchLabel = el("span", "", "sheet-find-count");
240
+ matchLabel.setAttribute("aria-live", "polite");
241
+ finder.append(el("span", undefined, "sheet-find-icon"), findInput, matchLabel);
242
+ const wrapButton = button("텍스트 줄바꿈", "sheet-button");
243
+ wrapButton.setAttribute("aria-pressed", "false");
244
+ const fullButton = button(undefined, "sheet-full-button", "펼치기");
245
+ fullButton.setAttribute("aria-label", "펼치기");
246
+ fullButton.setAttribute("aria-pressed", "false");
247
+ fullButton.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3h7v7M21 3l-7 7M10 21H3v-7M3 21l7-7"/></svg>';
248
+ const download = el("a", "다운로드", "sheet-download");
249
+ download.href = doc.spreadsheet.file;
250
+ download.download = doc.title;
251
+ download.setAttribute("aria-label", "엑셀 파일 다운로드");
252
+ toolbar.append(fullButton, finder, el("span", undefined, "sheet-spacer"), wrapButton, download);
253
+
254
+ const formula = el("div", undefined, "sheet-formula");
255
+ const nameBox = el("div", "", "sheet-name-box");
256
+ const formulaValue = el("div", "", "sheet-formula-value");
257
+ formula.append(nameBox, el("div", "fx", "sheet-fx"), formulaValue);
258
+
259
+ const grid = el("div", undefined, "sheet-grid spreadsheet-table");
260
+ grid.tabIndex = 0;
261
+ grid.setAttribute("role", "grid");
262
+ grid.setAttribute("aria-label", `${doc.title} 시트`);
263
+
264
+ const footer = el("div", undefined, "sheet-footer");
265
+ const arrows = el("div", undefined, "sheet-arrows");
266
+ const prev = button("‹", "sheet-arrow", "이전 시트 (Ctrl+PgUp)");
267
+ const next = button("›", "sheet-arrow", "다음 시트 (Ctrl+PgDn)");
268
+ prev.setAttribute("aria-label", "이전 시트");
269
+ next.setAttribute("aria-label", "다음 시트");
270
+ arrows.append(prev, next);
271
+ const tabs = el("div", undefined, "sheet-tabs");
272
+ tabs.setAttribute("role", "tablist");
273
+ tabs.setAttribute("aria-label", "시트 선택");
274
+ const status = el("div", undefined, "sheet-status");
275
+ const statusMessage = el("span", "");
276
+ statusMessage.setAttribute("aria-live", "polite");
277
+ const dims = el("span", "");
278
+ status.append(statusMessage, dims);
279
+ footer.append(arrows, tabs, status);
280
+ viewer.append(toolbar, formula, grid, footer);
281
+
282
+ const tabButtons = sheets.map((sheet, i) => {
283
+ const tab = button(undefined, "sheet-tab");
284
+ tab.setAttribute("role", "tab");
285
+ tab.append(el("span", sheet.name), el("span", String(Math.max(0, sheet.rows.length - 1)), "sheet-tab-count"));
286
+ tab.onclick = () => goSheet(i);
287
+ tabs.append(tab);
288
+ return tab;
289
+ });
290
+
291
+ let cells = [];
292
+ let colHeads = [];
293
+ let rowHeads = [];
294
+ let cols = [];
295
+ let table;
296
+
297
+ const cellValue = (r, c) => {
298
+ const value = sheets[state.sheet].rows[r]?.[c];
299
+ return value == null ? "" : String(value);
300
+ };
301
+
302
+ function updateFormula() {
303
+ const { r, c } = selection[state.sheet];
304
+ nameBox.textContent = `${columnLetter(c)}${r + 1}`;
305
+ formulaValue.textContent = cellValue(r, c) || " ";
306
+ }
307
+
308
+ function scrollToCell({ r, c }) {
309
+ const cell = cells[r]?.[c];
310
+ if (!cell) return;
311
+ const top = COL_HEAD + (r > 0 ? cells[0][0].offsetHeight : 0);
312
+ if (cell.offsetLeft - ROW_HEAD < grid.scrollLeft) grid.scrollLeft = cell.offsetLeft - ROW_HEAD;
313
+ else if (cell.offsetLeft + cell.offsetWidth > grid.scrollLeft + grid.clientWidth)
314
+ grid.scrollLeft = cell.offsetLeft + cell.offsetWidth - grid.clientWidth;
315
+ if (r === 0) return;
316
+ if (cell.offsetTop - top < grid.scrollTop) grid.scrollTop = cell.offsetTop - top;
317
+ else if (cell.offsetTop + cell.offsetHeight > grid.scrollTop + grid.clientHeight)
318
+ grid.scrollTop = cell.offsetTop + cell.offsetHeight - grid.clientHeight;
319
+ }
320
+
321
+ function mark(on) {
322
+ const { r, c } = selection[state.sheet];
323
+ cells[r]?.[c]?.classList.toggle("is-selected", on);
324
+ cells[r]?.[c]?.setAttribute("aria-selected", String(on));
325
+ colHeads[c]?.classList.toggle("is-active", on);
326
+ rowHeads[r]?.classList.toggle("is-active", on);
327
+ }
328
+
329
+ function select(r, c, { scroll = true } = {}) {
330
+ mark(false);
331
+ if (state.expanded) {
332
+ cells[state.expanded.r]?.[state.expanded.c]?.classList.remove("is-expanded");
333
+ state.expanded = null;
334
+ }
335
+ selection[state.sheet] = { r, c };
336
+ mark(true);
337
+ statusMessage.textContent = "";
338
+ updateFormula();
339
+ if (scroll) scrollToCell({ r, c });
340
+ }
341
+
342
+ function paintMatches() {
343
+ for (const row of cells) for (const cell of row) cell.classList.remove("is-match", "is-current-match");
344
+ const query = state.query.trim().toLocaleLowerCase();
345
+ state.matches = [];
346
+ if (query) {
347
+ for (const [r, row] of sheets[state.sheet].rows.entries())
348
+ for (const [c, value] of row.entries())
349
+ if (String(value ?? "").toLocaleLowerCase().includes(query)) {
350
+ state.matches.push({ r, c });
351
+ cells[r][c].classList.add("is-match");
352
+ }
353
+ }
354
+ const current = state.matches[state.matchIndex];
355
+ if (current) cells[current.r][current.c].classList.add("is-current-match");
356
+ matchLabel.textContent = query
357
+ ? state.matches.length
358
+ ? `${state.matchIndex >= 0 ? state.matchIndex + 1 : 0}/${state.matches.length}`
359
+ : "0건"
360
+ : "";
361
+ }
362
+
363
+ function buildGrid() {
364
+ const sheet = sheets[state.sheet];
365
+ table = el("table");
366
+ const colgroup = el("colgroup");
367
+ colgroup.append(Object.assign(el("col"), { style: `width:${ROW_HEAD}px` }));
368
+ cols = sheet.widths.map((width) => {
369
+ const col = el("col");
370
+ col.style.width = `${width}px`;
371
+ colgroup.append(col);
372
+ return col;
373
+ });
374
+ const head = el("thead");
375
+ const headRow = el("tr");
376
+ headRow.append(el("th", "", "sheet-corner"));
377
+ colHeads = sheet.widths.map((_, c) => {
378
+ const th = el("th", columnLetter(c), "sheet-col-head");
379
+ th.scope = "col";
380
+ const handle = el("span", undefined, "sheet-resize");
381
+ handle.setAttribute("aria-hidden", "true");
382
+ handle.onpointerdown = (event) => startResize(event, c);
383
+ th.append(handle);
384
+ headRow.append(th);
385
+ return th;
386
+ });
387
+ head.append(headRow);
388
+ const body = el("tbody");
389
+ rowHeads = [];
390
+ cells = sheet.rows.map((row, r) => {
391
+ const tr = el("tr");
392
+ const number = el("th", String(r + 1), "sheet-row-head");
393
+ number.scope = "row";
394
+ rowHeads.push(number);
395
+ tr.append(number);
396
+ const rowCells = row.map((value, c) => {
397
+ const td = el("td");
398
+ td.dataset.cell = `${r}-${c}`;
399
+ td.setAttribute("role", "gridcell");
400
+ if (typeof value === "number") td.classList.add("is-number");
401
+ td.append(el("div", value == null ? "" : String(value)));
402
+ tr.append(td);
403
+ return td;
404
+ });
405
+ if (r === 0) tr.classList.add("sheet-header-row");
406
+ body.append(tr);
407
+ return rowCells;
408
+ });
409
+ table.append(colgroup, head, body);
410
+ updateWidth();
411
+ grid.replaceChildren(table);
412
+ grid.scrollTop = 0;
413
+ grid.scrollLeft = 0;
414
+ mark(true);
415
+ updateFormula();
416
+ paintMatches();
417
+ dims.textContent = `${Math.max(0, sheet.rows.length - 1)}행 × ${sheet.widths.length}열`;
418
+ for (const [i, tab] of tabButtons.entries()) {
419
+ tab.classList.toggle("is-active", i === state.sheet);
420
+ tab.setAttribute("aria-selected", String(i === state.sheet));
421
+ }
422
+ tabButtons[state.sheet]?.scrollIntoView({ block: "nearest", inline: "nearest" });
423
+ }
424
+
425
+ function updateWidth() {
426
+ table.style.width = `${ROW_HEAD + sheets[state.sheet].widths.reduce((a, b) => a + b, 0)}px`;
427
+ }
428
+
429
+ function startResize(event, c) {
430
+ event.preventDefault();
431
+ event.stopPropagation();
432
+ const widths = sheets[state.sheet].widths;
433
+ const x0 = event.clientX;
434
+ const w0 = widths[c];
435
+ const move = (moveEvent) => {
436
+ widths[c] = Math.max(40, Math.round(w0 + moveEvent.clientX - x0));
437
+ cols[c].style.width = `${widths[c]}px`;
438
+ updateWidth();
439
+ };
440
+ const up = () => {
441
+ window.removeEventListener("pointermove", move);
442
+ window.removeEventListener("pointerup", up);
443
+ viewer.classList.remove("is-resizing");
444
+ };
445
+ viewer.classList.add("is-resizing");
446
+ window.addEventListener("pointermove", move);
447
+ window.addEventListener("pointerup", up);
448
+ }
449
+
450
+ function goSheet(index) {
451
+ state.sheet = (index + sheets.length) % sheets.length;
452
+ state.matchIndex = -1;
453
+ state.expanded = null;
454
+ statusMessage.textContent = "";
455
+ buildGrid();
456
+ }
457
+
458
+ function setFull(full) {
459
+ state.full = full;
460
+ viewer.classList.toggle("is-full", full);
461
+ document.body.classList.toggle("sheet-fullscreen", full);
462
+ const label = full ? "좁히기" : "펼치기";
463
+ fullButton.title = label;
464
+ fullButton.setAttribute("aria-label", label);
465
+ fullButton.querySelector("path").setAttribute("d", full
466
+ ? "M14 4v6h6M14 10l7-7M10 20v-6H4M10 14l-7 7"
467
+ : "M14 3h7v7M21 3l-7 7M10 21H3v-7M3 21l7-7");
468
+ fullButton.setAttribute("aria-pressed", String(full));
469
+ }
470
+
471
+ grid.addEventListener("pointerdown", (event) => {
472
+ const cell = event.target.closest("td[data-cell]");
473
+ if (!cell) return;
474
+ const [r, c] = cell.dataset.cell.split("-").map(Number);
475
+ select(r, c, { scroll: false });
476
+ setTimeout(() => grid.focus({ preventScroll: true }));
477
+ });
478
+ grid.addEventListener("dblclick", (event) => {
479
+ const cell = event.target.closest("td[data-cell]");
480
+ if (!cell) return;
481
+ const [r, c] = cell.dataset.cell.split("-").map(Number);
482
+ const same = state.expanded?.r === r && state.expanded?.c === c;
483
+ if (state.expanded) cells[state.expanded.r][state.expanded.c].classList.remove("is-expanded");
484
+ state.expanded = same ? null : { r, c };
485
+ cell.classList.toggle("is-expanded", !same);
486
+ });
487
+ grid.addEventListener("keydown", (event) => {
488
+ const rows = sheets[state.sheet].rows;
489
+ const { r, c } = selection[state.sheet];
490
+ const lastRow = rows.length - 1;
491
+ const lastCol = rows[0].length - 1;
492
+ const mod = event.metaKey || event.ctrlKey;
493
+ if (mod && (event.key === "PageUp" || event.key === "PageDown")) {
494
+ event.preventDefault();
495
+ goSheet(state.sheet + (event.key === "PageUp" ? -1 : 1));
496
+ return;
497
+ }
498
+ if (mod && event.key.toLowerCase() === "c" && !getSelection()?.toString()) {
499
+ event.preventDefault();
500
+ navigator.clipboard?.writeText(cellValue(r, c)).then(
501
+ () => (statusMessage.textContent = `${columnLetter(c)}${r + 1} 복사됨`),
502
+ () => (statusMessage.textContent = "복사하지 못했습니다"),
503
+ );
504
+ return;
505
+ }
506
+ if (event.key === "Escape" && state.full) {
507
+ event.preventDefault();
508
+ setFull(false);
509
+ return;
510
+ }
511
+ const move = {
512
+ ArrowUp: [-1, 0],
513
+ ArrowDown: [1, 0],
514
+ ArrowLeft: [0, -1],
515
+ ArrowRight: [0, 1],
516
+ Enter: [event.shiftKey ? -1 : 1, 0],
517
+ Tab: [0, event.shiftKey ? -1 : 1],
518
+ }[event.key];
519
+ const clamp = (value, max) => Math.min(max, Math.max(0, value));
520
+ if (move) {
521
+ event.preventDefault();
522
+ const nr = mod && move[0] ? (move[0] > 0 ? lastRow : 0) : clamp(r + move[0], lastRow);
523
+ const nc = mod && move[1] ? (move[1] > 0 ? lastCol : 0) : clamp(c + move[1], lastCol);
524
+ select(nr, nc);
525
+ } else if (event.key === "Home") {
526
+ event.preventDefault();
527
+ select(mod ? 0 : r, 0);
528
+ } else if (event.key === "End") {
529
+ event.preventDefault();
530
+ select(mod ? lastRow : r, lastCol);
531
+ }
532
+ });
533
+ findInput.addEventListener("input", () => {
534
+ state.query = findInput.value;
535
+ state.matchIndex = -1;
536
+ paintMatches();
537
+ });
538
+ findInput.addEventListener("keydown", (event) => {
539
+ if (event.key === "Escape" && state.full) return setFull(false);
540
+ if (event.key !== "Enter" || !state.matches.length) return;
541
+ event.preventDefault();
542
+ const count = state.matches.length;
543
+ state.matchIndex = (state.matchIndex + (event.shiftKey ? -1 : 1) + count) % count;
544
+ paintMatches();
545
+ const { r, c } = state.matches[state.matchIndex];
546
+ select(r, c);
547
+ });
548
+ wrapButton.onclick = () => {
549
+ state.wrap = !state.wrap;
550
+ viewer.classList.toggle("is-wrapped", state.wrap);
551
+ wrapButton.setAttribute("aria-pressed", String(state.wrap));
552
+ };
553
+ fullButton.onclick = () => setFull(!state.full);
554
+ prev.onclick = () => goSheet(state.sheet - 1);
555
+ next.onclick = () => goSheet(state.sheet + 1);
556
+
557
+ buildGrid();
558
+ return viewer;
559
+ }
560
+
561
+ async function renderSpreadsheet(doc) {
562
+ const article = $("#article");
563
+ const content = el("p", "엑셀 파일을 불러오는 중입니다.", "sheet-message");
564
+ article.replaceChildren(el("h1", doc.title), content);
565
+ try {
566
+ const response = await fetch(doc.spreadsheet.data);
567
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
568
+ const sheets = await response.json();
569
+ if (current !== doc) return;
570
+ content.replaceWith(
571
+ spreadsheetViewer(doc, sheets),
572
+ el(
573
+ "p",
574
+ "방향키로 셀 이동 · 더블클릭 또는 줄바꿈으로 전체 내용 보기 · 열 경계 드래그로 너비 조절 · Ctrl+C 셀 복사",
575
+ "sheet-hint",
576
+ ),
577
+ );
578
+ } catch {
579
+ if (current === doc) content.textContent = "엑셀 파일을 불러오지 못했습니다.";
580
+ }
581
+ }
582
+
192
583
  function render() {
193
584
  let id, anchor;
194
585
  try {
@@ -209,6 +600,8 @@ function render() {
209
600
  const isFolder = folderPath && site.documents.some(
210
601
  (doc) => doc.tab === activeTab && doc.path.startsWith(folderPath),
211
602
  );
603
+ document.body.classList.toggle("is-spreadsheet", Boolean(current?.spreadsheet));
604
+ document.body.classList.remove("sheet-fullscreen");
212
605
  renderNavigation(isFolder ? folderPath : null);
213
606
  $("#toc").replaceChildren();
214
607
  $("#pagination").replaceChildren();
@@ -239,6 +632,13 @@ function render() {
239
632
  title: current.path.split("/").at(-1).replace(/\.md$/i, ""),
240
633
  id: current.id,
241
634
  });
635
+ if (current.spreadsheet) {
636
+ $(".toc").hidden = true;
637
+ $("#pagination").hidden = true;
638
+ renderSpreadsheet(current);
639
+ window.scrollTo(0, 0);
640
+ return;
641
+ }
242
642
  $("#article").innerHTML = current.html;
243
643
  if (!$("#article h1")) $("#article").prepend(el("h1", current.title));
244
644
  for (const heading of $("#article").querySelectorAll("h2, h3, h4, h5, h6")) {
package/client/style.css CHANGED
@@ -243,18 +243,18 @@ main {
243
243
  }
244
244
  article {
245
245
  font-size: 16px;
246
- line-height: 1.6;
246
+ line-height: 1.625;
247
247
  font-weight: 400;
248
- letter-spacing: -0.2px;
248
+ letter-spacing: normal;
249
+ color: #1c1d1e;
249
250
  overflow-wrap: anywhere;
250
251
  }
251
252
  article h1 {
252
- font-size: 32px;
253
- letter-spacing: -0.8px;
254
- line-height: 1.4;
255
- margin: 12px 0 24px;
256
- color: #1e2023;
257
- font-weight: 650;
253
+ font-size: 36px;
254
+ letter-spacing: -0.025em;
255
+ line-height: 1.25;
256
+ margin: 0 0 24px;
257
+ font-weight: 700;
258
258
  }
259
259
  article strong {
260
260
  font-weight: 600;
@@ -294,17 +294,28 @@ article strong {
294
294
  display: none;
295
295
  }
296
296
  article h2 {
297
- font-size: 28px;
298
- letter-spacing: -0.6px;
299
- margin: 44px 0 20px;
300
- line-height: 1.5;
301
- font-weight: 500;
297
+ font-size: 30px;
298
+ letter-spacing: -0.0125em;
299
+ margin: 20px 0;
300
+ padding-top: 1em;
301
+ line-height: 1.2;
302
+ font-weight: 600;
302
303
  }
303
304
  article h3 {
305
+ font-size: 24px;
306
+ letter-spacing: -0.0125em;
307
+ line-height: 1.333333;
308
+ font-weight: 600;
309
+ margin: 20px 0;
310
+ padding-top: 0.75em;
311
+ }
312
+ article h4 {
304
313
  font-size: 20px;
305
- line-height: 1.5;
314
+ letter-spacing: -0.0125em;
315
+ line-height: 1.4;
306
316
  font-weight: 600;
307
- margin: 28px 0 20px;
317
+ margin: 20px 0;
318
+ padding-top: 0.5em;
308
319
  }
309
320
  article :is(h1, h2, h3, h4, h5, h6) {
310
321
  scroll-margin-top: 24px;
@@ -326,32 +337,62 @@ article hr:has(+ .document-version) {
326
337
  display: none;
327
338
  }
328
339
  article p {
329
- color: #4b5055;
330
- margin: 16px 0;
340
+ margin: 20px 0;
331
341
  }
332
342
  article blockquote {
333
343
  margin: 20px 0;
334
344
  padding: 12px 24px;
335
345
  border-left: 2px solid var(--accent-border, #d6dfe6);
336
- color: #727b85;
346
+ color: #686f74;
337
347
  }
338
348
  article blockquote p {
339
349
  margin: 0;
340
- color: #727b85;
350
+ }
351
+ article blockquote > * + * {
352
+ margin-top: 16px;
341
353
  }
342
354
  article hr {
343
355
  border: 0;
344
356
  border-top: 1px solid var(--line);
345
- margin: 20px 0 28px;
357
+ margin: 20px 0;
346
358
  }
347
359
  article ul,
348
360
  article ol {
349
361
  padding-left: 24px;
350
- color: #4b5055;
362
+ margin: 20px 0;
363
+ }
364
+ article li {
365
+ padding-left: 4px;
366
+ line-height: 1.5;
367
+ }
368
+ article li::marker {
369
+ color: #686f74;
351
370
  }
352
371
  article li + li {
353
372
  margin-top: 8px;
354
373
  }
374
+ article li > p {
375
+ margin: 0;
376
+ }
377
+ article li > :is(ul, ol) {
378
+ margin: 8px 0 0;
379
+ }
380
+ article li > :not(:first-child) {
381
+ margin-top: 8px;
382
+ }
383
+ article ul {
384
+ list-style-type: disc;
385
+ }
386
+ article ul ul {
387
+ list-style-type: circle;
388
+ }
389
+ article ol ol {
390
+ list-style-type: lower-alpha;
391
+ }
392
+ article a:not(.folder-cards a) {
393
+ text-decoration: underline;
394
+ text-underline-offset: 2px;
395
+ }
355
396
  article pre {
356
397
  overflow: auto;
357
398
  padding: 18px;
@@ -373,6 +414,417 @@ article pre code {
373
414
  border: 0;
374
415
  background: none;
375
416
  }
417
+ @media (min-width: 1201px) {
418
+ body.is-spreadsheet .layout {
419
+ grid-template-columns: 288px minmax(0, 1fr);
420
+ }
421
+ }
422
+ body.is-spreadsheet .toc {
423
+ display: none;
424
+ }
425
+ body.sheet-fullscreen {
426
+ overflow: hidden;
427
+ }
428
+ .sheet-viewer {
429
+ --sheet-accent: var(--accent, #009dff);
430
+ --sheet-soft: color-mix(in srgb, var(--sheet-accent) 7%, white);
431
+ --sheet-active: color-mix(in srgb, var(--sheet-accent) 22%, white);
432
+ --sheet-match: color-mix(in srgb, var(--sheet-accent) 14%, white);
433
+ --sheet-current: color-mix(in srgb, var(--sheet-accent) 45%, white);
434
+ --sheet-ink: color-mix(in srgb, var(--sheet-accent) 55%, #1c1d1e);
435
+ --sheet-head: #f3f4f5;
436
+ --sheet-grid: #ebedef;
437
+ --sheet-rule: #d9dcdf;
438
+ position: relative;
439
+ display: flex;
440
+ flex-direction: column;
441
+ height: clamp(420px, calc(100vh - 220px), 860px);
442
+ border: 1px solid #dcdfe2;
443
+ border-radius: 8px;
444
+ background: #fff;
445
+ overflow: hidden;
446
+ font-size: 13px;
447
+ line-height: 1.5;
448
+ overflow-wrap: normal;
449
+ }
450
+ .sheet-viewer.is-full {
451
+ position: fixed;
452
+ inset: 0;
453
+ z-index: 100;
454
+ height: 100vh;
455
+ border-radius: 0;
456
+ border: 0;
457
+ }
458
+ .sheet-viewer.is-resizing {
459
+ cursor: col-resize;
460
+ user-select: none;
461
+ }
462
+ .sheet-toolbar {
463
+ display: flex;
464
+ flex-wrap: wrap;
465
+ align-items: center;
466
+ gap: 8px;
467
+ padding: 8px 10px;
468
+ border-bottom: 1px solid #e6e8ea;
469
+ background: #fafbfb;
470
+ }
471
+ .sheet-full-button {
472
+ display: inline-flex;
473
+ align-items: center;
474
+ justify-content: center;
475
+ flex: 0 0 32px;
476
+ width: 32px;
477
+ height: 32px;
478
+ padding: 0;
479
+ border: 0;
480
+ background: transparent;
481
+ color: #555;
482
+ cursor: pointer;
483
+ }
484
+ .sheet-full-button svg {
485
+ width: 18px;
486
+ height: 18px;
487
+ }
488
+ .sheet-find {
489
+ display: flex;
490
+ align-items: center;
491
+ gap: 8px;
492
+ flex: 0 1 260px;
493
+ min-width: 180px;
494
+ height: 32px;
495
+ padding: 0 10px;
496
+ border: 1px solid #dee1e4;
497
+ border-radius: 6px;
498
+ background: #fff;
499
+ }
500
+ .sheet-find:focus-within {
501
+ border-color: var(--accent-border, #76caff);
502
+ }
503
+ .sheet-find-icon {
504
+ width: 11px;
505
+ height: 11px;
506
+ flex-shrink: 0;
507
+ border: 1.5px solid #999;
508
+ border-radius: 50%;
509
+ }
510
+ .sheet-find input {
511
+ flex: 1;
512
+ min-width: 0;
513
+ padding: 0;
514
+ border: 0;
515
+ border-radius: 0;
516
+ outline: 0;
517
+ background: transparent;
518
+ font-size: 13px;
519
+ }
520
+ .sheet-find-count {
521
+ font-size: 12px;
522
+ color: #888;
523
+ white-space: nowrap;
524
+ }
525
+ .sheet-spacer {
526
+ flex: 1;
527
+ }
528
+ .sheet-button,
529
+ .sheet-download {
530
+ display: inline-flex;
531
+ align-items: center;
532
+ height: 32px;
533
+ padding: 0 12px;
534
+ border: 1px solid #dee1e4;
535
+ border-radius: 6px;
536
+ background: #fff;
537
+ color: #1f2124;
538
+ font-size: 13px;
539
+ white-space: nowrap;
540
+ }
541
+ .sheet-button[aria-pressed="true"] {
542
+ background: var(--sheet-soft);
543
+ border-color: var(--sheet-accent);
544
+ color: var(--sheet-ink);
545
+ }
546
+ .sheet-download {
547
+ padding: 0 14px;
548
+ border-color: var(--sheet-accent);
549
+ background: var(--sheet-accent);
550
+ color: #fff;
551
+ font-weight: 500;
552
+ }
553
+ .sheet-download,
554
+ .sheet-download:hover {
555
+ text-decoration: none;
556
+ }
557
+ .sheet-download:hover {
558
+ filter: brightness(0.94);
559
+ }
560
+ .sheet-formula {
561
+ display: flex;
562
+ align-items: stretch;
563
+ min-height: 34px;
564
+ border-bottom: 1px solid #e6e8ea;
565
+ }
566
+ .sheet-name-box,
567
+ .sheet-fx {
568
+ display: flex;
569
+ align-items: center;
570
+ justify-content: center;
571
+ flex-shrink: 0;
572
+ border-right: 1px solid #e6e8ea;
573
+ }
574
+ .sheet-name-box {
575
+ width: 72px;
576
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
577
+ font-size: 12px;
578
+ color: #333;
579
+ }
580
+ .sheet-fx {
581
+ width: 36px;
582
+ color: #aaa;
583
+ font-family: Georgia, serif;
584
+ font-style: italic;
585
+ }
586
+ .sheet-formula-value {
587
+ flex: 1;
588
+ min-width: 0;
589
+ max-height: 110px;
590
+ padding: 8px 12px;
591
+ overflow: auto;
592
+ white-space: pre-wrap;
593
+ overflow-wrap: anywhere;
594
+ line-height: 1.55;
595
+ color: #222;
596
+ }
597
+ .sheet-grid {
598
+ position: relative;
599
+ flex: 1;
600
+ min-height: 0;
601
+ overflow: auto;
602
+ outline: none;
603
+ background: #fff;
604
+ }
605
+ .sheet-grid:focus-visible {
606
+ box-shadow: inset 0 0 0 2px var(--accent-border, #76caff);
607
+ }
608
+ article .sheet-grid table {
609
+ width: auto;
610
+ margin: 0;
611
+ border-collapse: separate;
612
+ border-spacing: 0;
613
+ table-layout: fixed;
614
+ font-size: 13.5px;
615
+ line-height: 1.5;
616
+ }
617
+ article .sheet-grid :is(th, td) {
618
+ border: 0;
619
+ border-radius: 0;
620
+ overflow-wrap: normal;
621
+ }
622
+ article .sheet-grid th:first-child,
623
+ article .sheet-grid th:last-child {
624
+ border-radius: 0;
625
+ }
626
+ article .sheet-grid thead th {
627
+ position: sticky;
628
+ top: 0;
629
+ z-index: 3;
630
+ height: 26px;
631
+ padding: 0;
632
+ background: var(--sheet-head);
633
+ color: #666;
634
+ font-size: 12px;
635
+ font-weight: 500;
636
+ text-align: center;
637
+ border-right: 1px solid var(--sheet-rule);
638
+ border-bottom: 1px solid var(--sheet-rule);
639
+ user-select: none;
640
+ }
641
+ article .sheet-grid thead .sheet-corner {
642
+ left: 0;
643
+ z-index: 5;
644
+ }
645
+ article .sheet-grid .sheet-row-head {
646
+ position: sticky;
647
+ left: 0;
648
+ z-index: 2;
649
+ padding: 8px 0 0;
650
+ background: var(--sheet-head);
651
+ color: #777;
652
+ font-size: 12px;
653
+ font-weight: 400;
654
+ text-align: center;
655
+ vertical-align: top;
656
+ border-right: 1px solid var(--sheet-rule);
657
+ border-bottom: 1px solid #e4e6e8;
658
+ user-select: none;
659
+ }
660
+ article .sheet-grid :is(.sheet-col-head, .sheet-row-head).is-active {
661
+ background: var(--sheet-active);
662
+ color: var(--sheet-ink);
663
+ font-weight: 700;
664
+ }
665
+ .sheet-resize {
666
+ position: absolute;
667
+ top: 0;
668
+ right: -4px;
669
+ bottom: 0;
670
+ z-index: 2;
671
+ width: 8px;
672
+ cursor: col-resize;
673
+ touch-action: none;
674
+ }
675
+ .sheet-resize:hover {
676
+ background: color-mix(in srgb, var(--sheet-accent) 35%, transparent);
677
+ }
678
+ article .sheet-grid td {
679
+ padding: 8px 10px;
680
+ vertical-align: top;
681
+ text-align: left;
682
+ background: #fff;
683
+ border-right: 1px solid var(--sheet-grid);
684
+ border-bottom: 1px solid var(--sheet-grid);
685
+ cursor: cell;
686
+ }
687
+ article .sheet-grid td > div {
688
+ overflow: hidden;
689
+ text-overflow: ellipsis;
690
+ white-space: nowrap;
691
+ word-break: keep-all;
692
+ overflow-wrap: anywhere;
693
+ }
694
+ .sheet-viewer.is-wrapped .sheet-grid td > div,
695
+ article .sheet-grid td.is-expanded > div {
696
+ white-space: pre-wrap;
697
+ }
698
+ article .sheet-grid td.is-number {
699
+ text-align: right;
700
+ font-variant-numeric: tabular-nums;
701
+ }
702
+ article .sheet-grid .sheet-header-row > * {
703
+ position: sticky;
704
+ top: 26px;
705
+ z-index: 1;
706
+ font-weight: 700;
707
+ background: #fafbfb;
708
+ border-bottom: 2px solid #d0d4d8;
709
+ }
710
+ article .sheet-grid .sheet-header-row > .sheet-row-head {
711
+ z-index: 4;
712
+ font-weight: 400;
713
+ background: var(--sheet-head);
714
+ }
715
+ article .sheet-grid .sheet-header-row > .sheet-row-head.is-active {
716
+ font-weight: 700;
717
+ background: var(--sheet-active);
718
+ }
719
+ article .sheet-grid td.is-selected {
720
+ position: relative;
721
+ z-index: 1;
722
+ background: var(--sheet-soft);
723
+ box-shadow: inset 0 0 0 2px var(--sheet-accent);
724
+ }
725
+ article .sheet-grid .sheet-header-row > td.is-selected {
726
+ position: sticky;
727
+ z-index: 2;
728
+ }
729
+ article .sheet-grid td.is-match {
730
+ background: var(--sheet-match);
731
+ }
732
+ article .sheet-grid td.is-current-match {
733
+ background: var(--sheet-current);
734
+ }
735
+ .sheet-footer {
736
+ display: flex;
737
+ align-items: stretch;
738
+ height: 36px;
739
+ flex-shrink: 0;
740
+ border-top: 1px solid #dcdfe2;
741
+ background: var(--sheet-head);
742
+ }
743
+ .sheet-arrows {
744
+ display: flex;
745
+ align-items: center;
746
+ gap: 2px;
747
+ padding: 0 6px;
748
+ border-right: 1px solid #dcdfe2;
749
+ }
750
+ .sheet-arrow {
751
+ width: 26px;
752
+ height: 26px;
753
+ padding: 0;
754
+ border: 0;
755
+ border-radius: 4px;
756
+ background: transparent;
757
+ color: #666;
758
+ font-size: 16px;
759
+ line-height: 1;
760
+ }
761
+ .sheet-arrow:hover {
762
+ background: #e6e8ea;
763
+ }
764
+ .sheet-tabs {
765
+ display: flex;
766
+ align-items: stretch;
767
+ flex: 1;
768
+ min-width: 0;
769
+ overflow-x: auto;
770
+ }
771
+ .sheet-tab {
772
+ display: flex;
773
+ align-items: center;
774
+ flex-shrink: 0;
775
+ gap: 8px;
776
+ margin-top: -1px;
777
+ padding: 0 18px;
778
+ border: 0;
779
+ border-right: 1px solid #dcdfe2;
780
+ border-radius: 0;
781
+ background: transparent;
782
+ color: #666;
783
+ font-size: 13px;
784
+ white-space: nowrap;
785
+ }
786
+ .sheet-tab:hover {
787
+ color: #1f2124;
788
+ }
789
+ .sheet-tab.is-active {
790
+ background: #fff;
791
+ color: var(--sheet-ink);
792
+ font-weight: 700;
793
+ box-shadow: inset 0 -2px 0 var(--sheet-accent);
794
+ }
795
+ .sheet-tab-count {
796
+ font-size: 11px;
797
+ font-weight: 400;
798
+ color: #9a9a9a;
799
+ }
800
+ .sheet-status {
801
+ display: flex;
802
+ align-items: center;
803
+ gap: 14px;
804
+ padding: 0 14px;
805
+ border-left: 1px solid #dcdfe2;
806
+ color: #777;
807
+ font-size: 12px;
808
+ white-space: nowrap;
809
+ }
810
+ .sheet-hint,
811
+ .sheet-message {
812
+ margin: 14px 0 0;
813
+ font-size: 12px;
814
+ color: #9a9a9a;
815
+ }
816
+ @media (max-width: 700px) {
817
+ .sheet-find {
818
+ flex: 1 1 180px;
819
+ }
820
+ .sheet-spacer,
821
+ .sheet-status span:first-child:empty {
822
+ display: none;
823
+ }
824
+ .sheet-status {
825
+ padding: 0 10px;
826
+ }
827
+ }
376
828
  article table {
377
829
  width: 100%;
378
830
  border-collapse: separate;
@@ -658,13 +1110,21 @@ dialog::backdrop {
658
1110
  padding-top: 25px;
659
1111
  }
660
1112
  article h1 {
661
- font-size: 27px;
1113
+ font-size: 30px;
662
1114
  }
663
1115
  .folder-cards {
664
1116
  grid-template-columns: minmax(0, 1fr);
665
1117
  }
666
1118
  article h2 {
667
- font-size: 21px;
1119
+ font-size: 24px;
1120
+ }
1121
+ article h3 {
1122
+ font-size: 20px;
1123
+ line-height: 1.4;
1124
+ }
1125
+ article h4 {
1126
+ font-size: 18px;
1127
+ line-height: 1.5;
668
1128
  }
669
1129
  article table {
670
1130
  font-size: 12px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unana_dev/doxen",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Config-first Markdown documentation sites with Korean and section search",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,6 +42,7 @@
42
42
  "markdown-it": "^14.1.0",
43
43
  "markdown-it-container": "^4.0.0",
44
44
  "mermaid": "^12.1.0",
45
+ "read-excel-file": "^9.3.14",
45
46
  "sanitize-html": "^2.17.0",
46
47
  "wrangler": "4.149.0"
47
48
  },
package/src/content.js CHANGED
@@ -5,6 +5,7 @@ import MarkdownIt from "markdown-it";
5
5
  import container from "markdown-it-container";
6
6
  import GithubSlugger from "github-slugger";
7
7
  import sanitizeHtml from "sanitize-html";
8
+ import readXlsxFile from "read-excel-file/node";
8
9
  import { inside } from "./config.js";
9
10
 
10
11
  const assetExtensions = new Set([
@@ -16,6 +17,7 @@ const assetExtensions = new Set([
16
17
  ".avif",
17
18
  ".ico",
18
19
  ".pdf",
20
+ ".xlsx",
19
21
  ]);
20
22
  const escape = (text) =>
21
23
  text.replace(
@@ -47,7 +49,7 @@ async function walk(dir) {
47
49
  continue;
48
50
  const file = path.join(dir, entry.name);
49
51
  if (entry.isDirectory()) files.push(...(await walk(file)));
50
- else if (/\.md$/i.test(entry.name)) files.push(file);
52
+ else if (/\.(?:md|xlsx)$/i.test(entry.name)) files.push(file);
51
53
  }
52
54
  return files.sort((a, b) => a.localeCompare(b, "ko", { numeric: true }));
53
55
  }
@@ -62,13 +64,26 @@ export async function collectSite(config) {
62
64
  tab: tab.slug,
63
65
  path: relative,
64
66
  file,
65
- source: await readFile(file, "utf8"),
67
+ source: await readFile(file, /\.xlsx$/i.test(file) ? undefined : "utf8"),
66
68
  });
67
69
  }
68
70
  }
69
71
  const byFile = new Map(documents.map((doc) => [doc.file, doc]));
70
72
  const assets = new Map();
71
73
  for (const doc of documents) {
74
+ if (/\.xlsx$/i.test(doc.path)) {
75
+ const hash = createHash("sha256").update(doc.source).digest("hex").slice(0, 20);
76
+ const sheets = await readXlsxFile(doc.source, { trim: false });
77
+ assets.set(`${hash}.xlsx`, doc.source);
78
+ assets.set(`${hash}.json`, Buffer.from(JSON.stringify(sheets)));
79
+ doc.title = path.basename(doc.path);
80
+ doc.spreadsheet = { data: `./assets/${hash}.json`, file: `./assets/${hash}.xlsx` };
81
+ doc.toc = [];
82
+ doc.sections = [];
83
+ delete doc.source;
84
+ delete doc.file;
85
+ continue;
86
+ }
72
87
  const slugger = new GithubSlugger();
73
88
  const md = new MarkdownIt({
74
89
  html: false,
package/src/dev.js CHANGED
@@ -18,6 +18,7 @@ const types = {
18
18
  ".ico": "image/x-icon",
19
19
  ".svg": "image/svg+xml",
20
20
  ".pdf": "application/pdf",
21
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
21
22
  ".woff2": "font/woff2",
22
23
  };
23
24