Skip to content

Commit

Permalink
wasm update
Browse files Browse the repository at this point in the history
and more testing
  • Loading branch information
Simon-Laux committed Oct 14, 2023
1 parent 7d00b96 commit 1bbcc60
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions message_parser_wasm/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
border-radius: 2px;
padding: 2px;
}

.mention {
color: rgb(0, 126, 168);
}

body {
font-family: sans-serif;
}
</style>
<h3>Input</h3>
<textarea
Expand Down
9 changes: 9 additions & 0 deletions message_parser_wasm/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ function renderElement(elm) {
email.innerText = elm.c;
email.href = "mailto:" + elm.c;
return email;

case "Mention":
let mention = document.createElement("span");
mention.innerText = "@" + elm.c.address;
mention.onclick = () => {
alert(`Clicked on a Mention, this should open view profile view for ${elm.c.address}`)
}
mention.className = "mention"
return mention

case "BotCommandSuggestion":
let bcs = document.createElement("a");
Expand Down
1 change: 1 addition & 0 deletions message_parser_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type ParsedElement =
| { t: "InlineCode"; c: { content: string } }
| { t: "CodeBlock"; c: { language: null | string; content: string } }
| { t: "EmailAddress"; c: string }
| { t: "Mention"; c: { address: string } }
| { t: "BotCommandSuggestion"; c: string }
| { t: "Link"; c: { destination: LinkDestination } }
| {
Expand Down
1 change: 1 addition & 0 deletions message_parser_wasm/src/manual_typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type ParsedElement =
| { t: "InlineCode"; c: { content: string } }
| { t: "CodeBlock"; c: { language: null | string; content: string } }
| { t: "EmailAddress"; c: string }
| { t: "Mention"; c: { address: string } }
| { t: "BotCommandSuggestion"; c: string }
| { t: "Link"; c: { destination: LinkDestination } }
| {
Expand Down
9 changes: 9 additions & 0 deletions tests/mentions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ fn extract_mentions_are_deduped_and_sorted() {
]
)
}

#[test]
fn extract_mentions_false_positive() {
let mention_text = "my text@[email protected], more text";
assert_eq!(
extract_mention_addresses(mention_text),
Vec::<String>::new()
);
}

0 comments on commit 1bbcc60

Please sign in to comment.