summaryrefslogtreecommitdiff
path: root/texmf-dist/doc/latex/fetchbibpes/examples/bibpes_replace.tex
blob: 7fd9f1d4c21a09087b4691b88e593809f497d926 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
\documentclass{article}
%\usepackage{array,calc}
\usepackage{xcolor}
% useverses=none avoids a warning in the log when there is not value for
% userverses. In this document we define our verses 'by hand' using the
% declareBVs environment.
\usepackage[ignorecfg,useverses=none]{fetchbibpes}[2016/09/19]

\providecommand\cs[1]{\texttt{\char`\\#1}}
\let\pkg\texttt

\addtoBibles{NKJV}

\begin{document}

\section{Highlighting the replace key.}

As described in the \texttt{fetchbibpes\_man.pdf}, we can search and replace
text for a single passage created by \cs{fetchverse}. In this document, we
demonstrate the basic features of the \texttt{replace} key and demonstrate
some `radical' applications as well.

We begin with an environment not documented in \texttt{fetchbibpes\_man.pdf},
the \texttt{declareBVs} environment.
\begin{verbatim}
\begin{declareBVs}
\BV(Mat 2:1 KJV) Now when Jesus was born in Bethlehem of Judaea
in the days of Herod the king, behold, there came wise men from
the east to Jerusalem,\null
\end{declareBVs}
\end{verbatim}
Its used to define a Bible passage as seen in the DEF file. It is useful
declaring a passage or two under discussion. The syntax for the argument of
\cs{BV} is explained in the reference manual of \pkg{fetchbibpes}. Once
declared, we can use it.
\begin{declareBVs}
\BV(Mat 2:1 KJV) Now when Jesus was born in Bethlehem of Judaea in the days
of Herod the king, behold, there came wise men from the east to Jerusalem,\null
\end{declareBVs}

This verse is fetched as follows.
\begin{quote}
\fetchverse{Mat 2:1}
\end{quote}
The verse continues to the next passage (Mat 2:2) and ends with a comma. As
this is a stand alone quotation, we want to end the passage with a period
instead. There are two commas in the verse, we replace the comma that follows
`Jerusalem'.
\begin{quote}
\verb|\fetchverse[replace={Jerusalem,}{Jerusalem.}]{Mat 2:1}|\\[3pt]
\fetchverse[replace={Jerusalem,}{Jerusalem.}]{Mat 2:1}
\end{quote}
For the second example, we do two replacements: (1) replace the comma
following `\texttt{Jerusalem}' with a period; and (2) change every instance
of `\texttt{Jesus}' to `\verb|\textbf{\textcolor{red}{Jesus}}|', just because
we can.
\begin{quote}
\verb|\fetchverse[replace={Jerusalem,}{Jerusalem.}|\\
\null\hskip20pt\verb|{Jesus}{\textbf{\textcolor{red}{Jesus}}}]{Mat 2:1}|\\[3pt]
\fetchverse[replace={Jerusalem,}{Jerusalem.}
{Jesus}{\textbf{\textcolor{red}{Jesus}}}]{Mat 2:1}
\end{quote}
\let\bMrk\relax\let\eMrk\relax
\begin{declareBVs}
\BV(Gen 1:1 KJV Mrk)  In the \bMrk beginning God \eMrk %
created the heaven and the earth.\null
\end{declareBVs}
Generally, commands in the first argument are discouraged, but they can be
used very carefully. In the example below, we test a couple of things. We
defined a new passage
\begin{verbatim}
\letEach\bit\eit\bCol\eCol\to\relax
\BV(Gen 1:1 KJV Mrk) In the \bMrk beginning God \eMrk created %
    the heaven and the earth.\null
\end{verbatim}
We've marked off arbitrary text for manipulation. In the example below, we
(1)~change all text between the markers to bold and red; (2) change the bold
(\cs{bfseries}) to san-serif (\cs{sffamily}); (3)~convert \cs{sffamily} to
\cs{ttfamily}. The code is,
\begin{verbatim}
\fetchverse[%
    replace={\bMrk}{\bgroup\protect\bfseries\protect\color{red}}
    {\eMrk}{\egroup}{\bfseries}{\sffamily}{\sffamily}{\ttfamily},
alt=Mrk]{Gen 1:1}
\end{verbatim}
Note the use of \cs{protect} in the first replacement text, this prevents \cs{bfseries}
and \cs{color} from being expanded into their primitive definitions; consequently, the
tokens \cs{bfseries} and \cs{color} are still present by the time of the second search.

Will it work? I wouldn't have wasted my time typing this out
if it didn't! Here goes!
\begin{fpquote}[rightmargin=0pt]
\fetchverse[replace={\bMrk}{\bgroup\protect\bfseries\protect\color{red}}{\eMrk}{\egroup}
{\bfseries}{\sffamily}{\sffamily}{\ttfamily},alt=Mrk]{Gen 1:1}
\end{fpquote}
Ho, ho, it worked!

\letEach\bit\eit\bCol\eCol\to\relax
\begin{declareBVs}
\BV(Mat 8:10 NKJV Mrk) When Jesus heard \bit it\eit, %
He marveled, and said to those who followed, \bCol"Assuredly, %
I say to you, I have not found such great faith, not even in %
Israel!\eCol\null
\end{declareBVs}

\medskip\noindent
Here's another crazy idea. Consider the following passage:
\begin{verbatim}
\letEach\bit\eit\bCol\eCol\to\relax
\begin{declareBVs}
\BV(Mat 8:10 NKJV Mrk) When Jesus heard \bit it\eit, He marveled,
and said to those who followed, \bCol"Assuredly, I say to you,
I have not found such great faith, not even in Israel!\eCol\null
\end{declareBVs}
\end{verbatim}
The passage is marked up several commands \cs{let} to \cs{relax}. If no replacement occurs, the passage should
appear normally, without any special formatting. However, if we do a nice replacement, we get formatting.
\begin{quote}
\fetchverse[replace={\bit}{\textit\bgroup}{\eit}{\egroup}
{\bCol}{\bgroup\color{red}}{\eCol}{\egroup}{!}{!''},from*=NKJV,alt=Mrk]{Mat 8:10}\bDQ
\end{quote}
The Words of Jesus continue on to the next verse, not displayed, so we'll replace the final exclamation
point (\texttt{!}) with `\verb|!''|'.

\end{document}