Deciding which tags to apply by using the chain-of-responsibility pattern

Now that we have the means to transform a simple line into an HTML encoded line, we need a way to decide which tags we should apply. Right from the start, I knew that we would be applying yet another pattern, one that is eminently suitable for asking the question, "Should I handle this tag?" If no, then I will forward this on so that something else can decide whether or not it should handle the tag.

We are going to use another behavioral pattern to handle this—the chain-of-responsibility pattern. This pattern lets us chain together a series of classes by creating a class that accepts the next class in the chain, along with a method to handle a request. Depending on ...

Get Advanced TypeScript Programming Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.