Is a comma required / advisable / forbidden in {NP[,] such as NP}, eg 'fossil fuels[,] such as coal'

I have a doubt about the use of commas with various phrases. It is my understanding that the comma rules for prepositional phrases are as follows: If the sentence starts with a prepositional phrase, then it must be followed by a comma before the independent clause. Conversely, if the sentence starts with the independent clause and a prepositional phrase follows, then there is no need for a comma. However, I have seen several sentences in books where this rule is not applied. For instance, take a look this sentence:

The diagram illustrates the process used to produce electricity using fossil fuels, such as coal.

In the second part of the sentence, we have the preposition phrase "such as coal" that is preceded by a comma. Is this a proper usage?


Such as is a phrase with more than one meaning, and this can cause complications.

From English Grammar Today:

We can use such as to introduce an example or examples of something we mention. We normally use a comma before such as when we present a list of examples. Where there is just one example, we don’t need a comma:

(1) The shop specialises in tropical fruits, such as pineapples, mangoes and papayas. (… for example, pineapples, mangoes and papayas.)

(2) Countries such as Sweden have a long record of welcoming refugees from all over the world.

Such as is similar to like for introducing examples, but it is more formal, and is used more in writing than like.

But this does not distinguish the different senses; in (1) such as means eg / for instance, whereas in (2) it means which are similar in nature to.

ODO brings out this distinction:

such as PHRASE

1: For example.

‘wild flowers such as mountain pansy and wild thyme’

2: Of a kind that; like.

‘an event such as we've shared’

Sometimes either reading is available, and then the comma is used to disambiguate:

"The diagram illustrates the process used to produce electricity using fossil fuels, such as coal." = "The diagram illustrates the process used to produce electricity using fossil fuels – for instance, coal." (non-restrictive)

whereas

"The diagram illustrates the process used to produce electricity using fossil fuels such as coal." = "The diagram illustrates the process used to produce electricity using coal and those fossil fuels which are similar." (restrictive / defining: only the fossil fuels which are (for the purposes of this presentation) similar to coal)

And in fact, the 'for instance' sense always takes the comma whereas the 'which may be classed together with' //'of a/the kind that' sense never does.