Skip to content

Commit

Permalink
fix: fixed the overflow of codeblock
Browse files Browse the repository at this point in the history
  • Loading branch information
akinoccc committed Feb 13, 2023
1 parent ef56ed9 commit 814e15a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 2 additions & 4 deletions source/css/_highlight.styl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.code-block-container
overflow: hidden
size(100%, auto)
margin: 10px 0
margin: 15px 0
box-sizing: content-box
border-radius: $border-radius-base
box-shadow: 0 5px 10px 0 rgb(0, 0, 0, 0.4)
Expand Down Expand Up @@ -65,17 +65,15 @@

pre
overflow-y: hidden
overflow-x: auto
margin: 0
padding: 0.8em
white-space: pre-wrap
transition: all 0.5s

.hljs
overflow-x: auto
display: block
width: 100%
white-space: pre-wrap
white-space: pre
color: #abb2bf

.hljs-comment
Expand Down
13 changes: 13 additions & 0 deletions source/js/page/codeblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ export default class CodeBlock {
}

_initHighlightStyle() {
hljs.registerLanguage('vue', () => {
return {
// contains: TYPES,
// keywords: LITERALS,
// illegal: '\\S'
}
});
hljs.registerLanguage('react', () => ({}));
$(document).on('DOMContentLoaded', () => {
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
});
});
hljs.highlightAll();
$('pre').each(function () {
const language = $(this).children(':first')[0].result.language || 'TEXT';
Expand Down

0 comments on commit 814e15a

Please sign in to comment.