Skip to content

Commit

Permalink
[Fix] Code HighLIght
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed Aug 6, 2021
1 parent bd4970e commit 6c57b12
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pages/oj/views/forum/Forum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--ForumPost main-->
<Panel :padding="40" shadow>
<div slot="title">{{forumpost.title}}</div>
<div id="forumpost-content" class="markdown-body" v-katex>
<div id="forumpost-content" class="markdown-body" v-katex v-highlight="code">
<p class="title">{{$t('m.Forum_Content')}}</p>
<p class="content" v-html="forumpost.content"></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/oj/views/problem/Problem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--problem main-->
<Panel :padding="40" shadow>
<div slot="title">{{problem.title}}</div>
<div id="problem-content" class="markdown-body" v-katex>
<div id="problem-content" class="markdown-body" v-katex v-highlight="code">
<p class="title">{{$t('m.Description')}}</p>
<p class="content" v-html=problem.description></p>
<!-- {{$t('m.music')}} -->
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
deep: true,
bind: function (el, binding) {
// on first bind, highlight all targets
Array.from(el.querySelectorAll('code')).forEach((target) => {
Array.from(el.querySelectorAll('pre code')).forEach((target) => {
// if a value is directly assigned to the directive, use this
// instead of the element content.
if (binding.value) {
Expand All @@ -25,7 +25,7 @@ export default {
},
componentUpdated: function (el, binding) {
// after an update, re-fill the content and then highlight
Array.from(el.querySelectorAll('code')).forEach((target) => {
Array.from(el.querySelectorAll('pre code')).forEach((target) => {
if (binding.value) {
target.textContent = binding.value
}
Expand Down

0 comments on commit 6c57b12

Please sign in to comment.