From 538b480d12231fb32565949a755f342518d7f0c1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 28 Jan 2023 08:32:33 -0500 Subject: Added superscript capability for verse numbers --- src/bible.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bible.cc b/src/bible.cc index c2d93b1..ac9b189 100644 --- a/src/bible.cc +++ b/src/bible.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include "utf8.h" using namespace std; @@ -21,6 +22,7 @@ void usage() { printf(" --list-books list books available in the current module\n"); printf(" --list-chapters list chapters available in book in the current module\n"); printf(" -o, --omit-verse-numbers when printing verse text, skip printing verse and chapter numbers\n"); + printf(" -s, --superscript when printing verse text, print verse and chapter numbers as superscript\n"); printf(" --list-installable= list bible versions available for download and install. Default lists for all languages.\n"); printf(" --install-network install module from the network where is LANG:NAME as provided by --list-installable\n"); printf(" --install-zip install module from a zip file\n"); @@ -176,6 +178,7 @@ int main(int argc, char* argv[]) { {"list-books", no_argument, 0, 0}, {"list-chapters", required_argument, 0, 0}, {"omit-verse-numbers", no_argument, 0, 'o'}, + {"superscript", no_argument, 0, 's'}, {"list-installable", optional_argument, 0, 0}, {"install-network", required_argument, 0, 0}, {"install-zip", required_argument, 0, 0}, @@ -184,10 +187,11 @@ int main(int argc, char* argv[]) { int opt, option_index; string modname; bool omitVerseNums = false; + bool superscript = false; bool doListBooks = false; string listChaptersBook; string option; - while ((opt = getopt_long(argc, argv, "hm:o", long_options, &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, "hm:os", long_options, &option_index)) != -1) { switch(opt) { case 'h': usage(); @@ -198,6 +202,9 @@ int main(int argc, char* argv[]) { case 'o': omitVerseNums = true; break; + case 's': + superscript = true; + break; case 0: option = string(long_options[option_index].name); if(option == "list-modules") { @@ -303,7 +310,15 @@ int main(int argc, char* argv[]) { if(omitVerseNums && tex.verse != verse) { out << " "; } else if(!omitVerseNums && tex.verse != verse) { - out << " (" << tex.verse << ") "; + if(superscript) { + out << " "; + map d2s = {{'0', "⁰"}, {'1', "¹"}, {'2', "²"}, {'3', "³"}, {'4', "⁴"}, {'5', "⁵"}, {'6', "⁶"}, {'7', "⁷"}, {'8', "⁸"}, {'9', "⁹"}}; + for(auto &d : to_string(tex.verse)) { + out << d2s[d]; + } + } else { + out << " (" << tex.verse << ") "; + } } chapter = tex.chapter; verse = tex.verse; -- cgit v1.2.3