fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
490 stars 301 forks source link

starred name span off by one with nicknames #1209

Closed LarsEighner closed 4 years ago

LarsEighner commented 7 years ago

When a nickname is starred, it is rendered in the full name with the opening quote underlined but the closing quote not. Either both quotes should go in the span (preferred for typography) or neither should. This problem is observed in ltr. Situation in rtl is not known to me.

ex: <span class="starredname">“Lars</span>” should be: <span class="starredname">“Lars"</span> or: "<span class="starredname">Lars</span>”

fisharebest commented 7 years ago

What is the GEDCOM behind this name?

LarsEighner commented 7 years ago

1 NAME Laurence Vail /Eighner/ 2 GIVN Laurence Vail 2 SURN Eighner 2 NICK Lars* 2 NOTE FamiliesWiki

Also wrong bit was copied directly from source view of the page, except for escaping the brackets.

badul

Note also similar problem in Father's Name ("Tiny")

LarsEighner commented 7 years ago

Problem appears to be regex in line 1221 of app/individual.php

// A suffix of “*” indicates a preferred name $full = preg_replace('/([^ >])\/', '\1', $full);`

when you get to this line $full looks like: John "Jack" Doe the pattern captures "Jack and does not capture the closing "

I'm not finding the elegant one-line solutions here.

Okay here is what I get for line 1221 in app/Individual.php $full = preg_replace('/([^ >]*)\*(”)?/', '<span class="starredname">\\1\\2</span>', $full);

The starred name was wrapped in curly quotes, so note curly quote in regex.

The reason the span should include the quotes: Someone may want to style these differently. The general rule of typography is that punctuation next to letters should be in the same font as the letters. In spite of loose usage, boldface or italics are different fonts, so both the quotes should be included in the span.

This solves my problem and does not seem to hurt other name parts, but I only tested it in ltr English.