Skip to content

Commit 931375a

Browse files
Amine-jaboteSidqui-Youssef
authored andcommitted
FEATURE: Turn paragraphs into speech turns (closes #224).
Co-authored-by: Sidqui-Youssef <youssef.sidqui@utt.fr>
1 parent ca1da5d commit 931375a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

frontend/src/components/EditableText.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ import PictureUploadAction from '../menu-items/PictureUploadAction';
77
import {v4 as uuid} from 'uuid';
88
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
99

10+
function boldSpeakerNames(text) {
11+
return text.split('\n').map(line => {
12+
const match = line.match(/^([A-Z][a-zA-ZéèêîïÉÈÊÎÏ\-']+)\s*:/);
13+
if (match) {
14+
const name = match[1];
15+
return line.replace(name, `**${name}**`);
16+
}
17+
return line;
18+
}).join('\n');
19+
}
20+
1021
function EditableText({id, text, rubric, isPartOf, links, fragment, setFragment, setHighlightedText, setSelectedText, rawEditMode, setRawEditMode, backend, setLastUpdate}) {
1122
const [beingEdited, setBeingEdited] = useState(false);
1223
const [editedDocument, setEditedDocument] = useState();
@@ -110,7 +121,7 @@ function EditableText({id, text, rubric, isPartOf, links, fragment, setFragment,
110121
>
111122
<div className="formatted-text" onClick={handleClick}>
112123
<FormattedText {...{setHighlightedText, setSelectedText}}>
113-
{text || '&nbsp;'}
124+
{boldSpeakerNames(text || '&nbsp;')}
114125
</FormattedText>
115126
</div>
116127
</OverlayTrigger>

0 commit comments

Comments
 (0)