title: Modify all links in HTML Purifier
body: <p>I am using HTML purifier to remove all unnecessary/malicious html tags.</p>
  
  <pre><code>$html = 'dirty html provided by user';
  $config = HTMLPurifier_Config::createDefault();
  $config-&gt;set('HTML.Allowed', 'p,a[href], ... other tags);
  $purifier = new HTMLPurifier($config);;
  $output = $purifier-&gt;purify($html);
  </code></pre>
  
  <p>It works really nice, but I want to do a little bit more. I want to change all my <code>&lt;a href='link'&gt;...&lt;/a&gt;</code> to something else like <code>&lt;a href='somefunc(link)' rel="nofollow" target="_blank"&gt; ... &lt;/a&gt;</code>.</p>
  
  <p>After searching for a little bit, I found the following relevant <a href="https://stackoverflow.com/questions/9765982/configuring-htmlpurifier-to-display-external-links-as-plain-text">link</a>, but the problem is that it requires patching a complex library (which is not really a good idea, also the solution is kind of complicated).</p>
  
  <p>Reading through their <a href="http://htmlpurifier.org/phorum/read.php?2,5611" rel="nofollow noreferrer">forum post</a>, it looks like there is solution for adding nofollow parameter is <code>$config-&gt;set("HTML.Nofollow", true);</code>, but I still fail to find how can modify every link.</p>
  
  <p>My current solution is to parse purified html by myself and to modify a link, but I think that there is a way to do this through <code>HTML Purifier</code>.</p>