Improve the speed of the Markdown package

The current version of the Markdown package for TeX takes multiple seconds to initialize and process a markdown text:

$ docker run --rm -i witiko/markdown bash -c 'time markdown-cli <<< foo'
\markdownRendererDocumentBegin
foo\markdownRendererDocumentEnd

real	0m1.645s
user	0m1.430s
sys	0m0.215s

In a recent experiment, I processed a short text with historic versions of the Markdown package and I compared them with the current version of the Markdown package. The results show a more than 5× slow-down in version 3.4.3 of the Markdown package:

image

A PR that closes this ticket should take the following steps:

  1. Determine which of the eight PRs merged in version 3.4.3 caused the slow-down.
  2. Determine the exact cause of the slow-down and eliminate the slow-down.
  3. Test that processing a short text in the CI takes less than 1 second.