mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-07 14:35:26 +02:00
simplify code
This commit is contained in:
parent
5a753a8879
commit
cb30eef9bd
4 changed files with 4 additions and 29 deletions
2
public/dist/code-styling.bundle.js
vendored
2
public/dist/code-styling.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
public/dist/code-styling.css
vendored
2
public/dist/code-styling.css
vendored
|
@ -1,2 +1,2 @@
|
|||
.hljs{display:block;background:#fff;padding:.5em;color:#333;overflow-x:auto}.hljs-comment,.hljs-meta{color:#969896}.hljs-emphasis,.hljs-quote,.hljs-string,.hljs-strong,.hljs-template-variable,.hljs-variable{color:#df5000}.hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d}.hljs-attribute,.hljs-bullet,.hljs-literal,.hljs-symbol{color:#0086b3}.hljs-name,.hljs-section{color:#63a35c}.hljs-tag{color:#333}.hljs-attr,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-title{color:#795da3}.hljs-addition{color:#55a532;background-color:#eaffea}.hljs-deletion{color:#bd2c00;background-color:#ffecec}.hljs-link{text-decoration:underline}
|
||||
.diff{width:100%;display:inline-block}.diff-plus{color:green!important;background-color:rgba(0,128,0,.21)}.diff-minus{color:red!important;background-color:rgba(255,0,0,.21)}
|
||||
.diff-plus{color:green!important;background-color:rgba(0,128,0,.21)}.diff-minus{color:red!important;background-color:rgba(255,0,0,.21)}
|
||||
|
|
|
@ -48,31 +48,8 @@ export default class CodeStyler {
|
|||
|
||||
Array.from(codeBlocks).forEach(block => {
|
||||
hljs.highlightBlock(block);
|
||||
console.log(block);
|
||||
this.addDiffHighlight(block);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through all children and add diff highlighting
|
||||
* @param {HTMLElement} node - node to sort
|
||||
*/
|
||||
addDiffHighlight(node) {
|
||||
while (node) {
|
||||
const diffPlusRegEx = /\n([+].*)/ig;
|
||||
|
||||
if (diffPlusRegEx.test(node.innerHTML)) {
|
||||
node.innerHTML = node.innerHTML.replace(diffPlusRegEx, '\n<span class="diff diff-plus">$1</span>');
|
||||
}
|
||||
|
||||
const diffMinusRegEx = /\n([-].*)/ig;
|
||||
|
||||
if (diffMinusRegEx.test(node.innerHTML)) {
|
||||
node.innerHTML = node.innerHTML.replace(diffMinusRegEx, '\n<span class="diff diff-minus">$1</span>');
|
||||
}
|
||||
|
||||
this.addDiffHighlight(node.firstElementChild);
|
||||
node = node.nextSibling;
|
||||
}
|
||||
block.innerHTML = block.innerHTML.replace(/\n([+].*)/ig, '\n<span class="diff diff-plus">$1</span>');
|
||||
block.innerHTML = block.innerHTML.replace(/\n([-].*)/ig, '\n<span class="diff diff-minus">$1</span>'); });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
.diff {
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
&-plus {
|
||||
color: green !important;
|
||||
background-color: rgba(0, 128, 0, 0.21);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue