Hey Rob, if you’re up for some more fun, I’ve been thinking about this, and doing a bit of research. Nothing urgent. What you already did is working well enough for most cases.
If I knew the web DOM better, I’d tackle this myself. But I’m still on a steep learning curve there.
My thought is this: Can we design a script that considers a number of possibilities, and then executes on the one that fits?
From my research, a lot of sites use the
<pre> tag to start the code block. So maybe that is a common usage worth coding for.
The interesting thing is that when I use the “Inspect Elements” tool I can almost always spot by eye where the code block starts. If I can do it by eye, surely we (well, really you) can come up with a design to find the code.
Here’s the results of my research. I hope it helps:
<pre class="prettyprint prettyprinted">
<div class="codecolorer-container applescript default" style="/* overflow:auto; *//* white-space:nowrap; *//* height:300px; */">
<pre> for some
<p class="code”> for others
<table class="highlight tab-size js-file-line-container" data-tab-size="8">