title: Python (or etc.) - Process HTML to add target=blank to a-tags not in domain list
body: <p>I write web content for a living. I compose in markdown and process out with pandoc, because I have to submit HTML files.</p>
  
  <p>All outbound links need to have target="_blank" in the submitted markup. Links within the network should not. I could add {:target="_blank"} to the markdown files when composing (and also switch to Kramdown), but I'd rather deal with this in post.</p>
  
  <p>I already have a little bash script that fixes some of the other output things after rendering via pandoc. I'd like to add this requirement there.</p>
  
  <p>I'm imagining my little script would include a list of domain names that it would avoid. I can sort of sketch out the basic idea of this, but I don't know enough regex or text processing generally to figure out the details.</p>
  
  <p>Any help?</p>
  
  <p>(I have primarily used Bash for this stuff in the past, when I first started doing it and my needs [I thought] were simple. I have switched to Python for newer things, so that's what I mentioned above. I actually don't care what gets used [within reason]).</p>
  
  <p>(Also -- for MY OWN stuff, I accomplish this with three-lines of Jquery on-page, instead of cluttering up my source content. I cannot convince THE MAN that this is the right course of action.)</p>
  
  <p>Cheers! and Thanks!</p>