tangled
alpha
login
or
join now
ericwood.org
/
photos-site
1
fork
atom
A little app to serve my photography from my personal website
1
fork
atom
overview
issues
pulls
pipelines
language name on code blocks
ericwood.org
3 months ago
0bffef79
ca11abec
0/0
Waiting for spindle ...
+41
-6
3 changed files
expand all
collapse all
unified
split
src
blog.rs
views
blog
show
style.css
template.jinja
+18
-4
src/blog.rs
reviewed
···
53
53
fn write_pre_tag<'s>(
54
54
&self,
55
55
output: &mut dyn std::fmt::Write,
56
56
-
_attributes: HashMap<&'static str, std::borrow::Cow<'s, str>>,
56
56
+
attributes: HashMap<&'static str, std::borrow::Cow<'s, str>>,
57
57
) -> std::fmt::Result {
58
58
-
output.write_str("<pre class=\"highlighted\">")
58
58
+
if attributes.contains_key("lang") {
59
59
+
write!(
60
60
+
output,
61
61
+
"<pre class=\"highlighted\" data-language=\"{}\">",
62
62
+
attributes["lang"]
63
63
+
)
64
64
+
} else {
65
65
+
output.write_str("<pre class=\"highlighted\">")
66
66
+
}
59
67
}
60
68
61
69
fn write_code_tag<'s>(
62
70
&self,
63
71
output: &mut dyn std::fmt::Write,
64
64
-
_attributes: HashMap<&'static str, std::borrow::Cow<'s, str>>,
72
72
+
attributes: HashMap<&'static str, std::borrow::Cow<'s, str>>,
65
73
) -> std::fmt::Result {
66
66
-
output.write_str("<code>")
74
74
+
// why doesn't it give us the actual language string????? hmmm????
75
75
+
if attributes.contains_key("class") {
76
76
+
let lang = attributes["class"].replace("language-", "");
77
77
+
write!(output, "<code data-language=\"{}\">", lang)
78
78
+
} else {
79
79
+
output.write_str("<code>")
80
80
+
}
67
81
}
68
82
}
69
83
+20
-1
src/views/blog/show/style.css
reviewed
···
3
3
margin: 0 auto;
4
4
}
5
5
6
6
-
pre.highlighted {
6
6
+
.blog__body pre {
7
7
padding: 20px;
8
8
border-radius: 6px;
9
9
}
10
10
+
11
11
+
.blog__body pre > code {
12
12
+
position: relative;
13
13
+
display: block;
14
14
+
}
15
15
+
16
16
+
.blog__body pre > code:after {
17
17
+
content: attr(data-language);
18
18
+
position: absolute;
19
19
+
right: 0;
20
20
+
top: 0;
21
21
+
color: white;
22
22
+
opacity: 0.5;
23
23
+
transition: opacity 0.3s;
24
24
+
}
25
25
+
26
26
+
.blog__body pre:hover > code:after {
27
27
+
opacity: 0;
28
28
+
}
+3
-1
src/views/blog/show/template.jinja
reviewed
···
11
11
<p>
12
12
<time datetime="{{ post.published_at }}">{{ post.published_at }}</time>
13
13
</p>
14
14
-
{{ body }}
14
14
+
<div class="blog__body">
15
15
+
{{ body }}
16
16
+
</div>
15
17
</div>
16
18
{% endblock %}