* Font change via Search & Replace plugin
- Robert Jacobs
- Famous
- Posts: 111
- Joined: 21 Mar 2015 18:03
- Family Historian: V7
- Location: Ellensburg, Washington, U.S.A.
- Contact:
Font change via Search & Replace plugin
Can the Search and Replace plug in be set up to italicize text that lies between <i> and </i>? That would be extremely useful for those converting data from RootsMagic and probably others.
If that plugin won't work is there one that will?
If that plugin won't work is there one that will?
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Font change via Search & Replace plugin
Robert,
It is perhaps unfortunate that FH does not support standard rich text tags that have been used by RM for many years, particularly as it uses <i> and </i> internally anyway to denote italic text!
When it imports text containing these tags, it appears to actively avoid treating them as format tags, and places an escape character before the format code to prevent it formatting. In principle, all we need to do is convert all the escaped codes back to normal format codes. Unfortunately, we also need to tell FH to treat the codes as format instructions, so it is not as simple as simply using a text editor to change all the tags in the GEDCOM file directly.
That's a rather long-winded way of saying that even if there is not an existing plugin that does the conversion, it should be relatively straight forward to create an automatic way of doing it.
It is perhaps unfortunate that FH does not support standard rich text tags that have been used by RM for many years, particularly as it uses <i> and </i> internally anyway to denote italic text!
When it imports text containing these tags, it appears to actively avoid treating them as format tags, and places an escape character before the format code to prevent it formatting. In principle, all we need to do is convert all the escaped codes back to normal format codes. Unfortunately, we also need to tell FH to treat the codes as format instructions, so it is not as simple as simply using a text editor to change all the tags in the GEDCOM file directly.
That's a rather long-winded way of saying that even if there is not an existing plugin that does the conversion, it should be relatively straight forward to create an automatic way of doing it.
Mark Draper
- tatewise
- Megastar
- Posts: 27078
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Font change via Search & Replace plugin
Initially, when imported, the text fields that contain <b> <i> <u> etc, remain as plain text.
If those text fields become rich text then they become escaped /<b> /<i> /<u> etc, and the _FMT 1 GEDCOM tag is added.
The Search and Replace plugin will make the necessary changes but needs two runs.
Run 1
This detects any <b> <i> <u> codes without the escape / prefix and adds that escape prefix.
Include all records in Search Scope and just tick rich text Note & Description fields and Text From Source fields
Select Lua Pattern Mode so that all codes are handled in one pass.
Search for [^/]<(/?%l)> and Replace with /<%1>
So that matches < without / prefix and captures an optional / and any lowercase letter then >
It is replaced by /< that 1st capture and > and has the side effect of turning the field into rich text format.
Run 2
This detects all escaped codes /<b> /<i> /<u> and removes the escape / prefix.
Use the same settings as above but Search for /<(/?%l)> and Replace with <%1>
You can save those settings as two Presets so they can used again and again on future imports.
If those text fields become rich text then they become escaped /<b> /<i> /<u> etc, and the _FMT 1 GEDCOM tag is added.
The Search and Replace plugin will make the necessary changes but needs two runs.
Run 1
This detects any <b> <i> <u> codes without the escape / prefix and adds that escape prefix.
Include all records in Search Scope and just tick rich text Note & Description fields and Text From Source fields
Select Lua Pattern Mode so that all codes are handled in one pass.
Search for [^/]<(/?%l)> and Replace with /<%1>
So that matches < without / prefix and captures an optional / and any lowercase letter then >
It is replaced by /< that 1st capture and > and has the side effect of turning the field into rich text format.
Run 2
This detects all escaped codes /<b> /<i> /<u> and removes the escape / prefix.
Use the same settings as above but Search for /<(/?%l)> and Replace with <%1>
You can save those settings as two Presets so they can used again and again on future imports.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- LornaCraig
- Megastar
- Posts: 2989
- Joined: 11 Jan 2005 17:36
- Family Historian: V7
- Location: Oxfordshire, UK
Re: Font change via Search & Replace plugin
Another user had a similar question about importing the TMG italic code [ITAL:] [:ITAL].
He raised a ticket with Calico Pie and received a reply. In case it's relevant to your question, the topic is here:
Apparent failure to transcribe TMG text format code on import (18420)
He raised a ticket with Calico Pie and received a reply. In case it's relevant to your question, the topic is here:
Apparent failure to transcribe TMG text format code on import (18420)
Lorna
- Robert Jacobs
- Famous
- Posts: 111
- Joined: 21 Mar 2015 18:03
- Family Historian: V7
- Location: Ellensburg, Washington, U.S.A.
- Contact:
Re: Font change via Search & Replace plugin
Thank you all! I hope to try Mike's solution this afternoon.
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Font change via Search & Replace plugin
Minor query - is the escape character the forward slash or the backslash? I've been experimenting with this and following what happens in the GEDCOM file, and the backslash seems to be the escape character there.
Mark Draper
- tatewise
- Megastar
- Posts: 27078
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Font change via Search & Replace plugin
What I see in the GEDCOM file is forward slash /<i> italic text /</i>
i.e.
2 CONT /<b>1. Establish objective/</b>
2 CONT
2 CONT /<i>Define your goal, keep it concise/</i>
2 CONT
2 _FMT 1
Could you post what you see?
i.e.
2 CONT /<b>1. Establish objective/</b>
2 CONT
2 CONT /<i>Define your goal, keep it concise/</i>
2 CONT
2 _FMT 1
Could you post what you see?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Font change via Search & Replace plugin
First experiment - establish my baseline of what FH does left to its own devices. In RM, I created a rich text note in a copy of my RM Ancestry sync file, and exported as GEDCOM with just the notes and note formatting options selected. This imported into FH as a fresh project with no errors.
The rich text displayed literally, as expected, with the following GEDCOM line
I then forced the note to rich text in FH by adding another line of rich text.
The imported text was still displayed literally, but the escaping in the GEDCOM was different to what you showed, with backslashes before both opening and closing brackets.
Second experiment - repeat the import, and this time change <i> to /<i> and </i> to /</i> using the FH Search and Replace dialogue (so doing what I think your plugin is doing directly in native FH).
The modified note continued to display literally, and the GEDCOM showed that it had not been converted to rich text, even after saving, exiting, and reloading.
I don't understand why your plugin converts the note to rich text, when native FH does not, and why the escape pattern is different. Is there a subtlety there I have missed?
The rich text displayed literally, as expected, with the following GEDCOM line
Code: Select all
1 NOTE This RM line contains <i>italic text</i>.The imported text was still displayed literally, but the escaping in the GEDCOM was different to what you showed, with backslashes before both opening and closing brackets.
Code: Select all
1 NOTE This RM line contains \<i\>italic text\</i\>.
2 CONT This line with <b>bold text</b> was added in FH.
2 CONT
2 _FMT 1The modified note continued to display literally, and the GEDCOM showed that it had not been converted to rich text, even after saving, exiting, and reloading.
Code: Select all
1 NOTE This RM line contains /<i>italic text/</i>.Mark Draper
- tatewise
- Megastar
- Posts: 27078
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Font change via Search & Replace plugin
I don't understand now either!
Having repeated the whole process, I now get what you get with backslash \ escape characters.
I know I got forward slash / somehow but cannot recreate them. I think it involved upgrading an FH V6 Project to FH V7.
The reason the Search and Replace plugin converts to rich text is that it does more than a simple text substitution.
The simple text edit you can do in a GEDCOM file is impossible via the Plugin API to FH which demands rich text for Notes.
So when the plugin modifies a Note it has to use rich text format and that automatically adds the _FMT 1 tag at the end.
So the Search pattern is <(/?%l)> and Replace with \<%1\>
Then Search pattern is \<(/?%l)\> and Replace with <%1>
Having repeated the whole process, I now get what you get with backslash \ escape characters.
I know I got forward slash / somehow but cannot recreate them. I think it involved upgrading an FH V6 Project to FH V7.
The reason the Search and Replace plugin converts to rich text is that it does more than a simple text substitution.
The simple text edit you can do in a GEDCOM file is impossible via the Plugin API to FH which demands rich text for Notes.
So when the plugin modifies a Note it has to use rich text format and that automatically adds the _FMT 1 tag at the end.
So the Search pattern is <(/?%l)> and Replace with \<%1\>
Then Search pattern is \<(/?%l)\> and Replace with <%1>
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Font change via Search & Replace plugin
Interesting - it seems that CP have set it up to always regard Notes as rich text internally, but they only use the non-standard _FMT 1 tag in the GEDCOM file if it's needed. Revert the note to purely standard fonts and no rich features, and the tag goes away again. Nice way to code it, getting the best of both worlds.
FH seems to be attracting quite a few migrants from RM (put off by the radically different look and feel of RM8 perhaps?), so it wouldn't surprise me if a future FH7.x supported RM rich text import directly. RM users - make your voice heard at CP if you want it!
FH seems to be attracting quite a few migrants from RM (put off by the radically different look and feel of RM8 perhaps?), so it wouldn't surprise me if a future FH7.x supported RM rich text import directly. RM users - make your voice heard at CP if you want it!
Mark Draper