Class: CBETA::P5aToHTMLForPDF

Inherits:
Object
  • Object
show all
Includes:
CbetaShare
Defined in:
lib/cbeta/p5a_to_html_for_pdf.rb

Overview

Convert CBETA XML P5a to HTML for PDF

You can get CBETA XML P5a from: github.com/cbeta-git/xml-p5a

Instance Method Summary collapse

Methods included from CbetaShare

#to_html

Constructor Details

#initialize(xml_root, out_root, opts = {}) ⇒ P5aToHTMLForPDF

Returns a new instance of P5aToHTMLForPDF.

Parameters:

  • xml_root (String)

    來源 CBETA XML P5a 路徑

  • out_root (String)

    輸出 HTML 路徑

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :graphic_base (String)

    folder of graphics

    • graphic_base/figures: 插圖圖檔位置

    • graphic_base/sd-gif: images for Siddham (悉曇字)

    • graphic_base/rj-gif: images for Ranjana (蘭札體)

  • :front_page (String)

    內文前可以加一段 HTML,例如「編輯說明」

  • :front_page_title (String)

    加在目錄的 front_page 標題

  • :back_page (String)

    內文後可以加一段 HTML,例如「版權聲明」

  • :back_page_title (String)

    加在目錄的 back_page 標題

  • :toc (Boolean)

    要不要放目次, 預設會有目次



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cbeta/p5a_to_html_for_pdf.rb', line 33

def initialize(xml_root, out_root, opts={})
  @config = {
    toc: true
  }
  @config.merge!(opts)
  
  @xml_root = xml_root
  @out_root = out_root
  @cbeta = CBETA.new
  @gaijis = CBETA::Gaiji.new
end

Instance Method Details

#convert(target = nil) ⇒ Object

將 CBETA XML P5a 轉為 HTML 供轉為 PDF

T 是大正藏的 ID, CBETA 的藏經 ID 系統請參考: www.cbeta.org/format/id.php

Examples:

for convert 大正藏全部:


c = CBETA::P5aToHTMLForPDF.new('/PATH/TO/CBETA/XML/P5a', '/OUTPUT/FOLDER')
c.convert('T')


53
54
55
56
57
58
# File 'lib/cbeta/p5a_to_html_for_pdf.rb', line 53

def convert(target=nil)
  return convert_all if target.nil?

  arg = target.upcase
  convert_collection(arg)
end