Refer only the text?

I wanna make a dictionary link with the front text, so i tried putting like this
Examples
But my front text has a audio file in it.

Can I make the {{Front}} refer only for the text?

The first thing that came to my mind is the {{text:}} filter, but audio references are apparently converted to HTML after the filter is applied, so it doesn’t work here.

A possible workaround is to extract the text part using JavaScript as follows:

<div>http://example.com/?q=<span id="front"></span></div>

<script>
var div = document.createElement("div");
div.innerHTML = `{{Front}}`;
var text = div.textContent;
var front = document.getElementById("front");
front.textContent = text;
</script>

If the text and audio were in separate fields, the text filter would have worked here.
I always recommend separating different contents into different fields; that’s what fields are for.

3 Likes

Thank you for the response.
I am tying to put this value in a dictionary link(<a href="http://example.com/search?q={{Expression}}">check in dictionary</a>), but I can’t manage to do it. Is it possible? I don’t know a lot about this stuff sorry about.

Yes, it’s possible (I should have showed an example with <a> instead).

Try something like this:

<a id="link"></a>

<script>
var div = document.createElement("div");
div.innerHTML = `{{Front}}`;
var text = div.textContent;
var anchor = document.getElementById("link");
var link = `http://example.com/?q=${text}`;
anchor.textContent = link;
anchor.href = link;
</script>
1 Like