Home

Awesome

Bible Gateway to Markdown Script

This script uses BibleGateway.com's wonderful passage lookup tool to find a passage and turn it into Markdown usable in other ways.

The Markdown output includes:

Optionally it also includes:

The output is displayed in the terminal and also gets copied to the clipboard.

When the 'Lord' is shown with small caps in the Old Testament, it is output as upper-case 'LORD'. (In English; please let me know about other languages to support.)

When the original is shown red letter (i.e. the words of Jesus), this can be rendered in bold in the Markdown output, with the --boldwords option.

Some versions (e.g. LEB) include some words in italics. This is maintained in the markdown output, though where there is a reason for the italicisation available, that isn't kept. (There would be too much of it ...)

Chapters and verses can optionally be prefixed with markdown H5 and H6 headers respectively, using the --newline option.

Installation

I assume you have a working ruby installation. (Sorry, but I cannot provide guidance or support for this step, as there are just too many variations of version and operating system. There are plenty of existing sites that can help with this.)

Check you have installed the necessary gems (colorize, optparse, and clipboard) -- for example run gem install colorize or sudo gem install colorize etc.).

Add the .rb script to your PATH, and then set it as executable (chmod 755 bg2md.rb).

Running the Script

From the command line

Usage: ruby bg2md [options] reference

(or, depending on your ruby installation, bg2md.rb [options] reference)

The output is displayed in the terminal and also gets copied to the clipboard.

It passes 'reference' through to the BibleGateway parser to work out what range of verses should be included. This gives lots of flexibility, for example Jn 3.16, John 3:16 and jn3:16 all return the same verse. The reference term is concatenated to remove spaces, meaning it doesn't need to be 'quoted' on the command line. You can specify a verse range e.g. Jn 3.16-17 or even across chapters, e.g. 1 Cor 12.31-13.13. NB: This does not yet support multiple separate passages; instead just run for each passage separately.

The following options are available:

OptionOption (longer form)Meaning
-b--boldwordsMake the words of Jesus be shown in bold
-c--copyrightExclude copyright notice from output
-e--headersExclude editorial headers from output
-f--footnotesExclude footnotes from output
-h--helpShow help
-i--infoShow information as I work
-l--newlineStart chapters and verses on a new line that starts with an H5 or H6 heading
-n--numberingExclude verse and chapter numbers from output
-r--crossrefsExclude cross-refs from output
-t--test FILENAMEPass HTML from FILENAME instead of live lookup. 'reference' must still be given, but will be ignored.
-v--version VERSIONSelect Bible version to lookup using BibleGateway's abbreviations (default:NET)

Writing to Markdown files

If you want to write to a markdown note in the current directory, then use bg2md.rb [options] "reference" > notename.md. (Here the passage will need to be quoted if it contains spaces.) For example this is how I tend to run it:

bg2md -b -c -e -r -v NIV "Jn 3.16-17" > passage.md

From Launchers

With a little configuration it's possible to run this from Alfred or Raycast or other launchers, through whatever mechanism they use to 'Run script' with a query argument as the Bible reference. You'll likely need to create slightly different configurations for each Bible translation that you use.

Important Disclaimers

Supporting you

If you spot problems, or have requests for improvement, please raise an issue at the bg2md GitHub repository. Please give details on what calls you make, and what OS and version you're using, and the version of the ruby install. I cannot support getting ruby working itself.

Supporting me

If you would like to support my late-night work writing useful scripts, you can through

<img width="200px" alt="Buy Me A Coffee" src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg">

Thanks!

History

Please see the CHANGELOG.