Style Guide Compliance Checker

Style Guide Compliance Checker

Check your text for common style guide issues.

1. Text & Style Guide
2. Compliance Report
3. Revise & Export

Compliance Report for

${issue.description}

${[...new Set(issue.found)].map(item => `${item}`).join('')}
`; }); } elements.analysisResults.innerHTML = html; }; // --- PDF UTILITY --- const downloadPDF = () => { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const styleName = elements.styleGuide.options[elements.styleGuide.selectedIndex].text; const title = `Style Guide Compliance Report`; const originalText = elements.inputText.value; const revisedText = elements.revisedText.value; const PAGE_WIDTH = pdf.internal.pageSize.getWidth(); const MARGIN = 50; let y = 0; // Header pdf.setFillColor(3, 105, 161); // sky-700 pdf.rect(0, 0, PAGE_WIDTH, 80, 'F'); pdf.setFont('helvetica', 'bold'); pdf.setFontSize(22); pdf.setTextColor(255, 255, 255); pdf.text(title, MARGIN, 40); pdf.setFontSize(12); pdf.text(`Style Guide: ${styleName}`, MARGIN, 60); y = 120; const addSection = (secTitle, secContent) => { if (!secContent || secContent.length === 0) return; if (y > pdf.internal.pageSize.getHeight() - 100) { pdf.addPage(); y = MARGIN; } pdf.setFont('helvetica', 'bold'); pdf.setFontSize(14); pdf.setTextColor(14, 116, 144); // cyan-700 pdf.text(secTitle, MARGIN, y); y += 20; pdf.setFont('helvetica', 'normal'); pdf.setFontSize(10); pdf.setTextColor(51, 65, 85); // slate-700 const lines = pdf.splitTextToSize(Array.isArray(secContent) ? secContent.join('\n') : secContent, PAGE_WIDTH - MARGIN * 2); pdf.text(lines, MARGIN, y); y += lines.length * 12 + 25; }; const validIssues = analysisData.issues.filter(issue => issue.found.length > 0); if (validIssues.length > 0) { validIssues.forEach(issue => { const content = `${issue.description}\n\nInstances Found: ${[...new Set(issue.found)].join(', ')}`; addSection(issue.title, content); }); } else { addSection("Analysis Summary", `No common issues were detected for the ${styleName}.`); } pdf.addPage(); y = MARGIN; addSection('Original Text', originalText); if (revisedText !== originalText) { addSection('Revised Text', revisedText); } pdf.save(`Style_Guide_Report.pdf`); }; // --- EVENT LISTENERS --- elements.prevBtn.addEventListener('click', () => nextPrev(-1)); elements.nextBtn.addEventListener('click', () => nextPrev(1)); elements.tabs.forEach((tab, i) => { tab.addEventListener('click', () => console.warn("Direct tab navigation is disabled. Please use Next/Previous buttons.")); }); elements.downloadPdfBtn.addEventListener('click', downloadPDF); // Initialize showTab(currentTab); });
Scroll to Top