对于几年前我们做的一个需要类似处理的项目,我们将引用放在标准的西方样式引用中,这样 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