Skip to content

Commit 319f32d

Browse files
committed
feat: highlight specific code lines
1 parent 5f8ec7f commit 319f32d

File tree

5 files changed

+27
-182
lines changed

5 files changed

+27
-182
lines changed

_posts/2019-08-08-text-and-typography.md

Lines changed: 20 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -14,187 +14,26 @@ image:
1414
alt: Responsive rendering of Chirpy theme on multiple devices.
1515
---
1616

17-
## Headings
18-
19-
<!-- markdownlint-capture -->
20-
<!-- markdownlint-disable -->
21-
# H1 — heading
22-
{: .mt-4 .mb-0 }
23-
24-
## H2 — heading
25-
{: data-toc-skip='' .mt-4 .mb-0 }
26-
27-
### H3 — heading
28-
{: data-toc-skip='' .mt-4 .mb-0 }
29-
30-
#### H4 — heading
31-
{: data-toc-skip='' .mt-4 }
32-
<!-- markdownlint-restore -->
33-
34-
## Paragraph
35-
36-
Quisque egestas convallis ipsum, ut sollicitudin risus tincidunt a. Maecenas interdum malesuada egestas. Duis consectetur porta risus, sit amet vulputate urna facilisis ac. Phasellus semper dui non purus ultrices sodales. Aliquam ante lorem, ornare a feugiat ac, finibus nec mauris. Vivamus ut tristique nisi. Sed vel leo vulputate, efficitur risus non, posuere mi. Nullam tincidunt bibendum rutrum. Proin commodo ornare sapien. Vivamus interdum diam sed sapien blandit, sit amet aliquam risus mattis. Nullam arcu turpis, mollis quis laoreet at, placerat id nibh. Suspendisse venenatis eros eros.
37-
38-
## Lists
39-
40-
### Ordered list
41-
42-
1. Firstly
43-
2. Secondly
44-
3. Thirdly
45-
46-
### Unordered list
47-
48-
- Chapter
49-
- Section
50-
- Paragraph
51-
52-
### ToDo list
53-
54-
- [ ] Job
55-
- [x] Step 1
56-
- [x] Step 2
57-
- [ ] Step 3
58-
59-
### Description list
60-
61-
Sun
62-
: the star around which the earth orbits
63-
64-
Moon
65-
: the natural satellite of the earth, visible by reflected light from the sun
66-
67-
## Block Quote
68-
69-
> This line shows the _block quote_.
70-
71-
## Prompts
72-
73-
<!-- markdownlint-capture -->
74-
<!-- markdownlint-disable -->
75-
> An example showing the `tip` type prompt.
76-
{: .prompt-tip }
77-
78-
> An example showing the `info` type prompt.
79-
{: .prompt-info }
80-
81-
> An example showing the `warning` type prompt.
82-
{: .prompt-warning }
83-
84-
> An example showing the `danger` type prompt.
85-
{: .prompt-danger }
86-
<!-- markdownlint-restore -->
87-
88-
## Tables
89-
90-
| Company | Contact | Country |
91-
| :--------------------------- | :--------------- | ------: |
92-
| Alfreds Futterkiste | Maria Anders | Germany |
93-
| Island Trading | Helen Bennett | UK |
94-
| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |
95-
96-
## Links
97-
98-
<http://127.0.0.1:4000>
99-
100-
## Footnote
101-
102-
Click the hook will locate the footnote[^footnote], and here is another footnote[^fn-nth-2].
103-
104-
## Inline code
105-
106-
This is an example of `Inline Code`.
107-
108-
## Filepath
109-
110-
Here is the `/path/to/the/file.extend`{: .filepath}.
111-
112-
## Code blocks
113-
114-
### Common
115-
116-
```text
117-
This is a common code snippet, without syntax highlight and line number.
118-
```
119-
120-
### Specific Language
121-
122-
```bash
123-
if [ $? -ne 0 ]; then
124-
echo "The command was not successful.";
125-
#do the needful / exit
126-
fi;
127-
```
128-
129-
### Specific filename
130-
131-
```sass
132-
@import
133-
"colors/light-typography",
134-
"colors/dark-typography";
17+
```diff
18+
+ asd
19+
- xyz
13520
```
136-
{: file='_sass/jekyll-theme-chirpy.scss'}
137-
138-
## Mathematics
139-
140-
The mathematics powered by [**MathJax**](https://www.mathjax.org/):
141-
142-
$$
143-
\begin{equation}
144-
\sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6}
145-
\label{eq:series}
146-
\end{equation}
147-
$$
148-
149-
We can reference the equation as \eqref{eq:series}.
150-
151-
When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
152-
153-
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
154-
155-
## Mermaid SVG
15621

157-
```mermaid
158-
gantt
159-
title Adding GANTT diagram functionality to mermaid
160-
apple :a, 2017-07-20, 1w
161-
banana :crit, b, 2017-07-23, 1d
162-
cherry :active, c, after b a, 1d
22+
```html
23+
<html>
24+
<head>
25+
<script src="asd"></script>
26+
<style src="asd"></style>
27+
</head>
28+
</html>
16329
```
164-
165-
## Images
166-
167-
### Default (with caption)
168-
169-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" }
170-
_Full screen width and center alignment_
171-
172-
### Left aligned
173-
174-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal}
175-
176-
### Float to left
177-
178-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left}
179-
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum.
180-
181-
### Float to right
182-
183-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right}
184-
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum.
185-
186-
### Dark/Light mode & Shadow
187-
188-
The image below will toggle dark/light mode based on theme preference, notice it has shadows.
189-
190-
![light mode only](/posts/20190808/devtools-light.png){: .light .w-75 .shadow .rounded-10 w='1212' h='668' }
191-
![dark mode only](/posts/20190808/devtools-dark.png){: .dark .w-75 .shadow .rounded-10 w='1212' h='668' }
192-
193-
## Video
194-
195-
{% include embed/youtube.html id='Balreaj8Yqs' %}
196-
197-
## Reverse Footnote
198-
199-
[^footnote]: The footnote source
200-
[^fn-nth-2]: The 2nd footnote source
30+
{: mark_lines='2 4 5'}
31+
32+
{% highlight ruby linenos mark_lines="2 4 5" %}
33+
def hello_world
34+
puts 'Hello, world!' # highlighted
35+
name = "ChatGPT"
36+
puts "Hello, #{name}" # highlighted
37+
return name # highlighted
38+
end
39+
{% endhighlight %}

_sass/base/_syntax.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
-ms-user-select: none;
5656
user-select: none;
5757
}
58+
59+
.hll {
60+
background-color: var(--highlight-mark-line-color);
61+
}
5862
} /* .highlight */
5963

6064
code {

_sass/themes/_dark.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
--highlight-bg-color: #151515;
104104
--highlighter-rouge-color: #c9def1;
105105
--highlight-lineno-color: #808080;
106+
--highlight-mark-line-color: #90a959;
106107
--inline-code-bg: rgb(255 255 255 / 5%);
107108
--code-color: #b0b0b0;
108109
--code-header-text-color: #6a6a6a;

_sass/themes/_light.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
--highlight-bg-color: #f6f8fa;
100100
--highlighter-rouge-color: #3f596f;
101101
--highlight-lineno-color: #9e9e9e;
102+
--highlight-mark-line-color: #90a959;
102103
--inline-code-bg: rgb(25 25 28 / 5%);
103104
--code-color: #3a3a3a;
104105
--code-header-text-color: #a3a3a3;

jekyll-theme-chirpy.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
2525

2626
spec.required_ruby_version = "~> 3.1"
2727

28-
spec.add_runtime_dependency "jekyll", "~> 4.3"
28+
spec.add_runtime_dependency "jekyll", "~> 4.4"
2929
spec.add_runtime_dependency "jekyll-paginate", "~> 1.1"
3030
spec.add_runtime_dependency "jekyll-seo-tag", "~> 2.8"
3131
spec.add_runtime_dependency "jekyll-archives", "~> 2.2"

0 commit comments

Comments
 (0)