Skip to content

Commit 6be38da

Browse files
committed
using markdown plain text within findMarkdown
1 parent caf0349 commit 6be38da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

super_editor_markdown/lib/src/markdown_inline_upstream_plugin.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class _UpstreamInlineMarkdownParser {
258258
// Start visiting upstream characters by visiting the first character
259259
// and checking for possible syntaxes.
260260
for (final parser in parsers) {
261-
final markdownToken = parser.startWith(attributedText[offset] as String, offset);
261+
final markdownToken = parser.startWith(attributedText.toPlainText()[offset], offset);
262262
if (markdownToken != null) {
263263
_possibleSyntaxes.add(markdownToken);
264264
}
@@ -270,7 +270,7 @@ class _UpstreamInlineMarkdownParser {
270270

271271
// Update all existing possible syntaxes and remove any possible syntaxes
272272
// that are now invalid due to the new character.
273-
_updatePossibleSyntaxes(attributedText[offset] as String, offset);
273+
_updatePossibleSyntaxes(attributedText.toPlainText()[offset], offset);
274274

275275
// Store any successful parsers on a stack. We keep searching after successful
276276
// parsing because some parsers are essentially supersets of others, e.g., "*"
@@ -291,7 +291,7 @@ class _UpstreamInlineMarkdownParser {
291291
//
292292
// Finding a completed syntax isn't enough. We need to ensure that the
293293
// immediate upstream character before the syntax doesn't invalidate it.
294-
final upstreamCharacter = attributedText[offset - 1] as String;
294+
final upstreamCharacter = attributedText.toPlainText()[offset - 1];
295295
successfulParsers.removeWhere((parser) => !parser.canFollowCharacter(upstreamCharacter));
296296
}
297297
}
@@ -317,14 +317,14 @@ class _UpstreamInlineMarkdownParser {
317317
return null;
318318
}
319319

320-
final characterAtCaret = attributedText[caretOffset - 1] as String; // -1 because caret sits after character
320+
final characterAtCaret = attributedText.toPlainText()[caretOffset - 1]; // -1 because caret sits after character
321321
if (characterAtCaret != " ") {
322322
// Don't linkify unless the user just inserted a space after the token.
323323
return null;
324324
}
325325

326326
final endOfTokenOffset = caretOffset - 2;
327-
if (attributedText[endOfTokenOffset] != ")") {
327+
if (attributedText.toPlainText()[endOfTokenOffset] != ")") {
328328
// All links end with a ")", therefore we know the upstream token
329329
// isn't a link. Short-circuit return.
330330
return null;

0 commit comments

Comments
 (0)