From 9d5a13d7cedba2691b6248d416b651b020f9c866 Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Wed, 10 Jul 2024 10:16:16 -0400 Subject: [PATCH 1/4] un-mangle subreading display (closes #8) --- src/components/Analyzer.tsx | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/components/Analyzer.tsx b/src/components/Analyzer.tsx index 217c8b980..f94393515 100644 --- a/src/components/Analyzer.tsx +++ b/src/components/Analyzer.tsx @@ -53,35 +53,22 @@ const AnalysisResult = ({ const splitUnit = unit.split('/'); const morphemes: Array = []; - const joinedMorphemes: Record> = {}; splitUnit.slice(1).forEach((unit, i) => { const matches = unit.match(unitRegex); if (matches && matches.length > 2) { - matches.slice(1, matches.length - 1).forEach((match) => { - if (joinedMorphemes[match]) { - joinedMorphemes[match].push(unit); - } else { - joinedMorphemes[match] = [unit]; - } + matches.filter((m) => m.length > 0).forEach((match, n) => { + const width = 30 * n; + morphemes.push( +
+ {formatUnit(match)} +
+ ); }); } else { morphemes.push(
{formatUnit(unit)}
); } }); - Object.entries(joinedMorphemes).forEach(([joinedMorpheme, units], i) => { - morphemes.push(
{formatUnit(joinedMorpheme)}
); - units.forEach((unit, j) => { - const unitMatch = unit.match(unitRegex); - if (unitMatch) { - morphemes.push( -
- {formatUnit(unitMatch[0])} -
, - ); - } - }); - }); return ( From 4efea882a5ade16e9c16b694b887069cd2138cd9 Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Wed, 10 Jul 2024 10:18:26 -0400 Subject: [PATCH 2/4] blah --- src/components/Analyzer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Analyzer.tsx b/src/components/Analyzer.tsx index f94393515..33da9bd3f 100644 --- a/src/components/Analyzer.tsx +++ b/src/components/Analyzer.tsx @@ -57,7 +57,7 @@ const AnalysisResult = ({ const matches = unit.match(unitRegex); if (matches && matches.length > 2) { - matches.filter((m) => m.length > 0).forEach((match, n) => { + matches.filter((m) => m.length > 0).forEach((match, n) => { const width = 30 * n; morphemes.push(
From 33c33586b7aadd377cd6d67d6d17f86fdae8d648 Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Wed, 10 Jul 2024 10:50:07 -0400 Subject: [PATCH 3/4] linter appeasement --- src/components/Analyzer.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Analyzer.tsx b/src/components/Analyzer.tsx index 33da9bd3f..d72d56c8f 100644 --- a/src/components/Analyzer.tsx +++ b/src/components/Analyzer.tsx @@ -57,8 +57,9 @@ const AnalysisResult = ({ const matches = unit.match(unitRegex); if (matches && matches.length > 2) { - matches.filter((m) => m.length > 0).forEach((match, n) => { - const width = 30 * n; + matches.filter((m) => m.length > 0).forEach((match, n) => { + const subreadingIndent = 30; + const width = subreadingIndent * n; morphemes.push(
{formatUnit(match)} From 547b7e4ba6bb6d48785ab5ab8c37d60f5d882d7e Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Wed, 10 Jul 2024 10:59:17 -0400 Subject: [PATCH 4/4] ... and the formatter --- src/components/Analyzer.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/Analyzer.tsx b/src/components/Analyzer.tsx index d72d56c8f..50b483190 100644 --- a/src/components/Analyzer.tsx +++ b/src/components/Analyzer.tsx @@ -57,15 +57,17 @@ const AnalysisResult = ({ const matches = unit.match(unitRegex); if (matches && matches.length > 2) { - matches.filter((m) => m.length > 0).forEach((match, n) => { - const subreadingIndent = 30; - const width = subreadingIndent * n; - morphemes.push( -
- {formatUnit(match)} -
- ); - }); + matches + .filter((m) => m.length > 0) + .forEach((match, n) => { + const subreadingIndent = 30; + const width = subreadingIndent * n; + morphemes.push( +
+ {formatUnit(match)} +
, + ); + }); } else { morphemes.push(
{formatUnit(unit)}
); }