Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom parser duplicates the input content on web #584

Open
Skalakid opened this issue Dec 12, 2024 · 0 comments · May be fixed by #585
Open

Custom parser duplicates the input content on web #584

Skalakid opened this issue Dec 12, 2024 · 0 comments · May be fixed by #585
Labels
bug Something isn't working

Comments

@Skalakid
Copy link
Collaborator

Description:

After applying custom parser function to the Live Markdown Input, its content breaks.

For example, after applying following parser:

function parser(input) {
  'worklet';

  const ranges = [];
  // Regular expressions for hashtags and mentions
  const hashtagRegex = /#(\w+)/g;
  const mentionRegex = /@(\w+)/g;

  // Find and push hashtag ranges
  let match;
  while ((match = hashtagRegex.exec(input)) !== null) {
    ranges.push({
      start: match.index,
      length: match[0].length,
      type: 'link', // type 'link' for hashtags
    });
  }

  // Find and push mention ranges
  while ((match = mentionRegex.exec(input)) !== null) {
    ranges.push({
      start: match.index,
      length: match[0].length,
      type: 'mention-user', // type 'mention-user' for user mentions
    });
  }

  return ranges;
}
Screen.Recording.2024-12-12.at.09.47.06.mov

Reproduction steps

  1. Open the example app
  2. Write following text: @a #1
@Skalakid Skalakid changed the title Custom parser duplicates the input context on web Custom parser duplicates the input content on web Dec 12, 2024
@tomekzaw tomekzaw added the bug Something isn't working label Dec 12, 2024
@Skalakid Skalakid linked a pull request Dec 12, 2024 that will close this issue
@tomekzaw tomekzaw linked a pull request Dec 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants