Fix parsing
This commit is contained in:
+27
-4
@@ -86,6 +86,7 @@ function loadIssuesFromFiles(fileRefs, issueType, elementId, applyIssueSearchFil
|
|||||||
allIssues.push({
|
allIssues.push({
|
||||||
id: issue.id || '',
|
id: issue.id || '',
|
||||||
summary: issue.summary || '',
|
summary: issue.summary || '',
|
||||||
|
resolved: issue.resolved || '',
|
||||||
caveat: issue.caveat || '',
|
caveat: issue.caveat || '',
|
||||||
sourceVersion
|
sourceVersion
|
||||||
});
|
});
|
||||||
@@ -157,6 +158,7 @@ function parseMarkdownIssues(markdownText) {
|
|||||||
const issues = [];
|
const issues = [];
|
||||||
let currentIssueId = '';
|
let currentIssueId = '';
|
||||||
let currentIssueBodyParts = [];
|
let currentIssueBodyParts = [];
|
||||||
|
let currentIssueResolvedBlocks = [];
|
||||||
let currentIssueCaveatBlocks = [];
|
let currentIssueCaveatBlocks = [];
|
||||||
|
|
||||||
const finalizeIssue = () => {
|
const finalizeIssue = () => {
|
||||||
@@ -170,11 +172,13 @@ function parseMarkdownIssues(markdownText) {
|
|||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
const summary = summaryBody;
|
const summary = summaryBody;
|
||||||
|
const resolved = currentIssueResolvedBlocks.join('\n\n').trim();
|
||||||
const caveat = currentIssueCaveatBlocks.join('\n\n').trim();
|
const caveat = currentIssueCaveatBlocks.join('\n\n').trim();
|
||||||
|
|
||||||
issues.push({
|
issues.push({
|
||||||
id: currentIssueId,
|
id: currentIssueId,
|
||||||
summary,
|
summary,
|
||||||
|
resolved,
|
||||||
caveat
|
caveat
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -184,6 +188,7 @@ function parseMarkdownIssues(markdownText) {
|
|||||||
finalizeIssue();
|
finalizeIssue();
|
||||||
currentIssueId = String(token.text || '').trim();
|
currentIssueId = String(token.text || '').trim();
|
||||||
currentIssueBodyParts = [];
|
currentIssueBodyParts = [];
|
||||||
|
currentIssueResolvedBlocks = [];
|
||||||
currentIssueCaveatBlocks = [];
|
currentIssueCaveatBlocks = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -192,6 +197,14 @@ function parseMarkdownIssues(markdownText) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (token.type === 'code' && String(token.lang || '').trim().toLowerCase() === 'resolved') {
|
||||||
|
const resolvedText = String(token.text || '').trim();
|
||||||
|
if (resolvedText) {
|
||||||
|
currentIssueResolvedBlocks.push(resolvedText);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (token.type === 'code' && String(token.lang || '').trim().toLowerCase() === 'caveat') {
|
if (token.type === 'code' && String(token.lang || '').trim().toLowerCase() === 'caveat') {
|
||||||
const caveatText = String(token.text || '').trim();
|
const caveatText = String(token.text || '').trim();
|
||||||
if (caveatText) {
|
if (caveatText) {
|
||||||
@@ -234,6 +247,7 @@ function normalizeIssuesFromPayload(data) {
|
|||||||
return {
|
return {
|
||||||
id: String(item.id).trim(),
|
id: String(item.id).trim(),
|
||||||
summary: String(item.summary || item.description).trim(),
|
summary: String(item.summary || item.description).trim(),
|
||||||
|
resolved: String(item.resolved || '').trim(),
|
||||||
caveat: String(item.caveat || '').trim()
|
caveat: String(item.caveat || '').trim()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -251,6 +265,7 @@ function normalizeIssuesFromPayload(data) {
|
|||||||
return {
|
return {
|
||||||
id: String(issue.id).trim(),
|
id: String(issue.id).trim(),
|
||||||
summary: String(issue.description).trim(),
|
summary: String(issue.description).trim(),
|
||||||
|
resolved: String(issue.resolved || '').trim(),
|
||||||
caveat: String(issue.caveat || '').trim()
|
caveat: String(issue.caveat || '').trim()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -390,17 +405,21 @@ function dedupeIssues(issues, versionKey) {
|
|||||||
issues.forEach(issue => {
|
issues.forEach(issue => {
|
||||||
const id = (issue.id || '').trim();
|
const id = (issue.id || '').trim();
|
||||||
const summary = (issue.summary || '').trim();
|
const summary = (issue.summary || '').trim();
|
||||||
|
const resolved = (issue.resolved || '').trim();
|
||||||
const caveat = (issue.caveat || '').trim();
|
const caveat = (issue.caveat || '').trim();
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
|
||||||
if (!map.has(id)) {
|
if (!map.has(id)) {
|
||||||
map.set(id, { id, summary, caveat, [versionKey]: [] });
|
map.set(id, { id, summary, resolved, caveat, [versionKey]: [] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = map.get(id);
|
const entry = map.get(id);
|
||||||
if (!entry.summary && summary) {
|
if (!entry.summary && summary) {
|
||||||
entry.summary = summary;
|
entry.summary = summary;
|
||||||
}
|
}
|
||||||
|
if (!entry.resolved && resolved) {
|
||||||
|
entry.resolved = resolved;
|
||||||
|
}
|
||||||
if (!entry.caveat && caveat) {
|
if (!entry.caveat && caveat) {
|
||||||
entry.caveat = caveat;
|
entry.caveat = caveat;
|
||||||
}
|
}
|
||||||
@@ -441,7 +460,7 @@ function getSourceVersionFromFileName(fileName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderSummaryCell(cell, issue) {
|
function renderSummaryCell(cell, issue) {
|
||||||
cell.innerHTML = markdownSummaryToHtml(issue.summary, issue.caveat);
|
cell.innerHTML = markdownSummaryToHtml(issue.summary, issue.resolved, issue.caveat);
|
||||||
|
|
||||||
const refs = getSocialRefsForIssue(issue.id);
|
const refs = getSocialRefsForIssue(issue.id);
|
||||||
if (!refs.length) {
|
if (!refs.length) {
|
||||||
@@ -504,15 +523,19 @@ function normalizeSocialRefs(data) {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
function markdownSummaryToHtml(summaryText, caveatText) {
|
function markdownSummaryToHtml(summaryText, resolvedText, caveatText) {
|
||||||
const input = String(summaryText || '').trim();
|
const input = String(summaryText || '').trim();
|
||||||
|
const resolved = String(resolvedText || '').trim();
|
||||||
const caveat = String(caveatText || '').trim();
|
const caveat = String(caveatText || '').trim();
|
||||||
|
|
||||||
if (!input && !caveat) {
|
if (!input && !resolved && !caveat) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const htmlParts = [];
|
const htmlParts = [];
|
||||||
|
if (resolved) {
|
||||||
|
htmlParts.push(`<div><strong>Resolved:</strong> ${escapeHtml(resolved)}</div>`);
|
||||||
|
}
|
||||||
if (caveat) {
|
if (caveat) {
|
||||||
htmlParts.push(`<div><em>Caveat: ${escapeHtml(caveat)}</em></div>`);
|
htmlParts.push(`<div><em>Caveat: ${escapeHtml(caveat)}</em></div>`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ export function buildIssueMarkdownDocument(payload) {
|
|||||||
lines.push(`## ${issue.id}`);
|
lines.push(`## ${issue.id}`);
|
||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
|
if (issue.resolved) {
|
||||||
|
lines.push('```resolved');
|
||||||
|
lines.push(issue.resolved);
|
||||||
|
lines.push('```');
|
||||||
|
lines.push('');
|
||||||
|
}
|
||||||
|
|
||||||
if (issue.caveat) {
|
if (issue.caveat) {
|
||||||
lines.push('```caveat');
|
lines.push('```caveat');
|
||||||
lines.push(issue.caveat);
|
lines.push(issue.caveat);
|
||||||
|
|||||||
+16
-41
@@ -10,6 +10,7 @@ let activeDownloadUrl = null;
|
|||||||
const PROCESS_FORM_STATE_KEY = 'bugmedley.process.formState.v1';
|
const PROCESS_FORM_STATE_KEY = 'bugmedley.process.formState.v1';
|
||||||
const ISSUE_ID_PATTERN = /\b((?:[A-Z]{2,6}|WF500)-\d{4,8})\b/i;
|
const ISSUE_ID_PATTERN = /\b((?:[A-Z]{2,6}|WF500)-\d{4,8})\b/i;
|
||||||
const BLOCK_CONTAINER_TAGS = new Set(['ARTICLE', 'ASIDE', 'BLOCKQUOTE', 'DIV', 'P', 'PRE', 'SECTION']);
|
const BLOCK_CONTAINER_TAGS = new Set(['ARTICLE', 'ASIDE', 'BLOCKQUOTE', 'DIV', 'P', 'PRE', 'SECTION']);
|
||||||
|
const RESOLVED_LINE_PATTERN = /^resolved\s+in\b/i;
|
||||||
|
|
||||||
function loadProducts() {
|
function loadProducts() {
|
||||||
fetch('data/products.json')
|
fetch('data/products.json')
|
||||||
@@ -60,7 +61,7 @@ function generateJSON() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedIssues = parseIssuesInput(inputText);
|
const parsedIssues = parseIssuesFromHtmlTable(inputText);
|
||||||
|
|
||||||
if (parsedIssues.length === 0) {
|
if (parsedIssues.length === 0) {
|
||||||
document.getElementById('markdownOutput').value = '';
|
document.getElementById('markdownOutput').value = '';
|
||||||
@@ -72,6 +73,7 @@ function generateJSON() {
|
|||||||
const issues = parsedIssues.map(issue => ({
|
const issues = parsedIssues.map(issue => ({
|
||||||
id: issue.id,
|
id: issue.id,
|
||||||
description: issue.description,
|
description: issue.description,
|
||||||
|
resolved: issue.resolved || '',
|
||||||
caveat: issue.caveat || ''
|
caveat: issue.caveat || ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -87,15 +89,6 @@ function generateJSON() {
|
|||||||
setParseStatus(`Parsed ${issues.length} issues from input.`);
|
setParseStatus(`Parsed ${issues.length} issues from input.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseIssuesInput(inputText) {
|
|
||||||
const fromHtml = parseIssuesFromHtmlTable(inputText);
|
|
||||||
if (fromHtml.length > 0) {
|
|
||||||
return fromHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseIssuesFromLinePairs(inputText);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseIssuesFromHtmlTable(htmlText) {
|
function parseIssuesFromHtmlTable(htmlText) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(htmlText, 'text/html');
|
const doc = parser.parseFromString(htmlText, 'text/html');
|
||||||
@@ -105,16 +98,20 @@ function parseIssuesFromHtmlTable(htmlText) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const rows = table.querySelectorAll(':scope > tr, :scope > tbody > tr, :scope > thead > tr, :scope > tfoot > tr');
|
const rows = Array.from(table.querySelectorAll('tr'));
|
||||||
const issues = [];
|
const issues = [];
|
||||||
|
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
const cells = row.querySelectorAll('td, th');
|
const cells = Array.from(row.children).filter(cell => {
|
||||||
|
const tag = (cell.tagName || '').toUpperCase();
|
||||||
|
return tag === 'TD' || tag === 'TH';
|
||||||
|
});
|
||||||
|
|
||||||
if (cells.length < 2) {
|
if (cells.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leftCellText = normalizeWhitespace(cells[0].textContent || '');
|
const leftCellText = extractCellText(cells[0]);
|
||||||
const issueDetails = extractIssueDetails(cells[1]);
|
const issueDetails = extractIssueDetails(cells[1]);
|
||||||
const rightCellText = issueDetails.description;
|
const rightCellText = issueDetails.description;
|
||||||
|
|
||||||
@@ -128,6 +125,10 @@ function parseIssuesFromHtmlTable(htmlText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const id = issueIdMatch[1].toUpperCase();
|
const id = issueIdMatch[1].toUpperCase();
|
||||||
|
const leftCellTrailingText = normalizeWhitespace(
|
||||||
|
leftCellText.replace(issueIdMatch[0], '').replace(/^[-:;,.\s]+/, '')
|
||||||
|
);
|
||||||
|
const resolved = RESOLVED_LINE_PATTERN.test(leftCellTrailingText) ? leftCellTrailingText : '';
|
||||||
const description = rightCellText;
|
const description = rightCellText;
|
||||||
|
|
||||||
if (!description) {
|
if (!description) {
|
||||||
@@ -137,7 +138,8 @@ function parseIssuesFromHtmlTable(htmlText) {
|
|||||||
issues.push({
|
issues.push({
|
||||||
id,
|
id,
|
||||||
description,
|
description,
|
||||||
caveat: issueDetails.caveat
|
resolved,
|
||||||
|
caveat: issueDetails.caveat || (resolved ? '' : leftCellTrailingText)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -330,33 +332,6 @@ function sanitizeTableCellText(text) {
|
|||||||
return normalizeWhitespace(text).replace(/\|/g, '\\|');
|
return normalizeWhitespace(text).replace(/\|/g, '\\|');
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseIssuesFromLinePairs(rawText) {
|
|
||||||
const lines = rawText
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.map(line => line.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const issues = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i += 2) {
|
|
||||||
if (i + 1 >= lines.length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const issueIdMatch = lines[i].match(ISSUE_ID_PATTERN);
|
|
||||||
if (!issueIdMatch) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
issues.push({
|
|
||||||
id: issueIdMatch[1].toUpperCase(),
|
|
||||||
description: lines[i + 1]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return issues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeWhitespace(value) {
|
function normalizeWhitespace(value) {
|
||||||
return value.replace(/\s+/g, ' ').trim();
|
return value.replace(/\s+/g, ' ').trim();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user