############################### Matching the standard library ############################### ``turbohtml`` reproduces the exact behavior of :func:`python:html.escape` and :func:`python:html.unescape`. ``escape`` uses the same replacements, including ``'`` for the single quote, and ``unescape`` applies the full `HTML5 character-reference rules `_: named references with longest-prefix matching, numeric references, the Windows-1252 remaps, and the invalid code-point handling that maps to ``U+FFFD`` or the empty string. The test suite checks the C output against the standard library over a large fuzzed corpus. Template engines need a different contract: `markupsafe `_'s, where escaping produces a ``Markup`` safe-string that records "this is already HTML" and combining it with untrusted text escapes that text. :mod:`turbohtml.migration.markupsafe` is a drop-in for markupsafe's public surface, down to the numeric ``"``/``'`` quote references, so a `Jinja2 `_ or `WTForms `_ project migrates by changing the import. It lives in a module apart from :func:`turbohtml.escape` so each stays byte-exact with its own target: ``turbohtml.escape`` with the standard library, ``turbohtml.migration.markupsafe.escape`` with markupsafe. turbohtml builds the ``Markup`` in C in one call, where markupsafe pays a Python call and a ``Markup`` construction on every interpolation, so it runs faster. Linkifying needs the same HTML awareness from the other direction. :mod:`turbohtml.clean` parses the input first, so it can see that a URL already sits inside an ```` or a ``