diff --git a/demo.md b/demo.md index 084c7b0f..ef48b720 100644 --- a/demo.md +++ b/demo.md @@ -8,9 +8,10 @@ Like if you break up words you shoul dn't. Harper can be a lifesaver when writing technical documents, emails or other formal forms of communication. -Harper works everywhere, even offline. Since you r data -never leaves your device, you don't ned to worry aout us -selling it or using it to train large language models. +Harper works everywhere, even offline. Since your data +never leaves your device, you don't need to worry aout us +selling it or using it to train large language models, +despite of the consequences. The best part: Harper can give you feedback instantly. For most documents, Harper can serve up suggestions in diff --git a/harper-core/src/linting/lint_kind.rs b/harper-core/src/linting/lint_kind.rs index 0f1a70f0..513f9461 100644 --- a/harper-core/src/linting/lint_kind.rs +++ b/harper-core/src/linting/lint_kind.rs @@ -20,6 +20,24 @@ pub enum LintKind { Miscellaneous, } +impl LintKind { + /// Produce a string representation, which can be used as keys in a map or CSS variables. + pub fn to_string_key(&self) -> String { + match self { + LintKind::Spelling => "Spelling", + LintKind::Capitalization => "Capitalization", + LintKind::Formatting => "Formatting", + LintKind::Repetition => "Repetition", + LintKind::Readability => "Readability", + LintKind::Miscellaneous => "Miscellaneous", + LintKind::Enhancement => "Enhancement", + LintKind::WordChoice => "WordChoice", + LintKind::Style => "Style", + } + .to_owned() + } +} + impl Display for LintKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let s = match self { diff --git a/harper-wasm/src/lib.rs b/harper-wasm/src/lib.rs index 6befc85b..f9010047 100644 --- a/harper-wasm/src/lib.rs +++ b/harper-wasm/src/lib.rs @@ -282,6 +282,11 @@ impl Lint { /// Get a string representing the general category of the lint. pub fn lint_kind(&self) -> String { + self.inner.lint_kind.to_string_key() + } + + /// Get a string representing the general category of the lint. + pub fn lint_kind_pretty(&self) -> String { self.inner.lint_kind.to_string() } diff --git a/packages/web/src/lib/Editor.svelte b/packages/web/src/lib/Editor.svelte index 63385271..0af62b84 100644 --- a/packages/web/src/lib/Editor.svelte +++ b/packages/web/src/lib/Editor.svelte @@ -7,6 +7,7 @@ import type { Lint } from 'harper.js'; import CheckMark from '$lib/CheckMark.svelte'; import { fly } from 'svelte/transition'; + import lintKindColor from './lintKindColor'; export let content = demo; @@ -79,10 +80,10 @@ on:click={() => (focused = i)} bind:this={lintCards[i]} > -