Skip to content

Commit fafb6a0

Browse files
authored
Merge pull request #285 from php-school/code-highlighting-fixes
Fix different language highlight + add option to skip highlighting + …
2 parents 62cc9de + 5d3b621 commit fafb6a0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

assets/components/Website/Docs/CodeBlock.vue

+18-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,27 @@ import { highlightCode } from "../../../helpers/highlightCode";
1010
import { TransitionRoot } from "@headlessui/vue";
1111
import { ClipboardDocumentIcon } from "@heroicons/vue/24/solid";
1212
13-
const language = ref("php");
1413
const formattedCode = ref("");
1514
const code = ref(slots.default()[0].children);
1615
16+
const props = defineProps({
17+
lang: {
18+
type: String,
19+
default: "php",
20+
},
21+
noHighlight: {
22+
type: Boolean,
23+
default: false,
24+
},
25+
});
26+
1727
const highlight = () => {
18-
formattedCode.value = highlightCode(code.value, language.value);
28+
if (props.noHighlight === true) {
29+
formattedCode.value = code.value;
30+
return;
31+
}
32+
33+
formattedCode.value = highlightCode(code.value, props.lang);
1934
};
2035
2136
onMounted(() => {
@@ -66,7 +81,7 @@ const clipboardAvailable = computed(() => {
6681
<span class="absolute right-4 top-4 font-mono text-[10px] text-pink-600">Copied!</span>
6782
</TransitionRoot>
6883
<div class="mb-4 overflow-y-scroll rounded-md border border-gray-600 bg-gray-900 p-4">
69-
<pre><code class="block text-xs " :class="language" v-html="formattedCode"></code></pre>
84+
<pre><code class="block text-xs" :class="lang" v-html="formattedCode"></code></pre>
7085
</div>
7186
</div>
7287
</template>

assets/components/Website/Docs/Sections/Tutorial/CreatingAnExercise.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ echo $count / $numberCount;</pre
6464
</ul>
6565

6666
<p>Our problem file might look like the following.</p>
67-
<CodeBlock lang="md">
67+
<CodeBlock lang="md" no-highlight>
6868
<pre>
6969
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).
7070

0 commit comments

Comments
 (0)