Anki: How to make certain texts bold within the quotation marks

59 Views Asked by At

I recently imported dictionary information to be displayed as several special fields, including "Etymology" and "Example". There are several things I wish to be modified, but I'm strugling with formatting card templates(I have no idea with phython, javascript).

Take this for an example:

From Middle English addlen, adlen, from Old English edlēan (“reward, pay-back”), edlēanian (“to reward, recompense”); or from or cognate with Old Norse ǫðlask (“to gain possession of property”), from ōðal (“owndom, property”).

This is displayed in the field as an etymology regarding to the word "addle".

There are two types of texts I want to replace as bold-typed.

  1. texts within quotation("reward, pay-back", "to reward, recompense", etc.)

  2. If possible, texts indicating the origins(edlēan, edlēanian, ǫðlask, etc.)

For reference, the name of the field is "Etymology" (written as "{{Etymology}}" in the format), and every card type is basic.

+As for 2., I don't really think it will be ever possible if is not done by myself manually. I'm just asking it for the silm chances.

<span id="Etymology"> {{Etymology}} </span>

<script>
    var EtymologyText = document.getElementById("Etymology").innerHTML;
    document.getElementById("Etymology").innerHTML = EtymologyText.replace(/"([^"]+)"/g, '<b>"$1"</b>');
</script>

This is what I got from ChatGPT, but it didn't work.

1

There are 1 best solutions below

2
MathSolver On

You can try this code

var EtymologyText = document.getElementById("Etymology").innerHTML;
document.getElementById("Etymology").innerHTML = 
EtymologyText.replace(/"([^"]+)"/g, '<strong>"$1"</strong>');

If you want to apply the similar pattern to all the