fix: keep line breaks in the fields that are not Markdown
The earlier fix covered the Markdown body and stopped there, so the preview still ran lines together — which is exactly what it looked like from the outside: nothing had changed. Summary, problem, conclusion, environment and the rest are plain text. They never pass through the Markdown parser, so their newlines sit in a text node and HTML collapses them, and the renderer that now emits <br> for the body was never asked about them. They render through the same rule now. One helper, one behaviour: a line the author broke stays broken, wherever they typed it.
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { InlineRenderer } from "../../src/features/tech-log/presentation/shared/public-render/inline-renderer.tsx";
|
||||
import {
|
||||
InlineRenderer,
|
||||
PlainText,
|
||||
} from "../../src/features/tech-log/presentation/shared/public-render/inline-renderer.tsx";
|
||||
|
||||
/**
|
||||
* 작성자가 엔터로 나눠 쓴 글이 한 줄로 이어져 보였다. Markdown 이 한 번의 줄바꿈을 문단 내 공백으로
|
||||
@@ -34,3 +37,19 @@ describe("문단 안의 줄바꿈", () => {
|
||||
expect(container.querySelectorAll("br")).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 요약·문제·결론·환경은 Markdown 을 거치지 않고 그대로 그려진다. 본문만 고쳤을 때 이 칸들이
|
||||
* 여전히 이어져 보인 이유이고, 작성자가 "아직 안 고쳐졌다" 고 본 것도 이쪽이다.
|
||||
*/
|
||||
describe("Markdown 을 거치지 않는 평문 칸", () => {
|
||||
it("작성자가 나눠 쓴 줄을 지킨다", () => {
|
||||
const { container } = render(<PlainText text={"문제 첫 줄\n문제 둘째 줄"} />);
|
||||
expect(container.querySelectorAll("br")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("한 줄이면 <br> 를 넣지 않는다", () => {
|
||||
const { container } = render(<PlainText text="한 줄" />);
|
||||
expect(container.querySelectorAll("br")).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user