Fix error messages where there shouldn't be any

master
Araozu 2024-07-29 17:40:51 -05:00
parent 25c1e80591
commit 7e4d11123e
5 changed files with 10 additions and 8 deletions

View File

@ -2,7 +2,7 @@
import { native_highlighter } from "../lexer/highlighter"; import { native_highlighter } from "../lexer/highlighter";
import CodeError from "./docs/CodeError.astro"; import CodeError from "./docs/CodeError.astro";
const { thpcode } = Astro.props; const { thpcode, no_warnings } = Astro.props;
const [native_html, error_type, error_message] = await native_highlighter(thpcode); const [native_html, error_type, error_message] = await native_highlighter(thpcode);
--- ---
@ -11,7 +11,7 @@ const [native_html, error_type, error_message] = await native_highlighter(thpcod
class="language-thp"><code class="language-thp" set:html={native_html} /><span class="absolute top-2 right-2 inline-block text-sm select-none opacity-75">thp class="language-thp"><code class="language-thp" set:html={native_html} /><span class="absolute top-2 right-2 inline-block text-sm select-none opacity-75">thp
</span></pre> </span></pre>
{ {
error_message !== null && ( no_warnings !== true && error_message !== null && (
<CodeError error_type={error_type} error_message={error_message}></CodeError> <CodeError error_type={error_type} error_message={error_message} />
) )
} }

View File

@ -1,11 +1,11 @@
--- ---
import Code from "./Code.astro" import Code from "./Code.astro"
const { thpcode } = Astro.props; const { thpcode, no_warnings } = Astro.props;
--- ---
<div class="flex h-full py-8 items-center"> <div class="flex h-full py-8 items-center">
<div class="p-4 w-full"> <div class="p-4 w-full">
<Code thpcode={thpcode} /> <Code thpcode={thpcode} no_warnings={no_warnings} />
</div> </div>
</div> </div>

View File

@ -30,7 +30,7 @@ if (!title) {
</div> </div>
</div> </div>
<div> <div>
<CodeEditor thpcode={thpcode} /> <CodeEditor thpcode={thpcode} no_warnings={true} />
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@ import { native_highlighter } from "../../lexer/highlighter";
const { thpcode, href } = Astro.props; const { thpcode, href } = Astro.props;
const native_html = await native_highlighter(thpcode); const [native_html] = await native_highlighter(thpcode);
--- ---
<a href={href} class="inline-block w-full py-2 font-mono whitespace-pre" set:html={native_html} /> <a href={href} class="inline-block w-full py-2 font-mono whitespace-pre" set:html={native_html} />

View File

@ -24,6 +24,8 @@ case Cat(name, lives)
{ {
print("{name} has {lives}") print("{name} has {lives}")
}`; }`;
const [thp_html] = await native_highlighter(leftTrimDedent(thpcode).join("\n"));
--- ---
<BaseLayout> <BaseLayout>
@ -118,7 +120,7 @@ case Cat(name, lives)
</svg> </svg>
<div class="h-1"></div> <div class="h-1"></div>
<div id="editor" class="font-mono language-thp"> <div id="editor" class="font-mono language-thp">
<pre set:html={native_highlighter(leftTrimDedent(thpcode).join("\n"))}></pre> <pre set:html={thp_html}></pre>
</div> </div>
</div> </div>
</div> </div>