Academic Referencing Style Error Checker (Conceptual)

Academic Referencing Style Error Checker

Select a referencing style and paste your reference list below. The tool will check for common conceptual and formatting errors based on the rules defined in the "Data Configuration" tab.

Review the results below. Errors are based on configurable rules and may not catch every mistake.

Results will appear here after checking.

Add, edit, or remove referencing styles and their associated check rules. Rules use regular expressions (RegEx) to find patterns.

No references pasted. Please enter references in Tab 1.

'; pdfOutputContent.innerHTML = "

Reference Check Results

No references were provided.

"; showRefTab("ref-tab-results"); // Move to results tab return; } for (const reference of references) { let isValid = true; let errorMessages = []; for (const rule of styleRules.rules) { try { const regex = new RegExp(rule.regex); const hasMatch = regex.test(reference); if (rule.type === "positive" && !hasMatch) { isValid = false; errorMessages.push(rule.message); } if (rule.type === "negative" && hasMatch) { isValid = false; errorMessages.push(rule.message); } } catch (e) { // Log RegEx error but don't crash console.error(`Invalid RegEx in config: ${rule.regex}`, e); alert( `Error in rule "${rule.description}": Invalid RegEx. Please check configuration.` ); } } displayResult(reference, isValid, errorMessages); } // Switch to the results tab (Spec II.B.4.o) showRefTab("ref-tab-results"); }; /** * Downloads the output as a PDF * (Spec II.C) */ window.downloadRefPDF = function () { // Check for required libraries if ( typeof jspdf === "undefined" || typeof html2canvas === "undefined" ) { alert( "Error: PDF generation libraries (jsPDF, html2canvas) not loaded." ); return; } if (!pdfOutputContent || pdfOutputContent.children.length <= 1) { alert("Please check references before downloading PDF."); return; } const { jsPDF } = jspdf; const pdfOutputElement = document.getElementById( "ref-pdf-output-content" ); if (!pdfOutputElement) { alert("Error: PDF output element not found."); return; } // Temporarily make the element visible for html2canvas pdfOutputElement.style.display = "block"; pdfOutputElement.style.position = "absolute"; pdfOutputElement.style.left = "-9999px"; // Move off-screen html2canvas(pdfOutputElement, { scale: 2, // Improve resolution useCORS: true, backgroundColor: "#ffffff", }).then((canvas) => { // Hide the element again pdfOutputElement.style.display = "none"; pdfOutputElement.style.position = "static"; pdfOutputElement.style.left = "0"; const imgData = canvas.toDataURL("image/png"); const pdf = new jsPDF({ orientation: "p", unit: "px", format: "a4", }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; const imgWidth = pdfWidth - 40; // Add 20px margin on each side let imgHeight = imgWidth / ratio; let position = 20; // Top margin if (imgHeight <= pdfHeight - 40) { // Fits on one page pdf.addImage(imgData, "PNG", 20, position, imgWidth, imgHeight); } else { // Handle multiple pages let heightLeft = canvasHeight; let canvasPosition = 0; const pageMargin = 20; // Calculate height for one PDF page in canvas pixels // (pdfHeight - 2 * pageMargin) is the usable height in px // (imgWidth / canvasWidth) is the scale factor const pageHeightInPixels = (pdfHeight - 2 * pageMargin) * (canvasWidth / imgWidth); while (heightLeft > 0.1) { const pageHeight = Math.min(heightLeft, pageHeightInPixels); const pageImgHeight = (pageHeight * imgWidth) / canvasWidth; const tempCanvas = document.createElement("canvas"); tempCanvas.width = canvasWidth; tempCanvas.height = pageHeight; const ctx = tempCanvas.getContext("2d"); // Draw portion of the original canvas ctx.drawImage( canvas, 0, // sx canvasPosition, // sy canvasWidth, // sWidth pageHeight, // sHeight 0, // dx 0, // dy canvasWidth, // dWidth pageHeight // dHeight ); const pageImgData = tempCanvas.toDataURL("image/png"); pdf.addImage( pageImgData, "PNG", pageMargin, pageMargin, imgWidth, pageImgHeight ); heightLeft -= pageHeight; canvasPosition += pageHeight; if (heightLeft > 0.1) { pdf.addPage(); } } } pdf.save("reference-check-results.pdf"); }); }; // --- Initialization --- buildDashboard(); buildConfig(); // Show the first tab by default showRefTab("ref-tab-dashboard"); });
Scroll to Top