對於我們幾年前做的一個需要進行類似處理的專案,我們將引用設為標準的西方樣式引用,這樣 Paratext(以及 DBL)就能正常運作,並執行所有必要的檢查。但在出版前,我們使用 Python 腳本將其轉換為正確格式。以下是 Python 腳本中相關的正則表達式(請注意,對於引用的每種形式,例如多章、有節號或無節號等,都有單獨的轉換表達式):
# turn cross references into their long forms
# Takwiin 2:1; 5:2 or Takwiin 2:1-5; 5:6-9
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+(-\d+)?); (\d+):(\d+(-\d+)?\\\+xt\*)',
'\\1 fasul \\3 aaya \\4 wa fasul \\6 aaya \\7\\\+xt*', sText)
# Takwiin 2; 4
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+); (\d+\\\+xt\*)',
'\\1 fasul \\3 wa fasul \\4', sText)
# Takwiin 2:1
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+\\\+xt\*)',
'\\1 fasul \\3 aaya \\4', sText)
# Takwiin 2:1-5
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+-\d+\\\+xt\*)',
'\\1 fasul \\3 aaya \\4', sText)
# Takwiin 2 or Takwiin 1–2
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+(–\d+)?\\\+xt\*)',
'\\1 fasul \\3', sText)
如果我今天進行相同的排版工作,我會使用 PTXprint,並將這些更改放入 Changes.txt 檔案中。
請注意,這些表達式可能無法處理某些章/節表達式;這是針對特定專案的,我知道所有引用表達式格式的範圍。例如,我不認為這能處理三個章號,例如「bookname ch1; ch2; ch3」。如果專案中有這種情況,你需要添加新的表達式,或找到一種方法來擴展現有表達式(前者可能更容易……)。
另外請注意,當你在 DBL 輸出的文本中查看引用時,例如在 YouVersion 中,你只會看到西方引用格式,而不是你的「rukuh # ayat #」。這是因為 YouVersion 在處理和格式化文本方面沒有複雜的功能——它只是以 HTML 形式輸出,並希望看起來不錯。但如果你使用 SAB 創建聖經應用程式,你可以運行類似的正則表達式來獲得相同的預期效果。
@anon175865 在某些方面,這個 YouVersion 問題類似於標點符號周圍有空格時換行混亂的問題。也許我們應該有一個「建議排版規則」檔案,附加到專案並與專案一起儲存在 DBL 中。這樣,如果 YouVersion 在顯示文本時應用這些更改,它可能會做得更好。這在某種意義上允許文本的數據格式與呈現格式之間存在差異。然後,根據呈現類型,你可能需要選擇應用哪些規則。總之,只是稍微展望一下……
希望這能幫到你,
jeffh
For a project we did a couple of years ago which needed to do the same sort of thing, we put the references in normal Western style references, so that Paratext (and the DBL) is happy, and can do all of the checks it needs to do. But before publishing we processed with a Python script to convert them to the proper format. Here are the relevant Regular Expressions from the python script (note that there is a separate conversion expression for each form of the reference, whether multiple chapters, with verse numbers or no, etc.):
# turn cross references into their long forms
# Takwiin 2:1; 5:2 or Takwiin 2:1-5; 5:6-9
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+(-\d+)?); (\d+):(\d+(-\d+)?\\\+xt\*)',
'\\1 fasul \\3 aaya \\4 wa fasul \\6 aaya \\7\\\+xt*', sText)
# Takwiin 2; 4
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+); (\d+\\\+xt\*)',
'\\1 fasul \\3 wa fasul \\4', sText)
# Takwiin 2:1
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+\\\+xt\*)',
'\\1 fasul \\3 aaya \\4', sText)
# Takwiin 2:1-5
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+):(\d+-\d+\\\+xt\*)',
'\\1 fasul \\3 aaya \\4', sText)
# Takwiin 2 or Takwiin 1–2
sText = re.sub(r'(\\\+xt (\d )?[A-Za-zʼ -]+) (\d+(–\d+)?\\\+xt\*)',
'\\1 fasul \\3', sText)
If I was doing the same typesetting today, I would use PTXprint, and put those changes in the Changes.txt file.
Note that there may be chapter/verse expressions that aren’t handled by these expressions; this was for a specific project and I knew what the range of all of the reference expression formats was. For example, I don’t believe this would handle three chapter numbers, e.g. “bookname ch1; ch2; ch3”. If you have that in your project, you would need to add a new expression, or find a way to extend the existing expressions (probably the former is easier…).
Note also that when you look at your references in text coming out of the DBL, e.g. in YouVersion, you will just get the Western reference format, not your “rukuh # ayat #”. That’s because YouVersion doesn’t have any sophistication around processing and formatting text - it just dumps it out in HTML, and hope it looks good. But if you create Scripture apps with SAB, you can run similar Regular Expressions to get that same desired behavior.
@anon175865 In some ways this YouVersion problem is a similar to the problem of messing up line breaks when there are spaces around punctuation. Maybe we should have a “suggested typesetting rules” file that gets attached to the project and stored with the project in the DBL. Then if YouVersion applied those changes when it’s displaying a text, it might do a better job. That would in a sense allow a difference between the data format and the presentation format of the text. And then, depending on the type of presentation, you may need to choose what sorts of rules to apply. Anyway, just greenlighting a bit there…
Hope that helps,
jeffh
機器翻譯自 English