Monday, January 3, 2011

SparkNotes Compiler-Extractor

Ever find yourself in an English class in which the the text you're supposed to read is borderline incomprehensible?  Or if you're "that guy" who always needs to read supplement texts AFTER reading the original to make sure you have complete mastery of what you were supposed to read?

Either way, you probably read the SparkNotes.  Maybe you want to print them out and bring them to school so you can have a look at them in class.  Maybe your teacher is so magnanimous that he/she lets you use your notes on tests and/or quizzes.

If you fall in any of those categories, then you can find use in the SparkNotes Compiler/Extractor.  (If you're in middle school, you might not need this, but once you get into high school, SparkNotes will become your good friend, especially if you take higher-level English courses.  Or if you're just completely lazy.)  This way, you don't have to manually copy-and-paste the text (and waste a lot of time) for every SparkNotes page for every book that you're supposed to be reading.

I'd say that this program is pretty self-explanatory, but I'm the one who wrote it, so I'd think it's easy to use no matter what, right?  Here's a quick run-through of how to use the program.  You might want to just download and try the program first, and come back and read the rest of this post if you don't get it.

When you download the file ("SparkNotes Compiler-Extractor.zip"), you should extract the ZIP archive to wherever you want.  In your unzipped folder, you should have 6 items (in no particular order):

  • SparknotesCompiler.cs -- This is the source code for the program.  You can open it, read it, change it, and basically do anything you want with it except sell it!
  • c_SparknotesCompiler.bat -- Run this file to compile SparknotesCompiler.cs if you make any changes to the source code.
  • SparknotesCompiler.exe -- This is the actual program.  Run this program.
  • SparkNotes.dotx -- This is a word template I created just for these SparkNotes.  You just open the HTM document generated by Sparknotes.exe, copy all the text, and paste it into this template.  There's more to it, so read on.
  • SparkNotes.bas -- This is a Word macro for fixing up the formatting in your document.  You'll find out more about this further down the post.
  • styles.css -- This CSS file is needed for the generated HTM files to display correctly.  NOTE: The HTM files that are generated must be put in the same folder as the styles.css file!

Now you can compile/extract a SparkNotes!  First, run SparknotesCompiler.exe.  The first prompt wants you to complete a URL.  Let's compile Heart of Darkness by Joseph Conrad, for example.  To get SparkNotes's URL for that certain book, just Google it: "SparkNotes Heart of Darkness".  Probably the first one will be a link to it.  You can either click it or just use the web address that you see: "www.sparknotes.com/lit/heart".  All you have to fill out is the end of this URL, so type into the program: "lit/heart" and press [ENTER].

NOTE: If you get a URL like "http://www.sparknotes.com/lit/heart/section1.html", then just take out anything after the book's (probably abbreviated) name in the URL.  Also, don't include the forward-slash at the end, like the program tells you in case you didn't read it because you don't like to follow directions.

If you're just a normal user, then I recommend you just leave all the files extracted in the same folder, meaning that you shouldn't move them around and separate them.  You can move the entire folder if you want, just not the individual files.  That way, it helps keeps styles.css in the same folder as your HTM files.

When the program prompts you for a name, you should just enter the name without a path, such as "Heart of Darkness" or "Heart of Darkness - Conrad" or something like that.  Do not include the ".HTM" extension at the end; only put in the name.  Any characters not allowed in a normal file name are not allowed here.  The program will crash if you try something funny.

Now the program will start listing a whole bunch of URLs that it has finished getting the data from.  It'll tell you how long it took.  If you want to view the generated file right now, then press [ENTER] when the program is done (and gives you the prompt).  Otherwise just close it and maybe look at your SparkNotes later.

If you want a Word document version, then you have to do some work yourself (don't worry, it's pretty easy -- I already did most of it for you!).  First, you open up a new document based on SparkNotes.dotx by double-clicking it.  Then, you copy and paste in the text from your HTM document.  Remember to paste in the good-looking stuff that you normally read, not the HTML source code.  I'd fix up the formatting at the top a bit so that the book's title and author's name take up less space, but that's just my personal preference.  Next, you should change the name in the header (on the second page) to display the correct book title and author name in the corresponding places.

Here's something you might learn now: Word macros.  If you don't know what they are, it's OK because I already made it for you.  Because this post is already so long, I won't post the actual code here.

Here are the instructions for Word 2007.  If you have a different version of Word, it's probably pretty similar.  First, go to "View' on the ribbon and click "Macros" --> "View Macros" on the right.  Or, Alt - W - M - V is the Office 2007 shortcut for you.  Then, type in the name of the macro we're going to use.  For this one, I recommend something like "SparkNotes".  Then click the "Create" button.  It'll bring up this code screen.  But don't be afraid!  Click "File" --> "Import File..." and navigate to the folder where this program is.  Select "SparkNotes.bas".  Save and close the code window and go back to your Word document.  Go view your macros again.  This time, select "SparkNotes" and click "Run".  It will format your document for you.  I think that you only have to do this once, because it will save the macro with Word.  How useful!  You don't have to save this word document with the rest of the HTM files, styles.css, and the other files because Word has it's own independent formatting now.  It has no dependencies on other files!

If you're OK with a Word document (which you probably are), then you're fine.  If you want to make a PDF out of it, I recommend that you get CutePDF Writer.  It's a great, easy-to-install, free tool.  You can save/move the PDF files anywhere you want, just like the Word documents.  Just remember to keep the 6 downloaded files and the generated HTM files together!

That's all... it was pretty easy, wasn't it?  You didn't need those instructions -- you probably think I am insulting your intelligence right now!

If you didn't find the link in that massive bulk of text above, here it is again:

4 comments:

  1. Eric, you're fantastic. Thanks!

    ReplyDelete
    Replies
    1. hi...I couldn't do it..can u please help me...

      Delete
  2. when i try to do it..it stops working..please help.....

    ReplyDelete
  3. same problem, when i entered the folder name and press enter, the whole program crashes down... help

    ReplyDelete