question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parse plain text and connect its parts to svelte

See original GitHub issue

Hello

What i’m writing about is very common scenario in today’s web programming - namely hashtags and user mentions. User writes tags in plain text post and its saved on server:

{content:" text text #Cup "}

When retrieving from server those hashtags needs to be clickable. Problem is that changing “#Cup” into link or <Link> element makes it just plain text element

<script>
  import { link } from "svelte-routing"
    
    function hash(text) {
      return text.replace(/\#Cup/, '<a href="cup" use:link>Cup</a>')
  }
</script>

<p>
    {hash("this is a #Cup")} //this returns plain text
</p>
<p>
    {@html hash("this is a #Cup")} //this returns plain html
</p>

So what is the way to make svelte to understand that use:link?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
antonycommented, Jun 21, 2020

Then please try stackoverflow under the Svelte tag. Github issues is designed for bugs and feature requests for Svelte, and is not suitable for support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bindings / Text inputs • Svelte Tutorial
As a general rule, data flow in Svelte is top down — a parent component can set props on a child component, and...
Read more >
Dynamic behavior in Svelte: working with variables and props
In this case Svelte is using the export keyword to mark a variable declaration as a property or prop, which means it becomes...
Read more >
Provide non-decoded text to parse consumers #2714 - GitHub
Currently, parse from svelte/compiler decodes HTML entities (such as & or &dot; ). This causes tools like prettier-plugin-svelte that ...
Read more >
How to Fetch Data in Svelte - SitePoint
Learn how to consume a REST API using the Fetch API vs the Axios client. ... As you can see, the component contains...
Read more >
Rendering Svelte components from HTML string
As you say though, you could do something very similar by compiling <MyComponent> to a custom element called <my-component> instead, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found