//TeXworksScript
//Title: Bible Verses No Headings 1Col Parbox &I &N
//Description: Puts the current selection of verses in Document No headings
//Author: Paul A Norman
//Version: 0.1
//Date: 2009-09-26
//Script-Type: standalone
//Context: TeXDocument
//Shortcut: Alt+I, Alt+N
// Insert bible Verse
eval(TW.app.getGlobal("helper_twPan")); // Comment if NOT Needed - This includes PhpJs ($P), twConst, msgBox, twPan ($tw), string.toTitleCase()
txt = TW.target.selection;
if ((txt == "") | (txt == null))
{
if (TW.app.clipboard != "")
{
txt = TW.app.clipboard;
}
else
{ txt = "verses here\\\\";
}
}
// '\u005C'+'\u005C'
txt = twPan.convertSpeechMarks(txt);
// txt = txt.replace(/\n/g, '\\\\ \n');
txt = twPan.cleanParaMarks(txt);
txt = txt.replace(/\n\n/g,"\n"); // get rid of double line breaks
var firstColon = txt.indexOf(":"); // see if we have a reference at beginning
if ((firstColon > 0) & (firstColon < 20)) // look within first 20 chars
{
var referencePrompt = txt.substr(0, firstColon +1); // extract reference stem
txt = txt.substr(firstColon +1); // remove reference stem
}
var bibleReference = TW.getText( null, "Verse Refereence", "Please enter Main Scripture reference\n\nUpto and including \":\"", referencePrompt);
if (bibleReference == undefined){bibleReference = ""; var dash = ""}else {var dash = "-";}
var processBlocks = txt.split('\n');
var keepLastReferenceNumerals = '';
var keepFirstReferenceNumerals = '';
// blockType = TW.getItem( null, "Block Type", "Choose Indent Block Type: ", ["indentBible","indentPlain"] , 0 , true ) ;
for (block in processBlocks)
{
var findBlank = processBlocks[block].split(" ");
if (! isNaN(findBlank[0]))
{// we have leading numerals
keepLastReferenceNumerals = findBlank[0];
if (block == 0)
{ keepFirstReferenceNumerals = findBlank[0];
bibleReference = "\\bibleNumeral{" + bibleReference + findBlank[0] ;
findBlank[0] = 'referenceReplace';
}
else
{ findBlank[0] = "\\bibleNumeral{"+findBlank[0]+"}";
}
processBlocks[block] = findBlank.join(" ");
}
processBlocks[block] = "\\indentBible*{" + processBlocks[block] + "}";
}
if (keepFirstReferenceNumerals == keepLastReferenceNumerals)
{bibleReference = bibleReference ;}
else
{bibleReference = bibleReference + dash + keepLastReferenceNumerals ;}
abbrvInfo = twPan.getBibleVersion().abbrv;
var extraSpaceB4Aprev = " \\ \\ \\ \\ ";
bibleReference = bibleReference + extraSpaceB4Aprev + abbrvInfo + "}\\ \\ ";
switch( TW.getItem(null,"Use Tag?","Loose Verses or \\indentAlone ?",["\\indentAlone{}","Loose"],0))
{
case "Loose":
TW.target.insertText(processBlocks.join('\n').replace('referenceReplace', bibleReference));
break;
case undefined:
break;
default:
TW.target.insertText("\n\\indentAlone{"
+ processBlocks.join('\n').replace('referenceReplace', bibleReference)
+"}");
}
//var bibleHeading = TW.getText( null, "Top Heading", "Please enter a heading \nor Scripture reference" );
//var TocEntry = TW.getText( null, "TOC Entry", "Please enter TOC entry\n or nothing", "" );
/* TocLevel = "";
if (TocEntry != "")
{
TocLevel = TW.getItem( null, "TOC Level", "1 - section,\n2 - subsection ,\n3 - subsubsection", ["1","2","3"] , 2 , true ) ;
}
else
{TocLevel = "";}
bibleRef = TW.getText( null, "Bible Reference", "Please enter Bible Reference\nBible Version ,,,", "NIV" );
TW.target.insertText("% {Heading-Reference}{verses}{toc entry or blank}{if toc then level 1,2,3}{Bible Ref ... Version}" +
"\n\\bibleVersePar{"+bibleHeading+"}{\n" + processBlocks.join('\n') + "\\\\ \n}{"+TocEntry+"}{"+TocLevel+"}{"+bibleRef+"}");
*/
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation