-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Generate plain texts for Anki to import - Use <ruby> tags to annotate pronunciations
- Loading branch information
Showing
3 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,137 @@ | ||
# Anki Deck of Chinese Poetry (诗词) | ||
|
||
## Aiming | ||
|
||
This repository serves as a workspace for cotent collaboration. To download | ||
the deck, please go to https://ankiweb.net/shared/info/629702782 instead. | ||
|
||
## Template | ||
|
||
For your infomation, following templates are used in the deck: | ||
|
||
### Front Template | ||
|
||
```html | ||
<div id="title">《{{题目}}》— {{朝代}}·{{作者}}</div> | ||
``` | ||
|
||
### Back Template | ||
|
||
```html | ||
{{FrontSide}} | ||
|
||
<hr id="answer"> | ||
|
||
<div id="content">{{诗词}}</div> | ||
|
||
<hr> | ||
|
||
<div id="footnotes"> | ||
<div>{{脚注}}</div> | ||
<div>{{诗注}}</div> | ||
<div>{{小传}}</div> | ||
</div> | ||
|
||
<script> | ||
var content = document.getElementById('content') | ||
var contents = content.innerHTML.split('<br>').map(function(line) { | ||
return '<div class="hidden">' + line + '</div>' | ||
}) | ||
content.innerHTML = contents.join('') | ||
var footnotes = document.getElementById('footnotes') | ||
footnotes.classList = 'hidden' | ||
var clock = { | ||
index: 0, | ||
timer: null, | ||
ticks: -1, | ||
click: false, | ||
tick: function () { | ||
if (this.timer) { | ||
clearTimeout(this.timer) | ||
this.timer = null | ||
} | ||
if (this.ticks > 35 || this.click === true) { | ||
content.children[this.index].classList = '' | ||
this.index += 1 | ||
this.ticks = 0 | ||
this.click = false | ||
} else { | ||
this.ticks += 1 | ||
} | ||
if (this.index < contents.length) { | ||
this.timer = setTimeout(function () { clock.tick() }, 100) | ||
} else { | ||
footnotes.classList = '' | ||
} | ||
} | ||
} | ||
var handler = function () { | ||
if (clock.ticks > 5 && clock.ticks < 30) { | ||
clock.click = true | ||
clock.tick() | ||
clock.ticks = 5 | ||
} | ||
} | ||
document.addEventListener('click', handler) | ||
document.addEventListener('touchstart', handler) | ||
clock.tick() | ||
</script> | ||
``` | ||
|
||
### Styling | ||
|
||
```css | ||
html { | ||
font-size: 16px; | ||
font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif; | ||
} | ||
|
||
.hidden { | ||
visibility: hidden; | ||
} | ||
|
||
.card { | ||
color: black; | ||
background-color: white; | ||
text-align: center; | ||
} | ||
|
||
#title { | ||
font-size: 1.25rem; | ||
margin-bottom: 1em; | ||
} | ||
|
||
#content { | ||
padding: 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
#content > div { | ||
min-height: 1em; /* for blank lines */ | ||
} | ||
|
||
#footnotes { | ||
font-size: 1rem; | ||
text-align: left; | ||
} | ||
|
||
#footnotes > div { | ||
margin-bottom: 1em; | ||
} | ||
|
||
#footnotes ruby rt { | ||
font-size: 0.8rem; | ||
} | ||
``` | ||
|
||
## Acknowledgement | ||
|
||
Thanks to following projects which make this deck possible: | ||
|
||
- `chinese-poetry`: https://github.com/chinese-poetry/chinese-poetry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'digest' | ||
require 'yaml' | ||
|
||
task :default do | ||
fout = File.open('chinese-poetry.txt', 'w') | ||
|
||
fout.puts <<~END_OF_DOC | ||
#separator:Tab | ||
#html:true | ||
#columns:#{%w[题目 朝代 作者 诗词 脚注 诗注 小传].join("\t")} | ||
#tags column:8 | ||
#guid column:9 | ||
END_OF_DOC | ||
|
||
Dir['*/*.yml'].each do |file| | ||
poem = YAML.load(File.read(file)) | ||
|
||
fout.puts [ | ||
poem['题目'], poem['朝代'], poem['作者'], | ||
poem['诗词'].join('<br>'), | ||
poem['脚注'] ? '<ol><li>' + poem['脚注'].join('</li><li>') + '</li></ol>' : '', | ||
poem['诗注'], | ||
poem['小传'], | ||
poem['标签'] ? poem['标签'].join(' ') : '', | ||
Digest::MD5.hexdigest([poem['题目'], poem['朝代'], poem['作者']].join("\t")), | ||
].join("\t") | ||
end | ||
|
||
fout.close | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
题目: 将进酒 | ||
朝代: 唐 | ||
作者: 李白 | ||
诗词: | ||
- 君不见,黄河之水天上来,奔流到海不复回。 | ||
- 君不见,高堂明镜悲白发,朝如青丝暮成雪。 | ||
- 人生得意须尽欢,莫使金樽空对月。 | ||
- 天生我材必有用,千金散尽还复来。 | ||
- 烹羊宰牛且为乐,会须一饮三百杯。 | ||
- 岑夫子,丹丘生,将进酒,杯莫停。 | ||
- 与君歌一曲,请君为我倾耳听。 | ||
- | ||
- 钟鼓馔玉不足贵,但愿长醉不复醒。 | ||
- 古来圣贤皆寂寞,惟有饮者留其名。 | ||
- 陈王昔时宴平乐,斗酒十千恣欢谑。 | ||
- 主人何为言少钱,径须沽取对君酌。 | ||
- 五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。 | ||
脚注: | ||
- “将”字在“<ruby>将<rp>(</rp><rt>qiāng</rt><rp>)</rp></ruby>进酒”中表示“请”,在“呼儿<ruby>将<rp>(</rp><rt>jiāng</rt><rp>)</rp></ruby>出”中表示“拿”; | ||
- “岑夫子(岑勋)”和“丹丘生(元丹丘)”均是李白的好友。 |