CBData HTML 規範

出自DILA Wiki
於 2015年1月19日 (一) 15:41 由 imported>Ray 所做的修訂 →‎app 校勘

一卷一檔

HTML 根據 XML <milestone unit="juan"> 切卷。檔名為冊號、經號、卷號,例如 T01n0001_001.htm、T01n0001_002.htm...。

HTML 檔內容架構:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="filename" content="T01n0001_018.htm" />
  <title>經名</title>
</head>
<body>
  <div id="body">內文</div>
  <div id="back">校勘與缺字資訊</div>
</body>
</html>

檔頭有以下標記表示本檔檔名:

<meta name="filename" content="T01n0001_018.htm" />

經名

經名轉為 head/title,例如:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>長阿含經</title>
</head>

區塊標記

byline

byline 轉為

<p class="byline"/>....</p>

div

附文

XML:

<div type="w">

HTML:

<div class='w'>

figure 插圖

XML:

<figure>

HTML:

<p class='figure'>...</p>

head

XML:

<head>

HTML:

<p class='head'>...</p>

juan

卷首或卷尾資訊

XML:

<juan>

HTML:

<p class='juan'>...</p>

lg 偈頌

HTML:

<div class='lg'>
  <div class='lg-row'>
    <div class='lg-cell'>諸惡莫作,</div>
    <div class='lg-cell'>諸善奉行,</div>
  </div>
  <div class='lg-row'>
    <div class='lg-cell'>自淨其意,</div>
    <div class='lg-cell'>是諸佛教。</div>
  </div>
</div>

text-indent

如果 XML <lg> 有 rend 屬性,而且屬性值之中有 text-indent,例如 T01n0001, p. 1c03

<lg rend="margin-left:1em;text-indent:-1em">
  <l>「比丘集法堂,</l><l>講說賢聖論;</l>
  <l>如來處靜室,</l><l>天耳盡聞知。</l>
  ...
  <l>無上天人尊,</l><l>記於過去佛。」</l>
</lg>

轉為 HTML 時,text-indent 屬性會移到第一個 lg-cell,以避免後面的 div 繼承到 text-indent:

<div class='lg' style="margin-left:1em;">
  <div class='lg-row'>
    <div class='lg-cell' style='text-indent:-1em'>「比丘集法堂,</div>
    <div class='lg=cell'>講說賢聖論;</div>
  </div>
  <div class='lg-row'>
    <div class='lg-cell'>如來處靜室,</div>
    <div class='lg-cell'>天耳盡聞知。</div>
  </div>
  ...
  <div class='lg-row'>
    <div class='lg-cell'>無上天人尊,</div>
    <div class='lg-cell'>記於過去佛。」</div>
  </div>
</lg>

三句一行

如果偈頌一行有三句,例 T85n2828

<lb n="1266a16" ed="T"/><l>法界亦通□</l><l>意珠恒自淨</l><l>身光照十方</l>
<lb n="1266a17" ed="T"/><l>至心無處住</l><l>解脫得清□</l><l>觀想如無想</l>

HTML 的 lg-row 就包三個 lg-cell:

<span class='lb' id='T85n2828_p1266a16'>T85n2828_p1266a16</span>
<div class='lg-row'>
  <div class="lg-cell"><span class='t' l='1266a16' w='1'>法界亦通□</span></div>
  <div class="lg-cell"><span class='t' l='1266a16' w='47'>意珠恒自淨</span></div>
  <div class="lg-cell"><span class='t' l='1266a16' w='94'>身光照十方</span></div>
</div>
<span class='lb' id='T85n2828_p1266a17'>T85n2828_p1266a17</span>
<div class='lg-row'>
  <div class="lg-cell"><span class='t' l='1266a17' w='1'>至心無處住</span></div>
  <div class="lg-cell"><span class='t' l='1266a17' w='47'>解脫得清□</span></div>
  <div class="lg-cell"><span class='t' l='1266a17' w='94'>觀想如無想</span></div>
</div>

p 段落

XML 的 p 一樣轉為 HTML 的 p,但在段落開頭加上「頁、欄、行資訊」,例如:

<p><span class="lineInfo">0001a05</span>夫宗極絕於稱謂,賢聖以之沖默;玄旨非言...</p>

行內標記

app 校勘

內文中以 <a class="noteAnchor"> 標示註標,例如:

<a class="noteAnchor" href="#n0001001"></a>長阿含經序

並於檔尾記錄校勘內容:

<div id="back">
  ...
  <span class="footnote" id="n0001001">此序依宋元明三本ニ依テ載ス</span>
  ...
</div>

[*] 校勘以 class="star" 記錄,例如:T01n0001_p0001a20

邪正難<a class="noteAnchor star" href="#n0001004"></a>

g 缺字

Big5 沒有的字,在 CBETA XML 中都以缺字標記 g 處理,轉成 HTML 時依下列優先順序處理

  1. 有 Unicode
    1. 在 Unicode 1.1 範圍內:呈現 Unicode
    2. 在 Unicode 1.1 範圍之外:預設呈現 Unicode 字元,但仍以缺字處理,以 <a class="gaijiAnchor"> 記錄,如: <a class="gaijiAnchor" href="#CB00400">𣽈</a>
  2. 沒有 Unicode
    1. 有 Unicode 通用字:預設呈現 Unicode 通用字,包缺字資訊
    2. 有 Big 通用字:預設呈現 Big 通用字,包缺字資訊
    3. 預設呈現組字式,轉出 HTML 如: <a class="gaijiAnchor" href="#CB00510">[國*瓜]</a>

並於檔尾 <div id="back"> 裡面以 <span class="gaijiInfo"> 記錄缺字資訊如下:

<div id="back">
  ....
  <span id="CB00400" class="gaijiInfo" figure_url="http://dict.cbeta.org/dict_word/gaiji-cb/00/CB00400.gif" nor="濡">𣽈</span>
  <span id="CB00510" class="gaijiInfo" figure_url="http://dict.cbeta.org/dict_word/gaiji-cb/00/CB00510.gif" nor="">[國*瓜]</span>
  ....
</div>

figure_url 屬性為缺字圖檔路徑。

nor 屬性為通用字,空字串表示無通用字。