feat: [rd] 클코→슬랙 변환기 행간 가독성 개선
- 표(table) 행을 제외한 일반 행 사이에 빈 줄 추가 - 제목, 구분선 뒤에도 빈 줄 삽입 - 표 영역은 기존처럼 밀집 유지
This commit is contained in:
@@ -169,6 +169,7 @@ function convertToSlack(text) {
|
||||
let result = [];
|
||||
let inCodeBlock = false;
|
||||
let codeLines = [];
|
||||
let inTable = false;
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i];
|
||||
@@ -176,6 +177,7 @@ function convertToSlack(text) {
|
||||
if (line.trimStart().match(/^```/)) {
|
||||
if (!inCodeBlock) {
|
||||
inCodeBlock = true;
|
||||
inTable = false;
|
||||
codeLines = [];
|
||||
continue;
|
||||
} else {
|
||||
@@ -193,6 +195,28 @@ function convertToSlack(text) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 표 구분선(|---|---|) 스킵
|
||||
if (line.trim().match(/^\|[\s\-:|]+\|$/)) {
|
||||
inTable = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 표 행
|
||||
if (line.trim().match(/^\|.*\|$/)) {
|
||||
inTable = true;
|
||||
let cells = line.split('|').filter(c => c.trim() !== '');
|
||||
result.push(cells.map(c => c.trim()).join(' | '));
|
||||
continue;
|
||||
}
|
||||
|
||||
// 표 영역 종료 후 빈 줄 삽입
|
||||
if (inTable) {
|
||||
inTable = false;
|
||||
if (result.length > 0 && result[result.length - 1] !== '') {
|
||||
result.push('');
|
||||
}
|
||||
}
|
||||
|
||||
if (line.trim() === '') {
|
||||
if (result.length > 0 && result[result.length - 1] !== '') {
|
||||
result.push('');
|
||||
@@ -202,27 +226,20 @@ function convertToSlack(text) {
|
||||
|
||||
if (line.trim().match(/^[-]{3,}$/)) {
|
||||
result.push('———');
|
||||
result.push('');
|
||||
continue;
|
||||
}
|
||||
|
||||
let headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
||||
if (headingMatch) {
|
||||
result.push('*' + headingMatch[2].trim() + '*');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.trim().match(/^\|[\s\-:|]+\|$/)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.trim().match(/^\|.*\|$/)) {
|
||||
let cells = line.split('|').filter(c => c.trim() !== '');
|
||||
result.push(cells.map(c => c.trim()).join(' | '));
|
||||
result.push('');
|
||||
continue;
|
||||
}
|
||||
|
||||
line = convertInlineMarkdown(line);
|
||||
result.push(line);
|
||||
result.push('');
|
||||
}
|
||||
|
||||
if (inCodeBlock && codeLines.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user