\documentclass{article}
\usepackage{pdfcomment}
\hypersetup{bookmarks=false}
\usepackage[%
    useverses=none
%    useverses=verses
]{fetchbibpes}

\hypersetup{pdfpagemode=UseNone}

\def\cs#1{\texttt{\char`\\#1}}
\let\pkg\textsf
\let\env\texttt

\addtoBibles{YLT,ISV}


\title{Highlighting the \texorpdfstring{\protect
  \cs{fetchversestxt}}{\textbackslash{fetchversestxt}} command}
\author{D. P. Story}

\reversemarginpar

\begin{declareBVs}
\BV(1Co 1:1 KJV) Paul, called to be an apostle of Jesus Christ through the will of God, and Sosthenes our brother,\null
\BV(1Co 1:2 KJV) Unto the church of God which is at Corinth, to them that are sanctified in Christ Jesus, called to be saints, with all that in every place call upon the name of Jesus Christ our Lord, both theirs and ours:\null
\BV(1Co 1:3 KJV) Grace be unto you, and peace, from God our Father, and from the Lord Jesus Christ.\null
\BV(1Co 1:4 KJV) I thank my God always on your behalf, for the grace of God which is given you by Jesus Christ;\null
\BV(1Co 1:5 KJV) That in every thing ye are enriched by him, in all utterance, and in all knowledge;\null
%
\BV(1Ki 1:5 ISV) Meanwhile, about this time Haggith's son Adonijah began to seek a reputation for himself and decided, "I'm going to be king!" So he prepared chariots, cavalry, and 50 soldiers to serve as a security detail to guard him.\null
%
\BV(Gen 1:1 YLT) In the beginning of God's preparing the heavens and the earth--\null
\BV(Gen 1:2 YLT) the earth hath existed waste and void, and darkness is on the face of the deep, and the Spirit of God fluttering on the face of the waters,\null
\BV(Gen 1:3 YLT) and God saith, `Let light be;' and light is.\null
\end{declareBVs}

%\parindent0pt \parskip6pt

\begin{document}

\maketitle

The \cs{fetchversestxt} command does not expand to typeset content, rather,
it defines two commands \cs{versetxt}, which contains the verse reference,
and \cs{passagetxt}, which contains the passage for that verse. Take as an
example, \verb~\fetchversestxt[showfirst]{1Co 1:1-2}~\fetchversestxt[showfirst]{1Co 1:1-2}:
it expands to nothing typeset; however, the command `\cs{versetxt}' expands
to `\versetxt' and the command `\cs{passagetxt}' expands to `\passagetxt' The
next expansion of \cs{fetchversestxt} overwrites the \cs{versetxt} and
\cs{passagetxt} commands. You can use \cs{fetchversestxt} with the usual
options, any formatting options are ignored (I hope), otherwise, all options
should work as described in \texttt{fetchbibpes\_man.pdf}.

The application\fetchversestxt[showfirst]{1Co 1:1-}\pdfmargincomment[author={\versetxt}]{\passagetxt}
my former-friend had in mind was to pass the \cs{passagetxt} command to an
annotation macro such as \cs{annotpro} (\pkg{annot\_pro} package) or
\cs{pdfcomment} (\pkg{pdfcomment} package). What you see in the margin is a
sticky note put there by  \cs{pdfmargincomment} from the \pkg{pdfcomment}
package.

We try this with a different book that has a passage containing an apostrophe
and single quotes.\fetchversestxt[showfirst,abbr=none,from*=YLT]{Gen
1:1-3}\pdfmargincomment[author={\versetxt}]{\passagetxt}
In\eSQ\fetchversestxt[typeset,showfirst,abbr=none,from=YLT,localdefs=\gobbleto{and}{\gobbletoand},
replace={saith,}{saith, `Let light be;' and\gobbletoand}]{Gen 1:1-3}
\versetxt\space(YLT), it is written that \textsl{\passagetxt} If you have
eagle-eyes, you would have noticed the different treatment of the single
quotes and apostrophe in the passage listed in the sticky note and the one
that is typeset. In the latter case, the \texttt{typeset} option is used as
well as some fancy uses of the \texttt{replace} replace option to get the
naughty single quotes and apostrophes to look right.

\showTranslAlways
\translTxtFmt{ (#1)}

Before\fetchversestxt[showfirst]{1Co 1:1-2}\pdfmargincomment[author={\versetxt}]{\passagetxt} continuing the discussion of the \texttt{typeset} option, let us pause
to illustrate the \cs{showTranslAlways} and \cs{translTxtFmt}. Notice that
when quoting the default Bible (KJV) in the first sticky note above, the
transition note does not appear in the title heading of the sticky note, this
is because the \texttt{transl} key was not used. We expand
\cs{showTranslAlways} to always show the translation note (refer to all the
remaining sticky notes in this document). We also change the formatting for the transition notes
in the title bar of the sticky notes by executing \verb|\translTxtFmt{ (#1)}|. All subsequent comment notes
will reflect this change. We conclude this paragraph by inserting a sticky note in the margin that uses the default Bible (KJV).


The rest of this article discusses the \texttt{typeset} option using\fetchversestxt[abbr=none,from=ISV]{1Ki 1:5}
\versetxt.\pdfmargincomment[author={\versetxt}]{\passagetxt}
This passage contains double quotes (\texttt{"}) and apostrophes (\texttt{\char13}).

\medskip\noindent
\textbf{The \texttt{typeset} option of \cs{fetchversestxt}.} If, for whatever reason, you want
to typeset the \cs{passagetxt}, as we've done above, you can use the
\texttt{typeset} option. This will create the same passage (\cs{passagetxt})
as \cs{fetchverses}.

\medskip\goodbreak\noindent
\verb~\fetchversestxt[typeset,abbr=none,from*=ISV]{1Ki 1:5}\passagetxt~\\[3pt]
\bDQ\eSQ\fetchversestxt[typeset,abbr=none,from*=ISV]{1Ki 1:5}\passagetxt

\medskip\noindent
\verb~\fetchverses[abbr=none,from*=ISV]{1Ki 1:5}~\\[3pt]
\bDQ\eSQ\fetchverses[abbr=none,from*=ISV]{1Ki 1:5}

\medskip
This passage has two apostrophes, which make it difficult to deal with
correctly. We'll use advanced techniques. In the optional argument of both
commands \cs{fetchversestxt} and \cs{fetchverses}, we use the
\texttt{replace} option:
\begin{flushleft}\small
\quad\verb~replace={decided,}{decided, ``I'm going to be king!'' So\gobbletoSo}~
\end{flushleft} were we have already declared
\verb~\gobbleto{So}{\gobbletoSo}~.

\medskip\noindent
\gobbleto{So}{\gobbletoSo}
\verb~\fetchversestxt[typeset,abbr=none,from*=ISV,replace=~\\
\verb~{decided,}{decided, ``I'm going to be king!'' So\gobbletoSo}]~\\
\verb~{1Ki 1:5}\passagetxt~\\[3pt]
\bDQ\eSQ\fetchversestxt[replace={decided,}{decided, ``I'm going to be king!'' So\gobbletoSo},typeset,abbr=none,from*=ISV]{1Ki 1:5}\passagetxt

\medskip\noindent
\verb~\fetchverses[abbr=none,from*=ISV,replace={decided,}~\\
\verb~{decided, ``I'm going to be king!'' So\gobbletoSo}]{1Ki 1:5}~\\[3pt]
\bDQ\eSQ\fetchverses[replace={decided,}{decided, ``I'm going to be king!'' So\gobbletoSo},abbr=none,from*=ISV]{1Ki 1:5}

\medskip
Now for the proof in the pudding. When the \texttt{typeset} option is on,
both forms yield the same results, but now let's take away the
\texttt{typeset} option and put the \cs{passagetxt} in a comment
field.\fetchversestxt[abbr=none,from*=ISV]{1Ki 1:5}
\pdfmargincomment[author={\versetxt}]{\passagetxt}


\medskip\noindent
\textbf{The \texttt{typeset} and \texttt{typeset*} options with a value.} The
rest of this article discusses the \texttt{typeset} and \texttt{typeset*}
options. As a rule, if \cs{passagetxt} is to be passed to an annotation, the
\texttt{typeset*} option should be used if it has a value; if it does not
have a value, then there is no reason to use \texttt{typeset} or
\texttt{typeset*}, under normal circumstances. Here we use \texttt{typeset*}
for both \cs{fetchverses} and \cs{fetchversestxt}. We
use\fetchversestxt[typeset*={replace={ad-n-ahy-juh}{ad-n-\textbf{ahy}-j\textit{uh}}},abbr=none,from*=ISV,replace={Adonijah}{Adonijah
(ad-n-ahy-juh)}]{1Ki 1:5} \versetxt\space as our sample verse, and manipulate it
with the \texttt{replace}
option.\pdfmargincomment[author={\versetxt}]{\passagetxt} This passage
contains double quotes (\texttt{"}) and apostrophes (\texttt{\char13}). The ``raw'' passage is,
\begin{quote}
\verb~\fetchverses[abbr=none,from*=ISV]{1Ki 1:5}~\\[3pt]
\fetchverses[abbr=none,from*=ISV]{1Ki 1:5}
\end{quote}
Our goal with this passage is to correct the first apostrophe (Haggith`s son
should be Haggith's son), and to insert a phonetic spelling of Adonijah. This passage
will be typeset as well as inserted into a PDF annotation, so we must be sure not to
include any {\LaTeX} formatting commands. After hours of meditation, the following options
were taken:
\begin{fpquote}[rightmargin=0pt]\small
\verb~[typeset*={replace={ad-n-ahy-juh}{ad-n-\textbf{ahy}-j\textit{uh}}},~\\
\verb~abbr=none,from*=ISV,replace={Adonijah}{Adonijah (ad-n-ahy-juh)}]~
\end{fpquote}
When these options are for \cs{fetchversestxt}, the value of
\texttt{typeset*} is ignored; as a result, Adonijah is replaced by Adonijah
(ad-n-ahy-juh), see the comment note below. When these options are applied to
\cs{fetchverses}, the \texttt{replace} value is automatically modified to
read,
\begin{fpquote}[rightmargin=0pt]
\verb~replace={Adonijah}{Adonijah (ad-n-ahy-juh)}~\\
\qquad\verb~{ad-n-ahy-juh}{ad-n-\textbf{ahy}-j\textit{uh}}}~
\end{fpquote}
As a result, both versions of the passage a phonetic spelling of Adonijah, but the typeset version include changes of
font styles.

\medskip
The final results of this set of argument is given below.
\begin{quote}
\bDQ\eSQ\fetchverses[typeset*=
  {replace={ad-n-ahy-juh}{ad-n-\textbf{ahy}-j\textit{uh}}{decided,}{decided, ``I'm going to be king!'' So\gobbletoSo}},
  replace={Adonijah}{Adonijah (ad-n-ahy-juh)},abbr=none,from*=ISV]{1Ki 1:5}\fetchversestxt[typeset*=
  {replace={ad-n-ahy-juh}{ad-n-\textbf{ahy}-j\textit{uh}}{decided,}{decided, ``I'm going to be king!'' So\gobbletoSo}},
  replace={Adonijah}{Adonijah (ad-n-ahy-juh)},abbr=none,from*=ISV]{1Ki 1:5}\pdfmargincomment[author={\versetxt}]{\passagetxt}
\end{quote}
Note the typeset version and the annotation version are exactly as designated!
\end{document}
