fix(가이드): 그림 설명 속 대괄호([저장] 꼴)도 그림으로 그림 — 그림 줄 풀이 정규식 · 시험 덧
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,12 +43,20 @@ const DOC = [
|
||||
"", // 19
|
||||
'<script>alert("x")</script>', // 20
|
||||
].join("\n");
|
||||
// 설명 속 대괄호 — [저장] 꼴 단추 이름 · 굵게 · 링크가 섞여도 그림 줄은 그림
|
||||
const BRACKET = [
|
||||
"![[저장] 단추 누름](b05_full.webp)", // 0
|
||||
"![[저장]·[확정] **굵게** [글](B06/00_설명서)](b05_full.webp)", // 1
|
||||
"[글](B06/00_설명서) 와 [저장] 문단", // 2
|
||||
"![[저장] 뒤에 글](b05_full.webp) 덧글", // 3
|
||||
].join("\n");
|
||||
|
||||
process.stdout.write(
|
||||
JSON.stringify({
|
||||
plain: renderHelpMarkdown(DOC),
|
||||
admin: renderHelpMarkdown(DOC, ctx(true)),
|
||||
user: renderHelpMarkdown(DOC, ctx(false)),
|
||||
bracket: renderHelpMarkdown(BRACKET, ctx(true)),
|
||||
crlf: renderHelpMarkdown("# 가\r\n\r\n- 나\r\n- 다\r\n", ctx(false)),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -76,6 +76,20 @@ def test_그림_상자_링크(html) -> None:
|
||||
assert 'data-help-goto="B05/구조물_돌쌓기(메)">돌쌓기</a>' in admin
|
||||
|
||||
|
||||
def test_설명_속_대괄호도_그림(html) -> None:
|
||||
out = html["bracket"]
|
||||
src = "/api/help/B05/img/b05_full.webp?v=abc"
|
||||
assert '<figure data-src="0-0" class="ui-help-figure" data-img="b05_full.webp">' in out
|
||||
assert f'<img src="{src}" alt="[저장] 단추 누름" loading="lazy">' in out
|
||||
assert "<figcaption>[저장] 단추 누름</figcaption>" in out
|
||||
# 굵게는 캡션에서 풀리고, 링크는 그림 설명 안에서 링크로 풀리지 않음
|
||||
assert "<figcaption>[저장]·[확정] <strong>굵게</strong> [글](B06/00_설명서)</figcaption>" in out
|
||||
assert out.count("<figure") == 2
|
||||
# 링크 문단은 그대로 링크 · 그림 뒤에 글이 붙은 줄은 그림이 아님
|
||||
assert 'data-help-goto="B06/00_설명서">글</a> 와 [저장] 문단' in out
|
||||
assert "<p" in out and "덧글" in out
|
||||
|
||||
|
||||
def test_html_은_먼저_막음(html) -> None:
|
||||
for out in html.values():
|
||||
assert "<script>" not in out
|
||||
|
||||
@@ -161,7 +161,7 @@ export function renderHelpMarkdown(text: string, ctx?: HelpRenderContext): strin
|
||||
}
|
||||
const head = /^(#{1,4})\s+(.*)$/.exec(line);
|
||||
const item = /^(?:([-*])|\d+\.)\s+(.*)$/.exec(line);
|
||||
const image = ctx && /^!\[([^\]]*)\]\(([^)\s]+)\)$/.exec(line);
|
||||
const image = ctx && /^!\[(.*)\]\(([^)\s]+)\)$/.exec(line);
|
||||
if (!line) flush();
|
||||
else if (ctx && line.startsWith(">")) {
|
||||
flush();
|
||||
|
||||
Reference in New Issue
Block a user