Skip to content

Commit 509cc60

Browse files
florianbnlSanKson7claragullotta
authored andcommitted
FIX: Comment part of a scholium may include formatting (fixes #237).
Co-Authored-By: Theo <34419764+SanKson7@users.noreply.github.com> Co-Authored-By: claragullotta <127398339+claragullotta@users.noreply.github.com>
1 parent b1a8e37 commit 509cc60

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

frontend/src/components/FragmentComment.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ import '../styles/FragmentComment.css';
33
function FragmentComment({ children, setHighlightedText }) {
44
try {
55
const citationRegex = /^\[.*\]\s*\n(.*)$/m;
6-
if (citationRegex.test(children)) {
6+
if (citationRegex.test(children[0])) {
77
let [citation, comment] = children[0].split(/\n/);
88
citation = citation.replace(/[[\]]/g, '');
9+
const commentParts = [
10+
comment,
11+
...children.slice(1)
12+
].map((part, index) => (
13+
<span key={index}>
14+
{part}
15+
</span>
16+
));
17+
918
return <p
1019
onMouseEnter={
1120
e => {
@@ -25,7 +34,7 @@ function FragmentComment({ children, setHighlightedText }) {
2534
title="Highlight in document"
2635
>
2736
<span className="citation">{citation}</span>
28-
{comment}
37+
{commentParts}
2938
</p>;
3039
}
3140
} catch (e) {

0 commit comments

Comments
 (0)