FEATURE: allow ruby tags in Markdown

This commit is contained in:
Sam 2018-08-03 11:47:36 +10:00
parent 880462a41c
commit 280c318c49
2 changed files with 25 additions and 1 deletions

View File

@ -183,5 +183,12 @@ const DEFAULT_LIST = [
"strong",
"sub",
"sup",
"ul"
"ul",
"ruby",
"ruby[lang]",
"rb",
"rb[lang]",
"rp",
"rt",
"rt[lang]"
];

View File

@ -1312,4 +1312,21 @@ HTML
expect(cooked).to eq("<p lang=\"fr\">tester</p><div lang=\"fr\">tester</div><span lang=\"fr\">tester</span>")
end
it "whitelists ruby tags" do
# read all about ruby chars at: https://en.wikipedia.org/wiki/Ruby_character
# basically it is super hard to remember every single rare letter when there are
# so many, so ruby tags provide a hint.
#
html = (<<~MD).strip
<ruby lang="je">
<rb lang="je">X</rb>
<rp>(</rp><rt lang="je"> ㄏㄢˋ </rt><rp>)</rp>
</ruby>
MD
cooked = PrettyText.cook html
expect(cooked).to eq(html)
end
end