summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/bibletext/bibletext.sty
blob: 21abb5a97de2bf439ba0ac54d873c07fa3065226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{bibletext}
	[2017/09/01 v0.1.2 Insert Bible texts]

\newif\ifbibletext@defined
\bibletext@definedfalse
\newcommand{\bibletext@checkdefined}[1]{%
	\ifcsname#1\endcsname%
		\bibletext@definedtrue%
	\else%
		\bibletext@definedfalse%
	\fi%
}

\bibletext@checkdefined{DeleteShortVerb}
\ifbibletext@defined%
	\DeleteShortVerb{\|}%
\fi

\RequirePackage{pgfkeys}
\RequirePackage{pdftexcmds}

\newif\ifbibletext@Ref
\newif\ifbibletext@OmitChapter
\newif\ifbibletext@OmitRepeatedChapter
\pgfkeys{
	/bibletext/.is family, /bibletext,
	default/.style={
		translation=kjv,
		ref=false,
		omitchapter=false,
	},
	translation/.estore in = \bibletext@Translation, % unused for now
	ref/.is if=bibletext@Ref,
	omitchapter/.is if=bibletext@OmitChapter,
	omitrepeatedchapter/.is if=bibletext@OmitRepeatedChapter,
}
\newcommand\bibletext[2][]{%
	\pgfkeys{/bibletext, default, #1}%
	\ifbibletext@Ref%
		\ifbibletext@OmitRepeatedChapter%
			\input{|"bible -f '#2' | grep -o '[[:digit:]].*' | head -n1"}%
			\input{|"bible -f '#2' | grep -o '[[:digit:]][[:digit:]]*[[:space:]].*' | tail -n+2"}%
		\else\ifbibletext@OmitChapter%
			\input{|"bible -f '#2' | grep -o '[[:digit:]][[:digit:]]*[[:space:]].*'"}%
		\else%
			\input{|"bible -f '#2' | grep -o '[[:digit:]].*'"}%
		\fi\fi%
	\else%
		\input{|"bible -f '#2' | cut -d' ' -f2-"}%
	\fi%
	\unskip%
}
\AtEndOfPackage{
	\ifnum\pdf@shellescape=1\relax\else
		\PackageError{bibletext}
			{You must invoke LaTeX with the -shell-escape flag}
			{Pass the -shell-escape flag to LaTeX. Refer to the bibletext.sty
				documentation for more information.}
	\fi}
\endinput