Skip to content

Commit

Permalink
Fix the unsupported code snippets in rouge. (cotes2020#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Aug 15, 2020
1 parent ffbe413 commit 71ac3e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions _includes/refactor-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
-->
{% if _content contains '<pre class="highlight">' %}
{% assign _content = _content | replace: '<pre class="highlight"><code', '<code' %}
{% assign _content = _content | replace: '</code></pre>', '</code>' %}
{% assign _content = _content | replace: '<div class="highlight"><pre class="highlight"><code', '<div class="highlight"><code' %}
{% assign _content = _content | replace: '</code></pre></div>', '</code></div>' %}
{% endif %}

{{ _content }}
20 changes: 15 additions & 5 deletions assets/css/_addon/syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,30 @@ html[mode=dark] {

/*-- Codes Snippet --*/

%highlight-pre-bg {
%code-snippet-bg {
background: var(--highlight-bg-color);
}

%code-snippet-radius {
border-radius: 5px;
}

%code-snippet-padding {
padding: .8rem 1rem;
}

.highlighter-rouge {
background-color: var(--highlight-bg-color);
@extend %code-snippet-bg;
@extend %code-snippet-radius;
color: var(--highlighter-rouge-color);
margin-bottom: 1.2em; /* Override BS Inline-code style */
}

.highlight {
@extend %code-snippet-radius;
background: var(--highlight-bg-color);
@extend %code-snippet-bg;
@at-root figure#{&} {
background: var(--highlight-bg-color);
@extend %code-snippet-bg;
}
overflow: auto;
.lineno {
Expand Down Expand Up @@ -116,6 +120,12 @@ td.rouge-code {
padding-right: 1rem;
}

div>pre {
@extend %code-snippet-bg;
@extend %code-snippet-radius;
@extend %code-snippet-padding;
}

/* Hide line numbers for default, console, and terminal code snippets */
div {
&[class^='highlighter-rouge'],
Expand All @@ -126,7 +136,7 @@ div {
display: none;
}
td.rouge-code {
padding: .8rem 1rem;
@extend %code-snippet-padding;
}
}
}

0 comments on commit 71ac3e1

Please sign in to comment.