Apply style to a specific set of keywords in a post?

I’d like to apply some style to any instances of a specific set of words in a post. Such as names, places, etc.

I believe this is sufficiently different to syntax highlighting that would only apply to a code block.

So, in my post front matter I would have:

keywords: [Deneba, Star Wars, Han Solo, Obiwan]

and in the rendered Post I would like to see:

Han Solo was on his way to Deneba with Obiwan.
— Excerpt from Star Wars

I’m hosting on GitHub Pages, but can change that if I need to.

Thoughts appreciated!

I hacked this together:

{% assign modified = content %}
{% for keyword in page.keywords %}
{% assign emphasised = keyword | prepend: '<em>' | append: '</em>' %}
{% assign modified = modified | replace: keyword,emphasised %}
{% endfor %}
{{ modified }}

That’s enough for me, but I’m interested in any other solutions.

This looks like a decent solution without getting into writing a plug-in (which I know very little about). When I was looking at the code, I did think you could make it more universal. For example, you are styling an array of keywords right now, but what if you wanted to style an array of planets with a different look?

Your code could look like this:

{% assign modified = content %}
{% for keyword in page.keywords %}
  {% assign emphasised = keyword | prepend: '<span class="keyword">' | append: '</span>' %}
  {% assign modified = modified | replace: keyword,emphasised %}
{% endfor %}
{{ modified }}

Then, you would create a new scss file with code that looks like this:

.keyword {
  font-style: italic;
}

If you decide to work with an array of planets, your for loop would have a modification that looks like this:
{% assign emphasised = keyword | prepend: '<span class="planet">' | append: '</span>' %}

And finally, your updated scss code would look like this:

.keyword {
  font-style: italic;
}

.planet {
    font-weight: bold;
    color: green;
}

I hope this helps. Also, I wrote this code by hand in the browser and did not test it, so apologies if the code is not perfectly formatted.

That’s a good idea, Bill.

I’ll keep the changes in mind for if (when?) I have multiple styles of keywords.