(there’s a quasi Beatles reference in that title)
What would you do if my code spit an error?
Would you stand up and tweet out to me?
Send me an link and I’ll try to replicate
I will try to fix it quickly.
This is how stuff works. Someone I don’t know tweets about an error message in one of my code projects.
Hey @cogdog, I'm trying to use your Storify Extractor at https://t.co/PYdyW9IFuS and whenever I paste in the HTML for the Storify page, I get an error pop-up. Any advice?
— Christina Vasilevski (@cvasilevski) June 13, 2018
I’ve been surprised there’s not been more glitches with the Storify Embeddable Link Extractor, which is aimed at getting content out of a storify page’s HTML (which are now completely dead and gone and buried) that can be embedded into WordPress.
I thought maybe Christina was hitting an issue where her storifies were already gone, but she had extracted them earlier. Smart.
But what error? That is helpful in getting the answer.
I exported all my Storify pages back to HTML way back in January so the source file should be fine. This is the error message I get. pic.twitter.com/FN4tmsrLhJ
— Christina Vasilevski (@cvasilevski) June 13, 2018
That helps a little, it means that my code had borked somewhere on parsing the info. Christina sent me by email the HTML files she was getting errors on, and I confirmed it.
So it’s my fault.
I did have a hunch. The regex pattern matching my site uses to identify content is dependent on lines ending in a carriage return. And I saw one of her text block added to storify had extra line returns. Removing them from her source made the error vanish.
My guess was I needed to remove all line returns from the chunk of text I was using, which is what is pasted into the textarea. My previous code had:
$( "form" ).submit(function( event ) { // our raw input. yum. var raw = $('#raw').val();
A little bit of googling and some Stack Exchange examples on regex got me to modify that code:
$( "form" ).submit(function( event ) { // our raw input. yum. yank the newlines. var raw = $('#raw').val().replace(/(\r\n\t|\n|\r\t)/gm,"");
It worked locally with the HTML Christina had sent, so it was push the changes to github, and let her try again.
Try it again? https://t.co/odqfsgOLUg Was a bug I had not accounted for related to line returns in the text. I just tested the ones causing problems and it worked.
— Alan Levine (@cogdog) June 13, 2018
and good news!
Yup, I've run the extractor on multiple Storify pages, and no problem. Thanks so much!
— Christina Vasilevski (@cvasilevski) June 14, 2018
Thanks Christina, someone I have never communicated with, for helping me make my code a wee bit better.
It’s never quite ever done.
Featured Image:

I get by with a little help from my friends. flickr photo by anokarina shared under a Creative Commons (BY-SA) license