* Add TAB character to start of every line of a note for 2 fact types

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
phillip_leslie
Gold
Posts: 21
Joined: 30 Jun 2022 07:49
Family Historian: V7
Location: Huddersfield, West Yorkshire, UK

Add TAB character to start of every line of a note for 2 fact types

Post by phillip_leslie » 11 Nov 2022 23:00

I would like to add a single TAB character to the start of every Note line for two very specific fact types to help me improve the formatting and clarity of this information on various narrative reports, as I understand that there are no other formatting options available such as italics. I had these TAB characters in my data in my previous system TMG but the tabs were removed from my data during the FH conversion process, I did report that as a bug at the time which was acknowledge by CP, but it's probably not been fixed and it would have been too late for me anyway:

1. Name "Census" & label "Census"
2. Name "Address1" & label "1939 Register"

Example of a current 5 line note with a blank line (some notes may have 30 lines or more and several blanks):
Nettie Johncke, Wife, 37, Married 19 years, 5 children born & 5 living, born: Yorkshire, Hull
Ida Leslie, Daughter, 18, Single, Shop Girl, Gaiety Sports Saloon, born: Lanark, Glasgow
Arthur Leslie, Son, 17, Clerk, Mayfield Bros (Paint Works), born: Lanark, Glasgow

3 People, Two Females & 1 Male

Which would be enhanced to look like, where [TAB] would be an inserted tab character:
[TAB]Nettie Johncke, Wife, 37, Married 19 years, 5 children born & 5 living, born: Yorkshire, Hull
[TAB]Ida Leslie, Daughter, 18, Single, Shop Girl, Gaiety Sports Saloon, born: Lanark, Glasgow
[TAB]Arthur Leslie, Son, 17, Clerk, Mayfield Bros (Paint Works), born: Lanark, Glasgow

[TAB]3 People, Two Females & 1 Male

Is this a really bad idea or does anyone know of a plugin which could do this or is there anyone with the skills to write one for me?

Many Thanks.

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Add TAB character to start of every line of a note for 2 fact types

Post by tatewise » 12 Nov 2022 11:21

You say "that there are no other formatting options available such as italics" but that is not correct.
The FH V7 Rich Text features allow limited word-processing such as bold, italic, underlined and coloured text, plus a lot more that can be applied to Notes.

It should be possible to use the Search and Replace plugin to achieve the changes you want.

However, we must first discuss exactly what format changes you would prefer.

Your examples look like Census record transcripts that many users like to present as a table of rows and columns so it looks just like the original Census image. There may be a number of ways to achieve that.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
phillip_leslie
Gold
Posts: 21
Joined: 30 Jun 2022 07:49
Family Historian: V7
Location: Huddersfield, West Yorkshire, UK

Re: Add TAB character to start of every line of a note for 2 fact types

Post by phillip_leslie » 13 Nov 2022 10:35

Hi Mike, All of my census & 1939 records are formatted as per the example above, some with fewer and others with more comma separated field such as USA census records, I have over 1,500 records of these types of data in my notes field and am happy to continue with this format. The census & 1939 records are the only ones which I would like to insert a TAB character at the start of each line, although I have notes for many other facts, they are formatted as I want with bold/italics etc. If there is a way to insert a tab at the start of each line for a selective list of facts, that would be an excellent solution.

User avatar
phillip_leslie
Gold
Posts: 21
Joined: 30 Jun 2022 07:49
Family Historian: V7
Location: Huddersfield, West Yorkshire, UK

Re: Add TAB character to start of every line of a note for 2 fact types

Post by phillip_leslie » 13 Nov 2022 10:49

Hi Mike, I have installed your search and replace 3.7 plugin, and I can now see what I think what you are suggesting which could be a great solution. Using the plugin I can select the 2 specific fact types: Census & 1939, enable Show white space to see the tab, and then I can use the basic filter to select only Notes & Description fields. What I cannot fathom is what to insert into the search: & replace: fields to insert a TAB character at the start of each line, I am correct in guessing it would be a LUA pattern, any further guidance would be appreciated.

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Add TAB character to start of every line of a note for 2 fact types

Post by tatewise » 13 Nov 2022 11:37

Yes, you are almost absolutely correct and the 'magic' Lua patterns for Search and Replace are shown below.
Also, on the Extra Filters tab I advise you to choose Fact Notes (~Fact.NOTE) from the drop list top right.

To enter the search text, type the characters shown and press the Return/Enter key to get the newline character
Similarly, to enter the replace text, type the characters shown and press the Tab key to get the tab character »
Search:
([^¶
]+)

Replace:
» %1

S&Rtab.png
S&Rtab.png (59.04 KiB) Viewed 656 times

The explanation of the 'magic' Lua patterns is this:

[^¶
]
Means match any character that is not a newline (this caters for the last line having no Return)
+ Means repeat that match for as many characters as possible
( ) The surrounding parentheses mean capture anything that matches

» %1 Means replace with a tab character and whatever was captured in the search

However, that process is applied repeatedly to each chosen text field so multiple lines get converted.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Add TAB character to start of every line of a note for 2 fact types

Post by tatewise » 13 Nov 2022 12:17

For further details about Lua patterns see FHUG Knowledge Base Understanding Lua Patterns.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
phillip_leslie
Gold
Posts: 21
Joined: 30 Jun 2022 07:49
Family Historian: V7
Location: Huddersfield, West Yorkshire, UK

Re: Add TAB character to start of every line of a note for 2 fact types

Post by phillip_leslie » 13 Nov 2022 13:34

Hi Mike, that worked perfectly, many thanks for your help and explanation of the 'magic' pattern!

Post Reply