Drinfeld defined the Knizhinik--Zamolodchikov (KZ) associator \Phi_{\rm KZ} by considering the regularized holonomy of the KZ connection along the {\em droit chemin} [0,1]. The KZ associator is a group-like element of the free associative algebra with two generators, and it satisfies the pentagon equation.
In this paper, we consider paths on \mathbb{C}\backslash \{ z_1, \dots, z_n\} which start and end at tangential base points. These paths are not necessarily straight, and they may have a finite number of transversal self-intersections. We show that the regularized holonomy H of the KZ connection associated to such a path satisfies a generalization of Drinfeld's pentagon equation. In this equation, we encounter H, \Phi_{\rm KZ}, and new factors associated to self-intersections, to tangential base points, and to the rotation number of the path.