Browse Source

cleaned up debugging

master
Silberengel 8 months ago
parent
commit
c9721c5eb5
  1. 5
      src/lib/parser.ts
  2. 10
      src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts

5
src/lib/parser.ts

@ -1159,7 +1159,7 @@ function ensureAsciiDocHeader(content: string): string {
if (lines[i].trim() === '') continue; if (lines[i].trim() === '') continue;
if (lines[i].trim().startsWith('=')) { if (lines[i].trim().startsWith('=')) {
headerIndex = i; headerIndex = i;
console.debug('[Pharos] AsciiDoc document header:', lines[i].trim());
break; break;
} else { } else {
throw new Error('AsciiDoc document is missing a header at the top.'); throw new Error('AsciiDoc document is missing a header at the top.');
@ -1184,8 +1184,7 @@ function ensureAsciiDocHeader(content: string): string {
lines.splice(headerIndex + 1, 0, ':doctype: book'); lines.splice(headerIndex + 1, 0, ':doctype: book');
} }
// Log the state of the lines before returning
console.debug('[Pharos] AsciiDoc lines after header/doctype normalization:', lines.slice(0, 5));
return lines.join('\n'); return lines.join('\n');
} }

10
src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts

@ -43,18 +43,12 @@ function fixAllMathBlocks(html: string): string {
// Unescape \$ to $ for math delimiters // Unescape \$ to $ for math delimiters
html = html.replace(/\\\$/g, '$'); html = html.replace(/\\\$/g, '$');
// DEBUG: Log the HTML before MathJax runs
if (html.includes('latexmath')) {
console.debug('Processed HTML for latexmath:', html);
}
// Block math: <div class="stemblock"><div class="content">...</div></div> // Block math: <div class="stemblock"><div class="content">...</div></div>
html = html.replace( html = html.replace(
/<div class="stemblock">\s*<div class="content">([\s\S]*?)<\/div>\s*<\/div>/g, /<div class="stemblock">\s*<div class="content">([\s\S]*?)<\/div>\s*<\/div>/g,
(_match, mathContent) => { (_match, mathContent) => {
// DEBUG: Log the original and cleaned math content
console.debug('Block math original:', mathContent);
console.debug('Block math char codes:', Array.from(mathContent as string).map((c: string) => c.charCodeAt(0)));
let cleanMath = mathContent let cleanMath = mathContent
.replace(/<span>\$<\/span>/g, '') .replace(/<span>\$<\/span>/g, '')
.replace(/<span>\$\$<\/span>/g, '') .replace(/<span>\$\$<\/span>/g, '')
@ -64,8 +58,6 @@ function fixAllMathBlocks(html: string): string {
// Remove all leading and trailing whitespace and $ // Remove all leading and trailing whitespace and $
.replace(/^[\s$]+/, '').replace(/[\s$]+$/, '') .replace(/^[\s$]+/, '').replace(/[\s$]+$/, '')
.trim(); // Final trim to remove any stray whitespace or $ .trim(); // Final trim to remove any stray whitespace or $
console.debug('Block math cleaned:', cleanMath);
console.debug('Block math cleaned char codes:', Array.from(cleanMath as string).map((c: string) => c.charCodeAt(0)));
// Always wrap in $$...$$ // Always wrap in $$...$$
return `<div class="stemblock"><div class="content">$$${cleanMath}$$</div></div>`; return `<div class="stemblock"><div class="content">$$${cleanMath}$$</div></div>`;
} }

Loading…
Cancel
Save