유형
diff --git a/src/features/tech-log/presentation/public/pages/project-decisions-page.tsx b/src/features/tech-log/presentation/public/pages/project-decisions-page.tsx
index 704953b..bc25216 100644
--- a/src/features/tech-log/presentation/public/pages/project-decisions-page.tsx
+++ b/src/features/tech-log/presentation/public/pages/project-decisions-page.tsx
@@ -4,7 +4,7 @@ import {
RegisteredNotFoundRoute,
useRouteInput,
} from "../../../../../presentation/routes/route-input.tsx";
-import { PlainText } from "../../shared/public-render/inline-renderer.tsx";
+import { ProseText } from "../../shared/public-render/prose-text.tsx";
import { ProjectPageHeader } from "../components/project-page-header.tsx";
import { usePublicContent } from "../use-public-content.tsx";
@@ -32,7 +32,7 @@ export function ProjectDecisionsPage() {
{/*
작성자가 나눠 쓴 줄은 그대로 나눠 보여야 한다. 이 칸들은 Markdown 을 거치지 않고
텍스트 노드로 들어가므로, HTML 이 줄바꿈을 공백으로 접어 여러 문단이 한 줄로
- 이어져 보였다. `PlainText` 가 그 자리를 지킨다.
+ 이어져 보였다. `ProseText` 가 그 자리를 지킨다.
*/}
영향
{decision.consequences.length ? (
{decision.consequences.map((item) => (
-
+
))}
) : (
diff --git a/src/features/tech-log/presentation/shared/public-render/prose-text.tsx b/src/features/tech-log/presentation/shared/public-render/prose-text.tsx
new file mode 100644
index 0000000..534e22f
--- /dev/null
+++ b/src/features/tech-log/presentation/shared/public-render/prose-text.tsx
@@ -0,0 +1,70 @@
+import { Fragment, type ReactNode } from "react";
+
+/**
+ * 작성자가 직접 쓴 산문 칸. 요약·판단 기준 본문·해결 내용처럼 Markdown 블록 파서를 거치지
+ * 않고 문자열 그대로 오는 자리에 쓴다.
+ *
+ * 이 칸들은 오래 평문으로 나갔다. 그래서 두 가지가 깨져 있었다. 빈 줄로 나눈 문단이 문단으로
+ * 보이지 않았고(줄바꿈 두 개가 그냥 이어졌다), 작성자가 백틱으로 적은 식별자가 백틱째 화면에
+ * 나왔다 — 어떤 Reference 는 한 문서에 백틱이 32개 있었고 그 원문이 카드와 검색 결과까지
+ * 그대로 퍼졌다.
+ *
+ *
블록 파서(`parseCaseContent`)를 쓰지 않는 이유는 그쪽이 Case 전용 문법(`:::evidence`,
+ * 도식 참조)까지 물고 있어 이 칸들에는 없는 해석기를 끌고 오기 때문이다. 여기 필요한 것은
+ * 문단과 인라인 코드 둘뿐이다.
+ */
+
+/**
+ * 백틱으로 감싼 조각을 코드로 읽는다.
+ *
+ *
백틱 수가 홀수면 짝이 맞지 않는다 — 작성자가 코드를 의도한 것이 아니라 백틱 자체를 쓴
+ * 것일 수 있으므로 원문을 그대로 둔다. 반쯤 해석해서 한쪽만 코드로 만드는 쪽이 더 나쁘다.
+ */
+function renderInlineCode(text: string, keyPrefix: string): ReactNode[] {
+ const parts = text.split("`");
+ if (parts.length % 2 === 0) return [text];
+ return parts.map((part, index) =>
+ index % 2 === 1 ? (
+ {part}
+ ) : (
+ {part}
+ ),
+ );
+}
+
+/** 문단 안의 줄바꿈. 작성자가 엔터로 나눠 쓴 줄을 그 자리에 지킨다. */
+function renderLines(paragraph: string, keyPrefix: string): ReactNode[] {
+ const lines = paragraph.split("\n");
+ return lines.flatMap((line, index) => {
+ const rendered = renderInlineCode(line, `${keyPrefix}-${index}`);
+ if (index === 0) return rendered;
+ return [
, ...rendered];
+ });
+}
+
+export function ProseText({
+ text,
+ className,
+}: {
+ text: string;
+ /** 문단마다 붙는다. 한 문단만 있던 시절 바깥 `
` 가 갖고 있던 클래스가 여기로 온다. */
+ className?: string;
+}) {
+ // 빈 줄이 몇 개든 문단 하나의 경계다. 세 줄을 띄웠다고 빈 문단이 생기지는 않는다.
+ const paragraphs = text
+ .split(/\n{2,}/u)
+ .map((paragraph) => paragraph.trim())
+ .filter((paragraph) => paragraph !== "");
+
+ if (paragraphs.length === 0) return null;
+
+ return (
+ <>
+ {paragraphs.map((paragraph, index) => (
+
+ {renderLines(paragraph, String(index))}
+
+ ))}
+ >
+ );
+}
diff --git a/src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx b/src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx
index eb93961..950cb20 100644
--- a/src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx
+++ b/src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx
@@ -2,7 +2,7 @@ import { Link } from "react-router-dom";
import type { components } from "../../../contracts/studio/generated.ts";
import { inlinePlainText } from "../../../domain/content-format/inline-plain-text.ts";
-import { PlainText } from "./inline-renderer.tsx";
+import { ProseText } from "./prose-text.tsx";
import type {
ResolveEvidenceAsset,
ResolvePublishedLabel,
@@ -95,7 +95,7 @@ function ModelDocumentHeader({
) : null}
{model.title}
-
+
- 유형
@@ -177,27 +177,27 @@ function CaseDocument({
{model.title}
-
+
- 기록
@@ -272,13 +272,13 @@ function ConceptDocument({
{model.title}
-
+
{model.basisVersion ? (
) : null}
@@ -330,7 +330,7 @@ function ReferenceDocument({
@@ -343,7 +343,7 @@ function ReferenceDocument({
{String(index + 1).padStart(2, "0")}
{rule.title}
-
{rule.body}
+
))}
@@ -354,7 +354,7 @@ function ReferenceDocument({
{[...model.applyWhen]
.sort((left, right) => left.order - right.order)
- .map((item) => - {item.text}
)}
+ .map((item) => )}
@@ -362,7 +362,7 @@ function ReferenceDocument({
{[...model.exceptions]
.sort((left, right) => left.order - right.order)
- .map((item) => - {item.text}
)}
+ .map((item) => )}
@@ -370,7 +370,7 @@ function ReferenceDocument({
{[...model.examples]
.sort((left, right) => left.order - right.order)
- .map((item) => - {item.text}
)}
+ .map((item) => )}
마지막 검증 {displayDate(model.verifiedOn)}
@@ -394,7 +394,7 @@ function OrderedItems({
{[...items]
.sort((left, right) => left.order - right.order)
- .map((item) => - {item.text}
)}
+ .map((item) => )}
);
}
@@ -466,7 +466,7 @@ function QuestionDocument({
.map((option) => (
-
{option.title}
- {option.description}
+
))}
@@ -477,7 +477,7 @@ function QuestionDocument({
>
Next
다음 검증
-
+
@@ -524,16 +524,16 @@ function ProjectDecisionDocument({
{model.title}
{model.summary ? (
-
+
) : null}
영향
diff --git a/src/features/tech-log/presentation/styles/globals.css b/src/features/tech-log/presentation/styles/globals.css
index b2dea66..67ec74e 100644
--- a/src/features/tech-log/presentation/styles/globals.css
+++ b/src/features/tech-log/presentation/styles/globals.css
@@ -2467,6 +2467,22 @@ dialog::backdrop {
.reference-rules li > span { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; }
.reference-rules p,
.question-options p { margin: 5px 0 0; }
+
+/*
+ 문단 사이. 작성자가 빈 줄로 나눈 것이 문단으로 보여야 한다 — 나누기만 하고 여백이 없으면
+ 갈라 놓은 의미가 없다. 목록 항목 안에서는 항목 자체의 여백이 이미 있으므로 위아래 끝을 턴다.
+*/
+.public-document-body p + p,
+.reference-rules p + p,
+.question-options p + p { margin-top: 1.05em; }
+.public-document-body li > p:first-child,
+.reference-rules li p:first-of-type { margin-top: 0; }
+.public-document-body li > p:last-child { margin-bottom: 0; }
+
+/* 작성자가 백틱으로 적은 식별자. 본문 흐름을 끊지 않게 옅은 바탕만 준다. */
+.public-document-body code,
+.reference-rules code,
+.question-options code { padding: 1px 5px; border-radius: 4px; background: var(--line); font-family: "IBM Plex Mono", monospace; font-size: 0.88em; }
.verified-at { color: var(--faint) !important; font-size: 12px !important; }
.question-status { width: fit-content; margin: -34px 0 50px; padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 650; }
.question-status--open,
diff --git a/tests/component/inline-line-breaks.test.tsx b/tests/component/inline-line-breaks.test.tsx
index 7406895..0b40838 100644
--- a/tests/component/inline-line-breaks.test.tsx
+++ b/tests/component/inline-line-breaks.test.tsx
@@ -86,13 +86,21 @@ describe("문서 머리말의 요약", () => {
nextValidation: "",
};
- it("작성자가 나눈 문단을 지킨다", () => {
+ it("빈 줄은 문단으로, 문단 안 줄바꿈은 줄바꿈으로 그린다", () => {
const { container } = render(
,
);
- // 줄바꿈 셋(빈 줄 포함) →
셋. 그대로 넣으면 0개가 되어 한 줄로 읽힌다.
- expect(container.querySelectorAll(".public-document-header > p br")).toHaveLength(3);
+ /*
+ 요약은 "두 줄 + 빈 줄 + 한 줄" 이다. 예전에는 셋 다
로 나가서 문단 사이 여백이
+ 없었다. 지금은 빈 줄이 문단을 가르고, 문단 안의 줄바꿈만
로 남는다.
+ */
+ const paragraphs = container.querySelectorAll(".public-document-header p");
+ expect(paragraphs).toHaveLength(2);
+ expect(container.querySelectorAll(".public-document-header p br")).toHaveLength(1);
+ // 그대로 넣으면 문단 하나에
0개가 되어 전부 한 덩어리로 읽힌다.
+ expect(paragraphs[0]).toHaveTextContent("둘 다 메모리에 있다.");
+ expect(paragraphs[1]).toHaveTextContent("인스턴스를 늘리면 설계가 필요하다.");
});
});
diff --git a/tests/component/prose-text.test.tsx b/tests/component/prose-text.test.tsx
new file mode 100644
index 0000000..60c39c5
--- /dev/null
+++ b/tests/component/prose-text.test.tsx
@@ -0,0 +1,52 @@
+// @vitest-environment jsdom
+
+import { render } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+
+import { ProseText } from "../../src/features/tech-log/presentation/shared/public-render/prose-text.tsx";
+
+/**
+ * 산문 칸이 오래 평문으로 나갔다. 빈 줄로 나눈 문단이 문단으로 보이지 않았고, 작성자가 백틱으로
+ * 적은 식별자가 백틱째 화면에 나왔다 — 그 원문이 카드와 검색 결과까지 그대로 퍼졌다.
+ */
+describe("산문 칸", () => {
+ it("빈 줄로 나눈 문단을 문단으로 그린다", () => {
+ const { container } = render();
+ const paragraphs = container.querySelectorAll("p");
+ expect(paragraphs).toHaveLength(2);
+ expect(paragraphs[0]).toHaveTextContent("첫 문단.");
+ expect(paragraphs[1]).toHaveTextContent("둘째 문단.");
+ });
+
+ it("빈 줄을 여러 개 띄워도 빈 문단을 만들지 않는다", () => {
+ const { container } = render();
+ expect(container.querySelectorAll("p")).toHaveLength(2);
+ });
+
+ it("문단 안의 줄바꿈은 그 자리에 지킨다", () => {
+ const { container } = render();
+ expect(container.querySelectorAll("p")).toHaveLength(1);
+ expect(container.querySelectorAll("br")).toHaveLength(1);
+ });
+
+ it("백틱으로 감싼 조각을 코드로 읽는다", () => {
+ const { container } = render(
+ ,
+ );
+ const codes = [...container.querySelectorAll("code")].map((el) => el.textContent);
+ expect(codes).toEqual(["로그인 상태가 만료되었다", "Access Token"]);
+ // 백틱은 화면에 남지 않아야 한다 — 카드와 검색 결과까지 퍼지던 것이 이 문자다.
+ expect(container.textContent).not.toContain("`");
+ });
+
+ it("백틱 짝이 맞지 않으면 원문을 그대로 둔다", () => {
+ const { container } = render();
+ expect(container.querySelectorAll("code")).toHaveLength(0);
+ expect(container.textContent).toContain("`");
+ });
+
+ it("빈 문자열이면 아무것도 그리지 않는다", () => {
+ const { container } = render();
+ expect(container.querySelectorAll("p")).toHaveLength(0);
+ });
+});