v1.2.2: 이미지 파일명 alt 판별 및 미리보기 캡션 분리 수정

대괄호 내용이 URL 파일명과 일치할 때만 useAlt로 처리해, 캡션과 대체 텍스트가 미리보기에서 혼동되지 않도록 했다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-15 18:31:25 +09:00
parent 47620ab24c
commit c474a8b9a3
5 changed files with 47 additions and 19 deletions

View File

@@ -48,14 +48,21 @@ export const parseImageMarkdownLine = (line) => {
return null
}
const alt = match[1] || ''
const url = match[2] || ''
const altBracket = (match[1] || '').trim()
const quotedCaption = unescapeImageCaption(match[3])
const filenameAlt = getImageDefaultAltLabel(url)
/** 대괄호 안 문자열이 URL 파일명과 같을 때만 파일명 대체 텍스트 모드 */
const useAlt = altBracket !== '' && altBracket === filenameAlt
return {
url: match[2] || '',
caption: unescapeImageCaption(match[3]),
url,
/** `![](url "캡션")` 따옴표 캡션만 편집 필드에 반영 */
caption: quotedCaption,
/** 레거시 `![표시문구](url)` — 캡션 따옴표 없을 때 미리보기용 */
legacyBracketLabel: !quotedCaption && altBracket && !useAlt ? altBracket : '',
width: match[4] || 'regular',
/** true이면 대체 텍스트로 URL 파일명을 사용한다 */
useAlt: Boolean(alt)
useAlt
}
}
@@ -97,4 +104,16 @@ export const getImageAltAttribute = (image) => {
* @param {{ caption?: string }} image - 이미지 정보
* @returns {string} 캡션
*/
export const getImageCaption = (image) => String(image?.caption || '').trim()
export const getImageCaption = (image) => {
const caption = String(image?.caption || '').trim()
if (caption) {
return caption
}
if (image?.useAlt) {
return ''
}
return String(image?.legacyBracketLabel || '').trim()
}