I’m thinking I would like to remove all major reference linked references. I don’t see why someone would want to read multiple chapter major reference in a popup window. I would like to have the reference remain in the text however remove the link to the reference. Is there a way to do a change within SAB to omit, bypass, skip or the like of a “mr” linked reference?
Example from USX: para style=“mr”>(Sapta 22:17–24:34)</para
Side note: The “mr” above pops up to display, Pro. 22:17-24. So there seems to be a slight issue in how the reference is called. It doesn’t see the whole range. Maybe it is how the markup has been coded and there needs to be a fix.
I think part of your example got “eaten”. I assume it should read: <para style="mr">(Sapta 22:17–24:34)</para>
(Use the preformatted text option in the editor to make sure you don’t lose characters.)
First, it appears that SAB is interpreting your “–” (which is an EN DASH) as a simple hyphen “-” for a verse range, then ignoring the ":34’ afterwards. That may be a bug in SAB, as the default for EN DASH should be to define a chapter range. @mcquayi Maybe something to test and/or report?
I’m not sure about your other request. You want the reference in the text, but without a link? I don’t see any way in SAB to turn off the linking from the div.mr style. However, I think you could turn it into some other paragraph type. Try this change in SAB:
Find: para style="mr"
Replace: para style="mt2"
And see what that does. There might be other styles that might be more appropriate for your needs. Check out the possibilities here: <para> @style Types — Unified Scripture XML 3.0.0 documentation
I was testing em dash \u2014 as a replacement for the double dash (- -). The em dash was not fully working. I am now going to test, en dash, \u2013.
Note: I had to omit the < before para as the forum post compiled the expression. Therefore I removed the < so you could see the markup code.
Update: The en dash doesn’t changed anything. I also tried to replace mr with mt2. Still no change in how the reference is pulled. I’m looking at Kolosi 3. There is a mr for Chapter 3:5-4:18. (Sapta 3:5–4:18). The viewer window in browser says Kol 3:5 however the app pulls the ref as, Kol 3:5-4.
So I’m still stuck as the en dash nor change to mt2 appears to help. What about applying change to \xt text\xt* like in TDX as reference caller?
Good point, Ian. If you go to the USX mr style description (link in my previous post), it’s supposed to be a reference under a major section heading, which should be before \c, I believe, but not only before \c 1, so mt2 might not have been the best choice…
@Tyler_Hewitt Maybe you should try turning “mr” into “ms2”, to see what happens. If that removes the reference link, then you can change the style in SAB of ms2 to match the formatting you want. It might also help if you send up a snippet of your USX file (make sure to use Preformatted text!), with a number of lines before and after the “mr” line, so we can see the context better.
I did a test by what you stated, basically remove <ref loc="COL 1:1-3:4"> ... </ref>. I left the “mr” tag. This is what I have for testing, <para style="mr">(Sapta 1:1–3:4)</para>
Here is what the view in browser looks like:
As you see, the reference link (hyperlink) is missing. So…it looks like this will be a way forward. I have not tested in a build apk yet so that will be the next step.
Could you help with a change to remove <ref loc=.....>, then I would need another change to remove the tailing marker, </ref>? End result would be (Sapta X-X). If possible, I would like to work within SAB Changes then the change would be global for all 66 books. Otherwise, I would have to make the change in all 66 USX files.
Normally when you are creating Regular Expressions, it’s good to see a number of the expressions that need to be changed (and what SHOULDN’T get changed), to get a sense for the variety of text that you will need to capture in the expression. You’re giving us one example, so I can give you an expression that I know matches that one case, but I’ll try to make it as generic as possible, so hopefully it will work for you.
Here is the example you gave us: <para style="mr">(Sapta <ref loc="COL 1:1-3:4">1:1–3:4</ref>)</para>
The basic job is to remove the <ref> tags, but leave everything else the same. And if possible in a changes rule in SAB, so it gets applied globally.
Here’s what I propose:
Find: <ref loc="[^"]+">([^\<]+)</ref>
This find a ref loc= tag, with anything in the double quotes, then captures the text that follows that, until it gets to the end ref tag. And it replaces it with just what was between the tags.
This won’t work if, for example there are sometimes other tags embedded within the captured text. And it will change too much if you have ref tags elsewhere, other than just within an “mr” tag. If that’s the case, let me know if the “mr” tags always start with “Sapta” or not.
So why don’t you give that a try and let us know how it goes.
If you want to play around with Regular Expressions and try different variations, I would recommend https://regex101.com/, where you can paste in a search text (for example a portion of your USX text), enter RegEx’s and see what it matches and/or replaces.
I spent a good three hours yesterday trying this on my own and exploring many websites to figure out regular expressions. I was making good headway but I was stuck on two fronts. I could not figure out how to remove the /ref from inside the parentheses. Also, the change needs to capture only the “mr” lines. What you propose will not work as it will always effect all “r” lines which I don’t want. I only want to modify the “mr” lines and to remove the ref. So the change would need to reflect the “mr” lines only.
This is what I would want as end result: <para style="mr">(Sapta 1:1–3:4)</para>. Yes, all “mr” lines do include (Sapta (scripture verse(s))).
I will add the prefix to the code and try this: <para style="mr">[(]Sapta <ref loc="[^"]+">([^\<]+)</ref>
So the test with find above and replace with \1 results this: 1:1--3:4)</para>
That will not work…I think we are on the right track and your code was helpful and it did remove the /ref from the syntax. However, the find also applies to all “r” lines as well which I don’t want.
Thanks for help. I’ll look more into this as well. Your feedback and help is appreciated.
Looks like I got it by adding Sapta to the beginning of your expression.
Find: Sapta <ref loc="[^"]+">([^\<]+)</ref
Replace: Sapta \1
Find = <para style="mr">(Sapta <ref loc="COL 1:1-3:4">1:1--3:4</ref>)</para>
Replace = <para style="mr">(Sapta 1:1--3:4)</para>
Since all “mr” have prefix Sapta this expression will single out the “mr” lines only leaving “r” lines untouched.
Below is a example for the view in browser from Matthew 21. As you see, the “mr” is no longer linked as reference AND the “r” for cross references are still linked and working for the section heading.
Good job! The key with Regular Expressions is to find a way to match the things you want and exclude the things you don’t want. If there had been some (or all) \r lines which had also included “Sapta”, then you would have just had to add a bit more context to select only the cases you wanted. For example, you could have added the "mr">( before the Sapta, like this:
Note that I had to put \ before the parenthesis before Sapta, because that is a special character for Regular Expressions, and you have to mark it specially.
Note also that I didn’t want to have to repeat all of that text that I captured before the reference, so I just put parentheses around it in the Find string, i.e. I “captured” it, and then in the replacement string I put \1' to spit it back out again. (And then the other capture group became the 2nd group, so its reference changed to \2`.)
And just one more comment. If you had a different word than “Sapta” sometimes (maybe a singular and plural form), you could change Sapta to \w+, which would match any sequence of word-building characters (one or more times). If that sometimes became an expression of more than one word, you might be tempted to use .+, which matches any character (one or more times). But that would be bad! because the + operator is “greedy”, and would suck up all of the following characters, probably until you got to the end of the line, which might be very far away… But you could use that expression that I used for the reference, [^\<]+ which means any character other than a less than sign, the opening bracket for the tag (one or more times). This would prevent the capture from taking any part of the <ref> tag. If that doesn’t make sense, then don’t worry about it. But it seemed like you might be ready for that “next level” in Regular Expressions!
Glad you found a solution, and hope you can continue to make improvements to your app through Regular Expressions.
Thanks again for the help and the bonus tips you provided.
My ‘stupid’ question is, what does the replace: \1\2 mean in laymen terms?
In the previous message, the working fix for replace was: Sapta \1. Could you explain more, what does that \1 mean in regards to the find lookup expression? Also, in your last example, \1\2.
Whenever you have parentheses in the Find expression, the text that is “captured” by those parentheses (which you don’t know ahead of time, if you are using wildcards) can be output in the Replace expression by a back reference to that capture group. The number of the back reference is simply the position (or count) of the opening parenthesis.
As an example, what do you think this find/replace does?
Find: (\w+) (\w+)
Replace: \2 \1
(Try to figure it out before going on! Maybe test it at https://regex101.com/)
This finds two words separated by a space, assigns them back references of \1 and \2 (the position of the opening parenthesis), and then replaces with \2 (that’s the second word) followed by a space and \1 (that’s the first word). So this find/replace effectively finds 2 words separated by a space and swaps their positions. (If you run this on a paragraph, it will make a big mess of it, because it will find many matches which it will replace!)
So \1\2 in laymen terms is output the first capture group (from the Find expression) immediately followed by the second capture group. Does that make sense?