WIP: Use some XPath selectors in Markdown filters to improve performance

Open Stan Hu requested to merge stanhu/gitlab-ce:use-xpath-selectors-to-optimize-gfm into master

Nokogiri::DocumentFragment incurs a surprisingly significant performance penalty when using search with a CSS selector. Searching the h1..hN headers in the 70K Readme.md in #18001 (moved) dropped an order of magnitude from ~1.5 s to ~0.150 s by using an XPath selector.