Class: CBETA::P5aToHTML
- Inherits:
-
Object
- Object
- CBETA::P5aToHTML
- Defined in:
- lib/cbeta/p5a_to_html.rb
Overview
處理 CBETA XML P5a
CBETA XML P5a 可由此取得: github.com/cbeta-git/xml-p5a
轉檔規則請參考: wiki.ddbc.edu.tw/pages/CBETA_XML_P5a_轉_HTML
Instance Method Summary collapse
-
#convert(arg = nil) ⇒ Object
將 CBETA XML P5a 轉為 HTML.
-
#initialize(xml_root, out_root) ⇒ P5aToHTML
constructor
- xml_root
- 來源 CBETA XML P5a 路徑 out_root
-
輸出 HTML 路徑.
Constructor Details
#initialize(xml_root, out_root) ⇒ P5aToHTML
- xml_root
-
來源 CBETA XML P5a 路徑
- out_root
-
輸出 HTML 路徑
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cbeta/p5a_to_html.rb', line 23 def initialize(xml_root, out_root) @xml_root = xml_root @out_root = out_root @gaijis = CBETA::Gaiji.new # 載入 unicode 1.1 字集列表 fn = File.join(File.dirname(__FILE__), 'unicode-1.1.json') json = File.read(fn) @unicode1 = JSON.parse(json) end |
Instance Method Details
#convert(arg = nil) ⇒ Object
將 CBETA XML P5a 轉為 HTML
Example for convert 大正藏第一冊:
x2h = CBETA::P5aToHTML.new('/PATH/TO/CBETA/XML/P5a', '/OUTPUT/FOLDER')
x2h.convert('T01')
Example for convert 大正藏全部:
x2h = CBETA::P5aToHTML.new('/PATH/TO/CBETA/XML/P5a', '/OUTPUT/FOLDER')
x2h.convert('T')
T 是大正藏的 ID, CBETA 的藏經 ID 系統請參考: www.cbeta.org/format/id.php
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cbeta/p5a_to_html.rb', line 47 def convert(arg=nil) return convert_all if arg.nil? arg.upcase! if arg.size == 1 handle_collection(arg) else if arg.include? '..' arg.match(/^([^\.]+?)\.\.([^\.]+)$/) { handle_vols($1, $2) } else handle_vol(arg) end end end |