Skip to content

Commit 75b8f74

Browse files
committed
add reference number
Signed-off-by: Jinhao Hu <[email protected]>
1 parent 209acd7 commit 75b8f74

File tree

4 files changed

+95
-47
lines changed

4 files changed

+95
-47
lines changed

_plugins/side-by-side.rb

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,42 @@
22

33
module Jekyll
44
module SideBySideFilter
5+
def split_list_for_notes(list_node)
6+
items = list_node.css('> li')
7+
list_type = list_node.name
8+
9+
# Check if next sibling is a NOTE paragraph
10+
next_sibling = list_node.next_element
11+
has_note_following = next_sibling && next_sibling.text.strip.start_with?('[NOTE]')
12+
13+
if has_note_following && items.length > 1
14+
# Split: all items except last go in one list, last item in its own list
15+
first_items = items[0..-2]
16+
last_item = items[-1]
17+
18+
# Push the first group as one list
19+
first_list = "<#{list_type}>#{first_items.map(&:to_s).join}</#{list_type}>"
20+
@elements.push(first_list)
21+
22+
# Push the last item as its own list (will pair with the NOTE)
23+
last_list = "<#{list_type}>#{last_item.to_s}</#{list_type}>"
24+
@elements.push(last_list)
25+
else
26+
# No NOTE following, push the entire list as-is
27+
@elements.push(list_node.to_s)
28+
end
29+
end
30+
531
def side_by_side_with_subtitle(input, mode, subtitle)
632
@doc = Nokogiri::HTML::DocumentFragment.parse(input)
733
@elements = []
834
@doc.children.each do |node|
9-
@elements.push(node.to_s)
35+
# For lists with footnotes, split before the item with [NOTE] reference
36+
if (node.name == 'ul' || node.name == 'ol') && mode == 'comment'
37+
split_list_for_notes(node)
38+
else
39+
@elements.push(node.to_s)
40+
end
1041
end
1142
@result = '<table class="side-by-side"><tbody>'
1243
if mode == 'translation'
@@ -17,16 +48,24 @@ def side_by_side_with_subtitle(input, mode, subtitle)
1748
end
1849
end
1950
elsif mode == 'comment'
20-
@comments = ''
2151
@opened = false
2252
@elements.select { |e| !e.strip.empty? }.each do |e|
2353
if e.slice! '[NOTE] '
24-
@comments << e
54+
# Convert footnote references [^1] to styled markers
55+
e = e.gsub(/\[\^(\d+)\]/, '<sup class="note-ref">\1</sup>')
56+
# Output note immediately with the currently open row
57+
if @opened
58+
@result << %(<td>#{e}</td></tr>)
59+
@opened = false
60+
end
2561
else
62+
# Convert footnote references [^1] to styled markers in content
63+
e = e.gsub(/\[\^(\d+)\]/, '<sup class="note-ref">\1</sup>')
64+
# Close any previously opened row with empty comment
2665
if @opened
27-
@result << %(<td>#{@comments}</td></tr>)
28-
@comments = ''
66+
@result << %(<td></td></tr>)
2967
end
68+
# Open new row with this element
3069
if e.include? '<h1'
3170
@result << %(<tr><td>#{e}#{subtitle}</td>)
3271
else
@@ -35,6 +74,10 @@ def side_by_side_with_subtitle(input, mode, subtitle)
3574
@opened = true
3675
end
3776
end
77+
# Close any remaining open row
78+
if @opened
79+
@result << %(<td></td></tr>)
80+
end
3881
end
3982
@result << '</table></tbody>'
4083
return @result

_posts/2024-12-23-2024-retrospect.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ side_by_side: comment
99
* content
1010
{:toc}
1111

12-
今年总共读了 39 本书,看了 104 部影视,听了 600h+ 播客。在此记录分享一些个人喜爱的作品,夹杂着一些联想来帮助强化个人*信念之网*与记忆。
12+
今年总共读了 39 本书,看了 104 部影视,听了 600h+ 播客。在此记录分享一些个人喜爱的作品,夹杂着一些联想来帮助强化个人*信念之网[^1]*与记忆。
1313

14-
[NOTE] 信念之网:通过观察(实指法)传递信念,信念交织组成了一张巨大的信念之网,从内到外:自明性(逻辑真理)、常识、证言(权威)、假说。 ——《蒯因著作集(第5卷)》
14+
[NOTE] [^1]信念之网:通过观察(实指法)传递信念,信念交织组成了一张巨大的信念之网,从内到外:自明性(逻辑真理)、常识、证言(权威)、假说。 ——《蒯因著作集(第5卷)》
1515

1616
## 政治与社会
1717

@@ -33,9 +33,9 @@ side_by_side: comment
3333
* [世界的演变](https://book.douban.com/subject/26639302/):有关 19 世纪的诸多专题论述的合集
3434
* [十九世纪就在你家隔壁-高林](https://www.xiaoyuzhoufm.com/podcast-topic/6650610dc59d1e57576b6856):高老爷开讲!
3535

36-
### 德国
36+
### 德国[^2]
3737

38-
[NOTE] 今年比较大的一件事是去德国读博,因此试着去了解了一些德国历史。
38+
[NOTE] [^2]今年比较大的一件事是去德国读博,因此试着去了解了一些德国历史。
3939

4040
* [德意志贵族-一个群体的生活、历史与命运](https://book.douban.com/subject/36091018/):以概念辨析、衔级体系、历史演进与社会生活等角度描述德意志贵族,填充了中文世界空白(陆大鹏的播客也挺好听)
4141
* [默克尔](https://www.xiaoyuzhoufm.com/episode/615ad8a9ae1d32c4f86c1cd9)、中德建交历程([](https://www.xiaoyuzhoufm.com/episode/6369419e0d8d43263ef8ccd0)&[](https://www.xiaoyuzhoufm.com/episode/64e8ad2780c9ec4c5f467f2b)
@@ -50,11 +50,11 @@ side_by_side: comment
5050
### 一战&二战
5151

5252
* [战前37天(英德公务员视角)](https://movie.douban.com/subject/25823668/)[我们的父辈(德国年轻人视角)](https://movie.douban.com/subject/22623816/)
53-
* [万湖会议](https://movie.douban.com/subject/35769174/):毛骨悚然。无配乐长谈话,措辞用语惊人地熟悉。以后见之明审视今日之景,太多高效简单地将人变为数字的案例
53+
* [万湖会议](https://movie.douban.com/subject/35769174/)[^3]:毛骨悚然。无配乐长谈话,措辞用语惊人地熟悉。以后见之明审视今日之景,太多高效简单地将人变为数字的案例
5454
* [钢琴家](https://movie.douban.com/subject/1296736/):分食的糖块,跳跃的指尖和耳鸣的踉跄
5555
* [里斯本丸沉没](https://movie.douban.com/subject/30412658/)
5656

57-
[NOTE] 毒气在德语里竟然是 Giftgas…
57+
[NOTE] [^3]毒气在德语里竟然是 Giftgas…
5858

5959
## 性别
6060

@@ -68,10 +68,10 @@ side_by_side: comment
6868

6969
## 艺术
7070

71-
* [艺术的故事](https://book.douban.com/subject/3162991/):要说这本书的缺点,就是太薄,以作者的知识量和表述,再写十本都不嫌多
71+
* [艺术的故事](https://book.douban.com/subject/3162991/)[^4]:要说这本书的缺点,就是太薄,以作者的知识量和表述,再写十本都不嫌多
7272
* [抽象:设计的艺术](https://movie.douban.com/subject/26961333/),看完去读了《[周末速写》](https://book.douban.com/subject/30303814/),可爱
7373

74-
[NOTE] 下半年去逛了逛[柏林博物馆岛](https://www.instagram.com/p/DBI5lzUOGE_/?utm_source=ig_web_copy_link&igsh=MzRlODBiNWFlZA==),喜欢
74+
[NOTE] [^4]下半年去逛了逛[柏林博物馆岛](https://www.instagram.com/p/DBI5lzUOGE_/?utm_source=ig_web_copy_link&igsh=MzRlODBiNWFlZA==),喜欢
7575

7676
* [听音乐(Music: An Appreciation, 11th Editon)](https://book.douban.com/subject/30247531/):适合乐理初学者和历史爱好者,并在几场室内音乐会感受到古典音乐会现场的魅力
7777
* [Vibration 歪波音室-从零开始入门古典音乐](https://podcasts.apple.com/cn/podcast/%E6%97%B6%E5%85%89%E9%87%8C%E7%9A%84%E6%97%8B%E5%BE%8B-%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E5%85%A5%E9%97%A8%E5%8F%A4%E5%85%B8%E9%9F%B3%E4%B9%90/id1481229699?i=1000668532050&l=en-GB)[如何更好地入门古典音乐](https://podcasts.apple.com/cn/podcast/%E7%A9%BF%E8%B6%8A%E5%8E%86%E5%8F%B2%E7%9A%84%E9%9F%B3%E7%AC%A6-%E5%A6%82%E4%BD%95%E6%9B%B4%E5%A5%BD%E5%9C%B0%E5%85%A5%E9%97%A8%E5%8F%A4%E5%85%B8%E9%9F%B3%E4%B9%90/id1481229699?i=1000672950215&l=en-GB)[西方音乐简史-余志刚](https://book.douban.com/subject/2094547/)
@@ -112,9 +112,9 @@ side_by_side: comment
112112
* 推荐 [Rust Atomics and Locks : Low-Level Concurrency in Practice](https://book.douban.com/subject/35904892/),为 rust 并发编程造轮子,且循序渐进地进行系统优化,明白了各个结构背后实现的原因
113113
* [总结了一下造过地轮子](https://github.com/ihusharp),不过大多都是出于临摹,希望能在读博期间造出真正属于自己的轮子
114114

115-
## 对于 2025 的期待
115+
## 对于 2025 的期待[^5]
116116

117-
[NOTE] 偶尔会被一些过去所写下的只言片语所感动,因此希望能养成记录的习惯,给自己更多被感动的机会。
117+
[NOTE] [^5]偶尔会被一些过去所写下的只言片语所感动,因此希望能养成记录的习惯,给自己更多被感动的机会。
118118

119119
* 提高英语水平
120120
* 尽量写写周记

0 commit comments

Comments
 (0)