From 79f11383f1def577e34faf1f704b3fd196e7eef4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 21 Aug 2025 13:38:53 -0500 Subject: [PATCH] ReadWebpageTool: fix newlines in codeblocks --- eslint-rules/require-webmanifest.js | 16 ++++++++-------- src/lib/tools/ReadWebpageTool.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eslint-rules/require-webmanifest.js b/eslint-rules/require-webmanifest.js index 312bafda..9c957cae 100644 --- a/eslint-rules/require-webmanifest.js +++ b/eslint-rules/require-webmanifest.js @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; export default { meta: { @@ -19,7 +19,7 @@ export default { create(context) { const filename = context.getFilename(); - + // Only run this rule on HTML files if (!filename.endsWith('.html')) { return {}; @@ -29,11 +29,11 @@ export default { Program(node) { const sourceCode = context.getSourceCode(); const htmlContent = sourceCode.getText(); - + // Check for manifest link tag in HTML const manifestLinkRegex = /]*rel=["']manifest["'][^>]*>/i; const manifestMatch = htmlContent.match(manifestLinkRegex); - + if (!manifestMatch) { context.report({ node, @@ -53,11 +53,11 @@ export default { } const manifestPath = hrefMatch[1]; - + // Resolve the manifest file path relative to the project root const htmlDir = path.dirname(filename); let resolvedManifestPath; - + if (manifestPath.startsWith('/')) { // Absolute path - check in public directory first, then project root const publicPath = path.resolve(htmlDir, 'public' + manifestPath); @@ -67,7 +67,7 @@ export default { // Relative path resolvedManifestPath = path.resolve(htmlDir, manifestPath); } - + // Check if the manifest file exists if (!fs.existsSync(resolvedManifestPath)) { context.report({ diff --git a/src/lib/tools/ReadWebpageTool.ts b/src/lib/tools/ReadWebpageTool.ts index 117f7164..02e8225e 100644 --- a/src/lib/tools/ReadWebpageTool.ts +++ b/src/lib/tools/ReadWebpageTool.ts @@ -39,7 +39,7 @@ export class ReadWebpageTool implements Tool { const codeElement = node.querySelector("code"); if (codeElement) { const language = codeElement.className.match(/language-(\w+)/)?.[1] || ""; - return `\n\n\`\`\`${language}\n${codeElement.textContent || content}\n\`\`\`\n\n`; + return `\n\n\`\`\`${language}\n${content}\n\`\`\`\n\n`; } return `\n\n\`\`\`\n${content}\n\`\`\`\n\n`; },