0 votes

Is it possible to edit any of the content of the SFM file in PTXprint before printing it? The View+Edit section looks like I should be able to manually adjust the Final SFM, but nothing I edit here has any effect on the final result.

(For example, I’m using a Bible module to create a “Teachings of Jesus” booklet with lesson titles. I want to delete certain lines if the lesson title is the same as the section heading – i.e. the \s line that imports via a \ref marker. I don’t want the “Love One Another” heading if the lesson title is already “Love One Another”).

If not, can PTXprint export a file in any formats that can be edited in a word processor?

Thanks

PTXprint by (118 points)

3 Answers

0 votes

Thanks Dan for your good question. Welcome to the community!

There are many good reasons why we DON’T want people to be editing the USFM files manually during the layout/typesetting process, so the Viewer that shows you the “processed USFM” which gets fed into the typesetting program (XeTeX) is primarily there for diagnostic purposes. It shows the end result of all the pre-processing that has taken place due to the multitude of settings in the App.

HOWEVER, there is good news: There already is a mechanism to do exactly what you’re asking for by automating it completely through clever find and replace rules (called Regular Expressions, or RegEx). On the advanced tab is an option to enable PrintDraftChanges.txt to be applied to the text.

2021-01-20 21_41_41-Window

Once you’ve clicked on Edit, you might see a file with a bunch of rules in it, or there may just be an empty file in the editor.

# A rule in this PrintDraftChange.txt file uses this syntax:
"Find what" > "Replace with"

So for this “strip out the duplicate headings” task, you’ll need to add a RegEx rule which will look something like this:

"\\rem (.+?)\r?\n\\s \1\r?\n" > "\\s \1\r\n"

image

If what I have above doesn’t quite match your needs, then adjust it as needed (for example replace \rem with whatever marker you have in your text). I highly recommend using a site like regex101.com to refine your expression, and test out your Find and Substitution strings on a small subset of your data until it works.

I hope this helps, but if you’re still stranded, please ask for further clarification.

by (2.6k points)
reshown
0 votes

Hi Mark,
Thanks for the welcome and the prompt reply. I guess I don’t understand enough about what the software is doing to see why editing the USFM files manually is problematic. So far, I’ve been doing all my layout in Word and that of course allows me to edit any content I want. Other “publishing” software like Scripture App Builder operates directly from SFM files which I can manually edit. Is there no way in PTXprint to have the input come directly from a saved SFM file?

Thanks also for describing how to use Regular Expressions and for copying the rule. Unfortunately, I am totally unfamiliar with the use of Regular Expressions and it seems unlikely that I will learn to create appropriate RegEx rules, when what I usually want is simply to change one word or delete or add one line.

If I can’t edit the SFM file in PTXprint is there something I can do to the Bible Module in Paratext to adjust what PTXprint will do with it? (I know I can add lines in the Bible Module, but it’s actually the source text coming via a \ref marker that I usually want to adjust).

If I can’t make these small, individual adjustments without having to learn regular expressions, I’ll probably just go back to editing layout in Word. This would be unfortunate since PTXprint seems so wonderfully designed to do what I’m trying to do in a tiny fraction of the time.

Thanks again for your help!

by (118 points)

Dan -
If the issue is that you need to make adjustments to the text when it comes from the main text into the module, this is accomplished using the \rep marker (replace). If you look at the help documentation on modules you can see how this is used. Search help for “How do I edit the specification for a Bible module?” and then look at the section on “More on text replacement rules.”

Hi again Dan,

Yes, Phil is right that you can build similar find-replace rules into the module itself using the \rep marker in the module. The trick there is to avoid inadvertently changing the text in places where you weren’t intending a change to be made.

In comparing PTXprint to Word, I understand that you are expecting to be able to edit the final text, but that is NOT what PTXprint is intended for. We only do format/layout/typesetting and require that the data we get passed is already “final” and marked up with the appropriate USFM markers. We need to stick with this approach in order to maintain the integrity of scripture that is being typeset. Imagine if someone inadvertently edited/deleted text that was being typeset - that wouldn’t be a good thing.

Which is possible (preferably in the module as Phil suggested using \rep rules) or in PrintDraftChanges.txt using similar rules:
“And he said” > “And Adam said”
“on a plate.” > “on a plate so that she could be sure he was dead.”

In other words, you don’t HAVE to make up complicated RegExs if you don’t want to. I was just trying to help you by showing how powerful it is (one generic RegEx rule would take care of ALL Section Heading repetition deletions in the entire file).

…yes I agree. It is much better to set up a process by which the whole task can be run again and again at the click of a button than to have a system where you have to re-export AND re-EDIT the text every time something changes in the source text (which is always a possibility, and quite likely in most projects).

So, to summarize - YES there are existing ways to achieve what you want. It will take a bit of practice to set up and get right, but when you’ve got used to it, you will find that it is much more efficient and reliable than manually editing exported files.

0 votes

Mark and Phillip,

Thanks again for the prompt replies. I have used the \rep marker and it’s a reasonable way to address my issues. I really appreciate that helpful input!

I was going to write and ask if you had any ideas about solving another problem I was facing, but in the process of describing it I figured out a solution. I’ll describe it below in case it’s helpful to others (and you can feel free to let me know if there’s a better way to do this).

My problem:
The first occurrence of an unfamiliar term (like “Passover” in Luke 22:1) gets the very important footnote information, but the Bible module begins after this first occurrence (at 22:14).
One of the reasons I had hoped to edit the SFM file coming into PTXprint was to manually add this footnote information.

I fixed this with a \rep marker by copying the word “Passover” and its corresponding footnote from Luke 22:1 and using it as a replacement for the word Passover in verse 7. You have to be sure to get enough surrounding context from the verse in question so that the replacement will only apply to the one occurrence you’re interested in. This also enabled me to edit the verse reference in the footnote.

Copying things into Notepad made this process a lot easier for me.

Thanks again for the help!

by (118 points)
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
For where two or three gather in my name, there am I with them.
Matthew 18:20
2,645 questions
5,394 answers
5,065 comments
1,437 users