User:Xerxesbacon

From DPWiki
Jump to navigation Jump to search

Useful REGEX

PPTools/Guiguts/Guiguts 2 Manual/Help Menu#Regex Quick Reference

Potential <abbr> tag

  • <abbr title=""></abbr>
  • [ |\n|>][A-Z]{1}[a-z]{2}\.

Find a string that begins with either a space, linebreak, or >; has 1 Uppercase letter; has 2 lowercase letters; and ends with 1 period.

The numbers can be changed to look for different types of abbreviations.

Use Ctrl+F's “Find All” with “Alpha/Type” selected in order to more easily see the different types.

Ideally, notice odd abbreviations when sequentially inspecting text and write them down.

  • \b(?:[A-Za-z]\.){2,}

Finds abbreviations of the form N.J., U.S.A., e.g., i.e. & L.O.V.E.M.U.F.F.I.N.

Change 2 to 1 to also find abbreviations like M. & p.

  • [A-Z][a-zA-Z]{0,}\.

Poetry/Metrical Lowercase after Line Break

  • \n[a-z]

Because poetry typically has Uppercase characters after each line break. (Find line break, find a lowercase character)

Small Caps Regex

  • [A-Z]\.?</sc

Check for All Small Caps, including A.M. and B.C. (Find an uppercase character, find a . either 0 or 1 times, find </sc)

Italics replacement (i vs em vs cite)

Search
<(/*)i>
Replace
<\1em>
Replace
<\1cite>

Find <i> or </i>, replace it with <em> or </em>; or, <cite> or </cite>.

Search
<i([\s\S]*?)</i>
Replace
<em\1</em>
Replace
<cite\1</cite>

Find <i, block of text, and </i> then replace both <i> and </i> with em/cite. <i instead of <i> in order to account for additional attributes, i.e. lang.

To avoid seeing common <i> words/phrase such as i.e., ibid., op. cit. and others, use this search:

Search
<i(?!>i\.e\.)(?!>ibid\.)(?!>op\. cit\.)([\s\S]*?)</i>

To add more words/phrases you don’t want to see, add more queries like (?!>et seq\.) to after “<i” and before “([\s\S]*?)</i>”.

Rewrap marker replacement

Search
/\*([\s\S]*?)\*/
Replace
/r\1r/
Replace
/p\1p/

Find a /* block (find /*, a non-greedy match of items between, and find */). Replaces both * with the desired marker. Change r & p to whatever desired.

Long Lines

  • Search: .{73,}?

Find a line with 73 or more characters.

Hyperlink page numbers

Search
page (\d+)
Replace
<a href="#Page_\1">page \1</a>

For transcriber’s notes based on how I write them. Use In Selection

Hyperlink footnotes

Search
footnote (\d+)
Replace
<a href="#Footnote_\1_\1">footnote \1</a>

Useful CSS

Side-by-side

TBD

Italic block with normal text for emphasis

/* === Italics block with normal emphasis === */

.italics {font-style: italic;}

.italics em { font-weight: normal; font-family: initial; font-style: normal; }

Blackletter/Fraktur

.blackletter {

    font-family: Fraktur, Textur, "Old English Text MT", Schwabacher, Blackletter,

    "Olde English", "Old English Five", "Engravers Old English BT", "Collins Old English",

    "New Old English", UnifrakturMaguntia, MathJax_Fraktur, sans-serif;

}

Hemstitch in Metrical Drama

Hemstitch: spreading a metrical line across the dialogue of multiple speakers, commonly indenting the dialogue so that a metrical line visually flows between the speakers.

Stage directions, speaker, and dialogue are on separate lines:

  • Use /$ and $/ for the dialogue in order to preserve leading spaces.

TXT File:

  • Surround the /$ $/ block with a /* */ block in order to add 2 spaces while preserving the leading spaces in the text.
  • 2-step search/replace with regex:
    Search
    /\$
    Replace
    /*\n/$
    Search
    \$/
    Replace
    $/\n*/
  • Rewrap the entire document
  • The /$ and $/ remain and need to be manually removed like so, noting 2 spaces:
    Search
    /\$\n
    Search
    \n \$/
    Replace
  • Cleanup Rewrap Markers like normal

HTML File:

In the HTML, the leading space is automatically preserved with <span style="margin-left: 8.0em;"> and <br>

This styling functions, but the text will go off the screen on phones and small screens. Use this CSS for a more elegant styling:

CSS:

.vanish {

text-decoration: line-through;

    visibility: hidden;

    }

This will render invisible the text used for alignment. The line-through is for redundency; if the e-reader does not vanish the alignment text, then it will be crossed-through like so: Hidden Text.

Follow these steps for a more efficient workflow:

  • Replace span styling with span vanish:
    Search
    style="margin-left:.*?;">(.*?)</span>
    Replace
    class="vanish"> </span>\1
  • Use this search to find the next and remaining lines:
    Search
    <span class="vanish"> </span>
  • Within the Span, copy and paste the previous line(s) of dialogue as needed for indentation, leaving a space at the end.

Language Codes

https://iso639-3.sil.org/code_tables/639/data

Search for language codes for lang attributes. Use the 2-character country code if available to prevent HTML errors.

https://www.unicode.org/charts/

Unicode charts to search by character number. Useful for when the computer does not display a character.

Other

For printer's errors and other inconsistencies in punctuation, spelling, etc.,

only the changes listed below were made.

On page in footnote “” was corrected to “” in “”.

<i>Italics</i>, <sc>Small Caps</sc>, and <sc>ALL SMALL CAPS</sc> were

formatted as so.