Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

Fixed issues with underlines

Elijah Potter8ab80aac9f38
diff --git a/english_words.txt b/english_words.txt
index d8ff6690b..b9e15cccc 100644
--- a/english_words.txt
+++ b/english_words.txt
@@ -158739,7 +158739,7 @@ isms
isn
isnad
isnardia
-isnt
+isn't
iso
isoabnormal
isoagglutination
diff --git a/web/src/lib/Underlines.svelte b/web/src/lib/Underlines.svelte
index 5967da2f8..53e6c90fc 100644
--- a/web/src/lib/Underlines.svelte
+++ b/web/src/lib/Underlines.svelte
@@ -5,7 +5,9 @@
export let content: string;
let lints: Lint[] = [];
- $: lintText(content).then((newLints) => (lints = newLints));
+ $: lintText(content).then(
+ (newLints) => (lints = newLints.toSorted((a, b) => a.span.start - b.span.end))
+ );
function reOrgString(text: string): (string | undefined)[] {
if (text.trim().length == 0) {
@@ -14,12 +16,12 @@
let output: (string | undefined)[] = [];
- for (let chunk of text.split('\n')) {
+ for (let chunk of text.replaceAll(' ', '\u00A0').split('\n')) {
if (output.length > 0) {
output.push(undefined);
- } else {
- output.push(chunk);
}
+ console.log(chunk);
+ output.push(chunk);
}
return output;
@@ -28,7 +30,6 @@
// string | [string, string] | null
$: modified = [
...lints
- .toSorted((a, b) => a.span.start - b.span.end)
.map((lint, index, arr) => {
let prev = arr[index - 1];
@@ -38,18 +39,16 @@
let prevContent = [];
if (prevStart != prevEnd) {
- prevContent.push(reOrgString(content.substring(prevStart, prevEnd)));
+ prevContent.push(...reOrgString(content.substring(prevStart, prevEnd)));
}
- let lintContent = [spanContent(lint.span, content), 'red'];
+ let lintContent = [spanContent(lint.span, content).replaceAll(' ', '\u00A0'), 'red'];
- return [...prevContent.flat(), lintContent];
+ return [...prevContent, lintContent];
})
.flat(),
- reOrgString(content.substring(lints.at(-1)?.span.end ?? 0))
+ ...reOrgString(content.substring(lints.at(-1)?.span.end ?? 0))
];
-
- $: console.log(modified);
</script>
<div class="grid">
@@ -58,9 +57,11 @@
{#if chunk == null}
<br />
{:else if typeof chunk == 'string'}
- <p class="inline">{chunk}</p>
+ <span class="">{chunk}</span>
{:else}
- <p class="inline" style={`border-bottom: 1px solid ${chunk[1]}`}>{chunk[0]}</p>
+ <span style={`border-bottom: 3px solid ${chunk[1]}; margin-right: -4px;`}>
+ {chunk[0]}
+ </span>
{/if}
{/each}
</div>
diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte
index 8f20157e9..ab56aabce 100644
--- a/web/src/routes/+page.svelte
+++ b/web/src/routes/+page.svelte
@@ -27,9 +27,6 @@
<div class="overflow-auto p-0" style="grid-row: 1; grid-column: 1">
<Underlines {content}></Underlines>
</div>
- <div class="overflow-auto p-0" style="grid-row: 1; grid-column: 1">
- <Highlights {content}></Highlights>
- </div>
<textarea
class="w-full h-full m-0 rounded-none p-0 z-0 bg-transparent border-none"
spellcheck="false"