Skip to content

Commit b6eee54

Browse files
committed
Fix the unsupported code snippets in rouge. (cotes2020#101)
1 parent b61461e commit b6eee54

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

_includes/refactor-content.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
2121
-->
2222
{% if _content contains '<pre class="highlight">' %}
23-
{% assign _content = _content | replace: '<pre class="highlight"><code', '<code' %}
24-
{% assign _content = _content | replace: '</code></pre>', '</code>' %}
23+
{% assign _content = _content | replace: '<div class="highlight"><pre class="highlight"><code', '<div class="highlight"><code' %}
24+
{% assign _content = _content | replace: '</code></pre></div>', '</code></div>' %}
2525
{% endif %}
2626

2727
{{ _content }}

assets/css/_addon/syntax.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,30 @@ html[mode=dark] {
3030

3131
/*-- Codes Snippet --*/
3232

33-
%highlight-pre-bg {
33+
%code-snippet-bg {
3434
background: var(--highlight-bg-color);
3535
}
3636

3737
%code-snippet-radius {
3838
border-radius: 5px;
3939
}
4040

41+
%code-snippet-padding {
42+
padding: .8rem 1rem;
43+
}
44+
4145
.highlighter-rouge {
42-
background-color: var(--highlight-bg-color);
46+
@extend %code-snippet-bg;
4347
@extend %code-snippet-radius;
4448
color: var(--highlighter-rouge-color);
4549
margin-bottom: 1.2em; /* Override BS Inline-code style */
4650
}
4751

4852
.highlight {
4953
@extend %code-snippet-radius;
50-
background: var(--highlight-bg-color);
54+
@extend %code-snippet-bg;
5155
@at-root figure#{&} {
52-
background: var(--highlight-bg-color);
56+
@extend %code-snippet-bg;
5357
}
5458
overflow: auto;
5559
.lineno {
@@ -116,6 +120,12 @@ td.rouge-code {
116120
padding-right: 1rem;
117121
}
118122

123+
div>pre {
124+
@extend %code-snippet-bg;
125+
@extend %code-snippet-radius;
126+
@extend %code-snippet-padding;
127+
}
128+
119129
/* Hide line numbers for default, console, and terminal code snippets */
120130
div {
121131
&[class^='highlighter-rouge'],
@@ -126,7 +136,7 @@ div {
126136
display: none;
127137
}
128138
td.rouge-code {
129-
padding: .8rem 1rem;
139+
@extend %code-snippet-padding;
130140
}
131141
}
132142
}

0 commit comments

Comments
 (0)