Blockcodes
An article with various blocks of highlighted code snippets.
HTML code using crase ` ` `
<html>
<head> </head>
<body>
<p>Hello, World!</p>
</body>
</html>
Ruby code using crase ` ` `
include Enumerable
module Foo
class Bar
LIPSUM = "lorem ipsum dolor sit"
attr_reader :layout
def initialize
@layout = Layout.new
end
# instance method
def profile
measure_time do
compile layout
layout.render_with Bar::LIPSUM
end
rescue ArgumentError
false
end
end
end
# Execute code
Foo::Bar.new.profile
Sass code using crase ` ` `
@import "base"
.card
display: inline-block
margin: 0
padding: 0
&:hover
color: #ab45ef;
Block raw
{% assign foo = page.foo | bar: 'baz' %}
{{ foo }}
HTML using { % highlight % } with numbers
1
2
3
4
5
6
7
8
9
<html>
<head>
<meta charset="utf-8" />
<title>Hello World</title>
</head>
<body>
<p>Hello, World!</p>
</body>
</html>
Rust using { % highlight % } with numbers and marking lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// main.rs
use std::collections::HashMap;
fn main() {
let workflow: HashMap<&str, HashMap<&str, Vec<&str>>> = HashMap::from([
(
"My Main Tech Stack",
HashMap::from([
("Languages", vec!["Rust", "Python", "Shell Script"]),
("Frontend", vec!["HTML", "CSS", "SASS", "Bootstrap", "Jekyll"]),
("Database", vec!["PostGreSQL", "MySQL"]),
("Tools", vec!["VSCode", "Vim", "JetBrains IDEs", "Git"]),
("OS", vec!["Linux", "Windows"]),
]),
),
]);
let yt_link: &str = "https://www.youtube.com/c/williamcanin";
println!("Hello, World!");
println!("My name is William, and I am a programming and hacking enthusiast.");
for (key, value) in &workflow {
println!("{}:", key);
for (inner_key, inner_value) in value {
println!(" {}: {:?}", inner_key, inner_value);
}
}
println!("YouTube::> {}", yt_link);
}