Skip to content

Commit

Permalink
App 2068 bugfix undefined replace (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrloureed authored Jun 22, 2023
1 parent 1c0c1c5 commit d06147c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime",
"version": "0.2.14",
"version": "0.2.15",
"license": "Apache-2.0",
"type": "module",
"files": [
Expand Down
22 changes: 13 additions & 9 deletions src/elements/code-snippet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Themes = 'vs' | 'vsc-dark-plus';
export let language: string;
export let code: string;
export let theme: Themes;
export let theme: Themes = 'vs';
export let showbutton = 'true';
$: label = 'Copy';
Expand Down Expand Up @@ -86,7 +86,9 @@ const formatCode = (input: string): string => {
let formattedCode = input;
for (const [key, value] of Object.entries(htmlEntities)) {
formattedCode = formattedCode.replaceAll(key, value);
if (formattedCode) {
formattedCode = formattedCode.replaceAll(key, value);
}
}
return formattedCode;
Expand All @@ -97,7 +99,7 @@ onMount(async () => {
});
$: {
if (element) {
if (element && code) {
element.innerHTML = formatCode(code);
// eslint-disable-next-line no-void
void highlight();
Expand Down Expand Up @@ -127,9 +129,11 @@ $: {
{/if}
</div>

<link
rel="stylesheet"
crossorigin="anonymous"
referrerpolicy="no-referrer"
href="https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-{theme}.min.css"
/>
{#if theme}
<link
rel="stylesheet"
crossorigin="anonymous"
referrerpolicy="no-referrer"
href="https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-{theme}.min.css"
/>
{/if}

0 comments on commit d06147c

Please sign in to comment.