User:BobNearSeattle/Programs Source Code
Jump to navigation
Jump to search
Jedit Macros and other Jedit Stuff
jEdit References
- https://web.mit.edu/~jedit/arch/java/versions/4.3pre5/doc/users-guide/search-replace.html
- https://web.mit.edu/~jedit/arch/java/versions/4.3pre5/doc/users-guide/regexps.html
- https://web.mit.edu/~jedit/arch/java/versions/4.3pre5/doc/users-guide/writing-macros-part.html
- https://beanshell.org/manual/bshmanual.html
DP__bracket_notation_replace.bsh
// Replace bracket notations with their true characters. // Limitation: Not all characters are supported yet. // // diacritical characters // [=a] ā // [=i] ī // [=u] ū // [)U] Ŭ // [)a] ă // [)e] ĕ // [)i] ĭ // [)u] ŭ // // 2025-08-15 BobNearSeattle Original SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setWholeWord(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(false); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.setSearchString("[=a]"); SearchAndReplace.setReplaceString("ā"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[=i]"); SearchAndReplace.setReplaceString("ī"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[=u]"); SearchAndReplace.setReplaceString("ū"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[)U]"); SearchAndReplace.setReplaceString("Ŭ"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[)a]"); SearchAndReplace.setReplaceString("ă"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[)e]"); SearchAndReplace.setReplaceString("ĕ"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[)i]"); SearchAndReplace.setReplaceString("ĭ"); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[)u]"); SearchAndReplace.setReplaceString("ŭ"); SearchAndReplace.replaceAll(view);
DP_Capitalize.bsh
// For any Selected word... // Set the 1st letter to Uppercase and // Set the remainder to Lowercase. // // Useful when a SmallCaps mixed-case word comes through the P-rounds as Uppercase. // Example: // P3 "Dr. THWAITES" should be F1 "Dr. <sc>Thwaites</sc>" // // Modification log // 2025-08-06 BobNearSeattle Original SearchAndReplace.setSearchString("([A-Za-z0-9])(.*)"); SearchAndReplace.setReplaceString("(_1.toUpperCase() + _2.toLowerCase())"); SearchAndReplace.setBeanShellReplace(true); SearchAndReplace.setWholeWord(false); SearchAndReplace.setIgnoreCase(true); SearchAndReplace.setRegexp(true); SearchAndReplace.replace(view);
DP_Italic_Pence_Shilling.bsh
// Make all the UK Pound Sterling abbreviations "l.", "s." and "d." italics, when they are preceded by a number. Example: // the price is 4l. 3s. 2d. becomes // the price is 4<i>l.</i> 3<i>s.</i> 2<i>d.</i> // // Modification log // 2025-08-20 BobNearSeattle fix bug: 1st interpreted as shillings: 1<i>s</i>t. // 2025-08-19 BobNearSeattle support lowercase "l" as Pound Sterling // 2025-07-31 BobNearSeattle Original SearchAndReplace.setSearchString("([0-9])([dls]\\.)"); SearchAndReplace.setReplaceString("$1<i>$2</i>"); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setWholeWord(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view);
DP_SmallCap.bsh
// Surround selected text in SmallCap tags // If nothing selected, <sc></sc> inserted at caret position // // 2025-08-15 BobNearSeattle Document. Remove unused debug code. // 2025-01-29 BobNearSeattle Original tagStart = "<sc>"; tagEnd = "</sc>"; caret = textArea.getCaretPosition(); text = textArea.getSelectedText(); if(text == null) text = ""; // avoid errors later. sb = new StringBuffer(); // build the new string, like: <sc>MyText</sc> sb.append(tagStart); // <sc> sb.append(text); // MyText sb.append(tagEnd); // </sc> textArea.setSelectedText(sb.toString()); // replace selected text with buffer contents
Shell Scripts
table_preview_rough.sh
#!/bin/bash # This script converts a file downloaded from PGDP "Concatenated Text Files" # to its TEXT mode form. # # This is useful for verifying that table cells are properly aligned when the "Format Preview" function does not render. # # Example: # ./table_preview_rough.sh projectID677577e28a2cb_F1_saved.txt # # Input : PGDP "Concatenated Text Files" download # Output: <input_file_name>.out # # This script does not change the input file. # # Limitations: # Limited to Bold, Italic, and Small Caps tags. # # Requirements # bash scripting language, or equivalent. # # Details: # Perform the following replacements on the input: # 1) Convert "<b>" to "=" # 2) Convert "</b>" to "=" # 3) Convert "<i>" to "_" # 4) Convert "</i>" to "_" # 5) Convert "<sc>" to null # 6) Convert "</sc>" to null # # # # Modification log # 2025-07-17 BobNearSeattle Original # per https://www.pgdp.net/phpBB3/viewtopic.php?p=1370985#p1370985 # set -e IN_FILE="${1}" OT_FILE=$IN_FILE.out sed 's/<b>/=/g' ${IN_FILE} \ | sed 's/<\/b>/=/g' \ | sed 's/<i>/_/g' \ | sed 's/<\/i>/_/g' \ | sed 's/<sc>//g' \ | sed 's/<\/sc>//g' \ > ${OT_FILE} echo "INFO: Table preview with rough alignment written to ${OT_FILE}"