Git Product home page Git Product logo

biblelatex's Introduction

Bible Reference LaTeX Preprocessor

Author: Jemmin Chang ([email protected])

This script finds Bible passage references in a LaTeX source file like:

\bible{Gen1:1-5}

and replaces them with the text of the passage from the ESV in a configurable format (see Configuring output format, outputting the result to stdout. The acceptable syntax is determined by the web API used, which is http://www.esvapi.org/api. The first argument is used as the value for the "passage" URL parameter, so whatever that URL parameter accepts will work. In particular, the beginning and ending verse numbers are optional, according to the usual practice, so Gen1, Gen1:1, are also fine. The book name can be specified fully or with the first 3 letters/numbers (e.g. 1Co for 1 Corinthians), and capitalization doesn't matter. For more details, see the API website. Note that there is a (pretty comfortable) rate limit of 5,000 queries/day/IP.

Configuring output format

To configure the output format, add this command to your LaTeX source before the \bible commands you want it to configure (you can run this command again to reconfigure; \bible commands will always output according to the last \setbible configuration):

\setbible{format_string}{[\text_wrapper]}

format_string is a Python-style formatting string with these specific two mapping keys: (passage) and (citation). These keys are hardcoded in the script; you must use them exactly. (passage) will be substituted with the passage text and (citation) will be substituted with the passage citation (e.g. 'Genesis 1:1-5'). See Default output format for an example.

\text_wrapper is a single text-formatting LaTeX command which will be wrapped around each paragraph of the passage, with \textnormal used to cancel it around the verse numbers. (This works for things like \textit or textbf, but not arbitrary commands, of course.) It is optional in the sense that if you let it be the empty string, it won't have any effect, as wrapping things in braces does nothing in LaTeX.

Default output format

The default output format configuration before you run any \setbible is as follows.

format_string: %(passage)s -- %(citation)s (ESV)
\text_wrapper: \textit

Running the preprocessor

The idea is to use this script as a preprocessor for LaTeX files (run before you compile with your normal LaTeX compiler). For convenience, you can combine the steps in a function in your bashrc, e.g. (assuming this script lives in your home directory):

function biblepdflatex {
    python ~/insert_bible_passages.py $1 > ${1}biblerefpreprocessed
    pdflatex ${1}biblerefpreprocessed
    rm ${1}biblerefpreprocessed
}

Of course, this will prevent you from using additional options with pdflatex, so if you need that, you may need to run the preprocessor separately first.

biblelatex's People

Contributors

jchang504 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.