Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix different language highlight + add option to skip highlighting + … #285

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions assets/components/Website/Docs/CodeBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,27 @@ import { highlightCode } from "../../../helpers/highlightCode";
import { TransitionRoot } from "@headlessui/vue";
import { ClipboardDocumentIcon } from "@heroicons/vue/24/solid";

const language = ref("php");
const formattedCode = ref("");
const code = ref(slots.default()[0].children);

const props = defineProps({
lang: {
type: String,
default: "php",
},
noHighlight: {
type: Boolean,
default: false,
},
});

const highlight = () => {
formattedCode.value = highlightCode(code.value, language.value);
if (props.noHighlight === true) {
formattedCode.value = code.value;
return;
}

formattedCode.value = highlightCode(code.value, props.lang);
};

onMounted(() => {
Expand Down Expand Up @@ -66,7 +81,7 @@ const clipboardAvailable = computed(() => {
<span class="absolute right-4 top-4 font-mono text-[10px] text-pink-600">Copied!</span>
</TransitionRoot>
<div class="mb-4 overflow-y-scroll rounded-md border border-gray-600 bg-gray-900 p-4">
<pre><code class="block text-xs " :class="language" v-html="formattedCode"></code></pre>
<pre><code class="block text-xs" :class="lang" v-html="formattedCode"></code></pre>
</div>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ echo $count / $numberCount;</pre
</ul>

<p>Our problem file might look like the following.</p>
<CodeBlock lang="md">
<CodeBlock lang="md" no-highlight>
<pre>
Write a program that accepts one or more numbers as command-line arguments and prints the mean average of those numbers to the console (stdout).

Expand Down