Heal Your Church WebSite

Teaching, rebuking, correcting & training in righteous web design.

Hyperlink Bible References using Scripturizer 1.3

After almost a year of people emailing me and leaving comments, I’ve finally made the time to update my Scripturizer Perl Module. The changes aren’t big, but they provide dramatic relief to a series of annoyances that have encumbered some of you from adding more Scripture references to your blogs, church websites and other electronically distributed information. I apologize for taking so long to get around to such an important issue.

Addition of Abbreviations:

I think a comment by Werner Peters (no relation) on Rob Hulson’s blog sums up the need for this addition best when he writes:

“It gets a little tedious writing out Deuteronomy every time!”

Yeah, you’ve said a mouth full. So I’ve added various abbreviations to the new and improved version. I’ve done so a more hard-coded format than I like, but the regular expressions are complex enough. I want a novice to be able to look at the existing expressions for Books in the Bible and add or alter their own (expressions) as they need.

This was a painstaking process I automated to some degree with some Perl to split book names after the first three characters, then again at the fourth or fifth character depending on the length and vowel placement. I then went through each of the expressions and added or subtracted based upon a list of common Bible queries over at the ESV Bible. Many thanks to Stephen Smith for directing my attention to this data, it was incredibly helpful!

Finally, I took care of a small handful of typos, involving pluralization. I still need to write a “mop-up” option to weed-out typos such as “revalations” and “mathew.”

Eliminate the addition of a space before non-white space bug.

This bug is exceptionally annoying to those who like to encapsulate their scripture references between brackets or parenthesis, such as (1 John 1:9). So annoying that back last August, Jason Rust left a comment on my blog with a fix. A fix later tried and tested and nicely documented by Joseph Markey.

Essentially, the bug was introduced when evaluating the space between a volume reference, e.g. 1 John 1:9, which in turn put a space in front of a non-volume reference such as John 1:9. The bug occurred when the character directly before the non-volume number scripture reference was anything other than a space.

What the fix does is it pushes the evaluation for the space into a variable, then pushes it in front of the hyperlink. An approach that works much better than a hard-coded space as nothing before the reference is then accurately rendered as nothing just before the hyperlink.

Eliminate the ‘c’ in the gcex modifier in the regular expression.

This regular expression mode modifier did nothing in this context, except possibily eat up CPU and sometimes throw errors in the latest version of Perl.

ESV Bible flip-flop

The great people at the ESV Bible have been so helpful and responsive in the past, I figured why not say thanks in the form of directing those who select the English Standard Version option to the ESV online Bible website.

In MovableType, that would be <$MTBodyEntry scripturize=”ESV”$>

Using Scripturizer as a Perl Module, that would be print scripturize(”Phil. 4:6-7″, “ESV”).

XHTML compliant hyperlinks

Ampersands are now represented as &amp;

Usage Notes

Well, this is sorta a no-brainer. For those of you using the MovableType Scripturizer plug-in, leave the file /plugins/Scripturizer.pl alone.

Replace the file /extlib/Sermonizer/Scripture.pm with the referenced code below. That should be it, but first make a backup of the old one just in case.

Here is where I have it set-up on my PC for general purposes using ActiveState’s Perl Dev Kit: c:\perl\site\lib\Sermonizer\Scripturizer.pm.

Future Iterations

That’s pretty much it. If you can think of anything else, let me know and we’ll see about adding it.

Otherwise, I’d like to work on something else Stephen Smith of ESV sent me, a routine that fetches a snippet via their webservice. His code works but I have some MT centric things I want to tackle when slicing-n-dicing an XML stream of Matthew 5. That and I feel a full-blown ESV.pm module coming on. Well, Stephen has already created one, but I’ve got these ideas … and this compiler … well, you get the picture.

There is also a much needed death-blow to typos method subroutine that needs to be written. The question is, do I write it into the same pass, or do I run first a clean-up pass filter, then scripturize? Any thoughts would be appreciated.

Again, thanks to everyone for their input. I couldn’t have done any of this without your valuable input. Even if I could, it wouldn’t have been as much fun.

Download the PM … Sermonizer::Scripturizer.pm

view it as text: Sermonizer::Scripturizer.pm

Find a bug? Have a suggestion? Leave a comment. We’ll do our best to see it gets taken care of … quickly. Get it to me in the next couple of days and I’ll try to add it as an update to this article.


  1. Thanks for all your hard work on this! I did notice that you had a keen idea for the regex’s on the names of the books. For example, the book of Esther can be found as Est. or Esth. and you only used one pattern to find it. However, that pattern also matches Esthhhh. (which BibleGateway doesn’t like at all), since the literal regular expression is Esth*\. and perl interprets the asterisk to mean “zero or more occurences of the previous character.” Unless I missed something, an alternative to that would be to use the question mark in place of the asterisk, which says that the previous character may or may not be there. So the regex would become Esth?\. which only matches what I would expect it to.

  2. Just wanted to say that I just starting using this, and it’s great. I made one modification, though, I changed the link to Bible Gateway to open in a blank window so that people would still have my blog page if they wanted it. Thanks for your service!

  3. Dean, I’ve found a bug/oversight

    If I type in Matthew 7:7-11 then it works fine. However if I type in Matthew 7: 7-11 (note the extra space) it just returns a hyperlink for Matthew 7. It’s not a major issue, but I thought it was worth bringing to your attention.

  4. Now all I need to do is find one that works with PHP ;]

  5. Pingback: the Great Lands

  6. Ok, so per Dean’s suggestion, I’ve removed the spawning a new window. I do, however, have a bug. Seems that if I type Phil 1:6 it doesn’t scripturize it. Does it have to have the period at the end?

  7. Dean, the ampersands on line 71 are still strict ampersands, not &amp; thus resulting in invalid XHTML. I changed it in the code and my site validates again.

    71: “http://biblegateway.com/cgi-bin/bible?language=english&version=$bible&passage=”);

    Should be:

    71: “http://biblegateway.com/cgi-bin/bible?language=english&amp;version=$bible&amp;passage=”);

    Other than that, I’m loving it!

  8. Kristen,

    Yes, the abbreviated book reference must end in a period.

  9. But what about references like Mk 3:12? or Jn 7:1-9 ? because they by no means should end with a period, but obviously you’ll still want them to appear as links. That said, they may actually do this, I don’t know, I haven’t checked.

  10. Quadra,
    Scott Yang previously ported Scripturizer to PHP a while back if you’re interested.

  11. Pingback: Fat Guy...Little Coat

  12. I installed it and it works great. I’ve just got a couple of small requests:

    The HREF link extends onto the character space in this example:

    …read John 3:16 to find…

    Also, in the .pm file, I edited the code to simple change the HREF title to:

    title=\”Read $passage from the ESV Bible\”

    And the title ends up looking like:

    “Read John 3:16 from the ESV Bible”
    (note the extra character space)

    It does not pick up passages if they are in ALL CAPS.

    Not trying to be picky, just letting you know what I’ve seen. I love the plugin!


  13. The reason I bring up the point about the link extending onto the character (or white) space is for those of us who use CSS to underline links when hovered.

    Also, the “note the extra space” seems worthless since the extra space was removed by MT in my comment.

    “Read John 3:16  from the ESV Bible”

    Maybe that will work in order to show you what I mean?

  14. Changing line 67 of Scripturizer.pm to the following should fix the extra space in the link and allow for an extra space between the colon and the verse numbers which was also requested:

    my $verses = qr{ \d+ (: \s* \d+)* (?: \s* [-&] \s* \d+)* }x;

    I am using that and haven’t seen any problems yet.

  15. Pingback: salguod.net

  16. Pingback: salguod.net

  17. Pingback: salguod.net

  18. Pingback: salguod.net

  19. Pingback: salguod.net

  20. Pingback: salguod.net

  21. I can’t figure out whaat I’m doing wrong! I’d love to hve this work, but alas, it does not.

    – I cut and pasted into Notepad and saved as directed.
    – Used WiseFTP and uploaded to my site, as directed (I tried both ASCI an Binary).
    – I set the permissions on the files to 755.
    – I changed all my templates that had the tag to be (I tried “NIV” too).

    Do I need to type in anything special? I tried using Acts 2:38 and John 3:16 in my test post, but neither worked. Help!

  22. I fixed mine. When I cut and pasted the template tag from Rob Hulson’s site, I got a forward slanted quote instead of a vertical quote (“). Also, using “1” in my tag produced a link that Biblegateway didn’t understand. Changing it to “NIV” fixed that.

    I am now a very happy blogger.

  23. I also experienced the copying glitch that salguod mentioned. The copied quotes were messing things up. Also, I was confused about this part of the installation guide:

    —Copy the next bit of text, save it as a file and name it “Scripturizer.pm” Put this one in the following directory:


    Make sure your file is named Scripturizer.pm, not Scripture.pm

  24. Sparticus – one problem I can see with two-letter non-period abbreviations is that certain book abbrev. are also abbrev. for other things. For example, if I say “Hey everyone, I use MT 2.661 on my site,” it may become a link to Matthew chapter 2, followed by .61 (which will probably not be a link). Since such references are common, and there are standard abbreviations, I’d think it would be a better to use them.

  25. Dean-
    Forgive me if I or others have mentioned this before, but I have a question about RSS. In my MT blog, my RSS feed does not include Scripturizer hyperlinks. I’d like people to be able to read the entries (from Daily Texts, at http://www.radicalcongruency.com/DailyTexts/) via RSS, but there are no links, and the links are crucial (the feed is here). I assume this happens because the RSS feed is somehow generated without referring to Scripturizer. I’ve turned off the Remove_html tag that by default strips HTML from entries in the RSS feed (why you’d want to do that, I have no idea).

    Any ideas?

  26. Another bug I found. I recently type this in an entry at my site:

    … Romans 16:17-18, 2 Thessalonians 3:6, 1 Timothy 1:3-7, …

    The links I got were:

    Romans 16:17-18, 2
    Thessalonians 3:6, 1
    Timothy 1:3-7

    Those last two obviously don’t work, but the first one did give me verses 2, 17 and 18 of Romans 16. I separated the entries with semicolons to fix it:

    Romans 16:17-18; 2 Thessalonians 3:6; 1 Timothy 1:3-7

    Another cool thing I did with it was to add scripturizer to the comment tags (MTCommentBody scripturize=”NIV”) as well so any scripture references readers use get linked as well.

  27. Pingback: Spare Change

  28. I’ve installed the plugin and I really like it. I’ve noticed though that the link doesn’t come out right for passages that span chapters.

    For example: Genesis 6:9-9:29 links as Genesis 6:9-9 which obviously isn’t correct. Anyone have any ideas?

  29. I’ve installed the plugin and I really like it. I’ve noticed though that the link doesn’t come out right for passages that span chapters.

    For example: Genesis 6:9-9:29 links as Genesis 6:9-9 which obviously isn’t correct. Anyone have any ideas?

  30. Sorry for the double post. I’ve found that changing line 67 of Scripturizer.pm to the following seems to correct the issue I was experiencing:

    my $verses = qr{ \d+ (: \s* \d+)* (?: \s* [-&] \s* \d+)* (: \s* \d+)* }x;

    Btw, this change also incorporates the modification submitted by Joseph Markey in an earlier comment.

  31. Pingback: tim's journal

  32. Pingback: tim's journal

  33. Pingback: tim's journal

  34. Pingback: Pat Loughery @ Mt. Si Vineyard

  35. Pingback: Pat Loughery @ Mt. Si Vineyard

  36. Pingback: Pat Loughery @ Mt. Si Vineyard

  37. Pingback: Pat Loughery @ Mt. Si Vineyard

  38. Pingback: Pat Loughery @ Mt. Si Vineyard

  39. Pingback: Pat Loughery @ Mt. Si Vineyard

  40. Pingback: Pat Loughery @ Mt. Si Vineyard

  41. I had a few praises and prayer requests (a little christianese for a pat on the back and a request for a few modifications).

    Thank you Dean for creating this original script and thanks to all of you who have supported it and added to it. What an amazing thing to give people the easy power to point to God’s word.

    OK, on to my requests.

    I suggest that each time you update the plugin that you carry over the installation instructions. Some people aren’t that bright (like myself) and it helps to have it all on one page.

    On that note, I could not find a clear representation of how to incorporate the plugin into movable type. I assumed that it was nothing more than adding scripturize= to an existing tag, but that was a guess. Clarification is always good.

    Lastly, why don’t we incoporate a way to scripturize paragraphs, but not be restricted to a certain version for that section. Instead of scripturize=ESV in the tag, why not have the option to right the abbreviated version after the scripture reference, e.g. John 3:17-18 NIV. That way you can refer to different translations within the same section.

    Well, those are my questions and observations. I look forward to using this valuable tool. If I have overlooked anything and my requests are already answered or met, then I apologize in advance.

    God bless y’all,

  42. With all the hullabaloo about the new MT licensing/pricing issues, many are heading for the hills (WordPress). Any thoughts on re-writing for WP and a PHP system?

  43. When I try to install this script, I get this error from my error log:

    syntax error at Scripturizer.pl line 16, near “package plugins::Scripturizer”
    BEGIN not safe after errors–compilation aborted at Scripturizer.pl line 18.

    Any ideas?

  44. Anyone tried this with Greymatter? I’d love to have this on my site, and, if provided with docummentation, I can install a Perl script. But I just don’t have the knowledge to go in a hack away at it myself.

    Can anyone help?

  45. Hey Dean, does this work with MT 3.X?

  46. Any thoughts on re-writing for WP and a PHP system?

    Check out Radical Congruency. I think that they’ve implemented Scripturizer in WP.

  47. Pingback: the Great Lands

  48. Pingback: the Great Lands

  49. There is a plugin for ExpressionEngine now.

    EE Plugin