User:Cosmas

From DPWiki
Jump to navigation Jump to search

Setting Up Directories For PPing a DP Project

Location for the PP files: create a folder for each project (geikie_geology; rogers_trees; weed_butterfly; etc.). In those folders, create subfolders with the following structure:

Folder Name        Contents
\author_title      - ex: weed_butterfly
   \orig_files
      \images      - unzipped DP images file directory
         \pages    - images for each page in the book
         \details  - all of the detailed images from the book
      \text        - unzipped copy of the DP files
   \pp             - the in progress TXT and HTML files (along with the GG and other generated files
      \images      - the processed images for the HTML version


Search and Replace Regexs

Search and Replace for Small Caps

 for TXT  S: <sc>([^<]+?)\n?</sc>     R: \U$1\E  ALL UPPERCASE
                                  or  R: $1      Just remove <sc></sc>

for HTML S: <sc>([^<]+?)\n?</sc> R: <div class="smcap">$1

Search and Replace for Curly Quotes

Convert double quotes to fancy double quotes

  S: ([^\w=])"([\w\s\d\-&,\.:;\?\n!\*'#\(\)\[\]<>/]+?)"([\s<:;\),&])  follow up with >[^<]*" for those in HTML code
  R: $1&ldquo;$2&rdquo;$3

Convert single quotes to fancy single quotes

  S: ([^\w=])'([\w\s\d\-&,\.:;\?\n!\*"#\(\)\[\]<>/]+?)'([\s<:;\),&])
  R: $1&lsquo;$2&rsquo;$3

Convert apostrophe to right single quote

  S: (\w)'(\w)       R: $1&rsquo;$2

Convert dittos to fancy double quotes

  S: (\s*)"(\s*)     R: $1&rdquo;$2  or   R: $1&rbquo;$2

S & R Word Problems

Search for unjoined hyphenated words

  S: ([a-z])\-\n([\S]+)[\s]   R: $1$2\n

Repeated words

  S: \b(\S+)\s\1\b

Single space at line start

  S: ^\s([a-z]+)

Check </i> problems

  S: </i>\S         (look for unwrapped periods and missing spaces
  S: \ [a-z]+</i>\. (missed period HTML)
  S: (\ [a-z]+)_\.  (missed period TXT)
  S: <\i>\n<i>      (italics unjoined HTML)
  S: _\n_           (italics unjoined TXT)

Other S & R Stuff

For generic fraction (example 43-11/32)

Find: (-*)([1-9]+)(/)([1-9]+)

Replace: <sup>$1\</sup>&frasl;<sub>$2</sub>

   sup       {font-size:0.8em; margin-top:-0.5em;}
   sub       {font-size:0.8em; margin-bottom:-0.5em;}

Ascii Equivalents

[OE]  Œ &#338;  OE ligature
[oe]  œ &#339;  oe ligature
[AE]  Æ &#198;  AE ligature
[ae]  æ &#230;  ae ligature
·       &#183;  middle dot
%       &#37;   Percent sign
…       &#8230; Ellipsis
⋯      &#8230; Horizontal Ellipsis
§       &#167;  Section symbol
°       &#176;  Degrees symbol
±       &#177;  Plus/minus sign
=>      &#8594; rightwards arrow
[F]   = &#9792;
[M]   = &#9792;

Search for Diacritical Markup

 S: \[([='`)]*)([a-z]+)([='`)]*)\]

Diacritical Equivalents (&#nnn; - capitls are -32 except macron and breve -1)

 [=a] = 257   [=e] = 275  [=i] = 299  [=o] = 333  [=u] = 363
 [)a] = 259   [)e] = 277  [)i] = 301  [)o] = 335  [)u] = 365
 [`a] = 224   [`e] = 232  [`i] = 236  [`o] = 242  [`u] = 249
 ['a] = 225   ['e] = 233  ['i] = 237  ['o] = 243  ['u] = 250
 [^a] = 226   [^e] = 234  [^i] = 238  [^o] = 244  [^u] = 251
 [~a] = 227   [~e] = 7869 [~i] = 297  [~o] = 245  [~u] = 361
 [:a] = 228   [:e] = 235  [:i] = 239  [:o] = 246  [:u] = 252
 [.a] = 551   [.e] = 279              [.o] = 559  [.u] = 559
 [°a] = 229   [°a] = 229  [°a] = 229  [°a] = 229  [°a] = 229


Decrement a series of numbers ([121] or [122] to [110] or [111])

  S: \[(\d+)\]   R: [\C$1-11\E]

Search for numbers between 100 an 999

  S: (?<![\d>])(1[0-9]\d|2\d\d)(?![\d<])


Guiguts - Enhancement - Paste with New Line Added (Control+Shift+v)

To add the functionality (using Control + Shift + v) to Paste a selection and adding a new line after the copied text at the insertion point, the instructions for versions 1.3.x and 1.0.2x follow.

Paste + New Line Guiguts 1.3.x

Copy the lines of code which have a comment "# TC - Paste = New Line" and insert between the other code displayed in the two indicated perl files. Then in Guiguts Shift-Control-v will paste the text and add a blank line below the inserted text.

KeyBindings.pm - Insert the following lines commented with ## TC

   keybind( '<Control-v>',     sub { ::paste(); } );
   keybind( '<Shift-Control-v>', sub { ::paste_newline(); } );       # TC - Paste + New Line
   keybind( '<Control-Alt-v>', sub { ::paste('alternative'); } );    # to avoid Perl/Tk paste bug
   # After the Tk::Entry for Paste add the following
   # To allow user to paste selected text and add a new line after it       # TC - Paste + New Line
   $textwindow->MainWindow->bind( 'Tk::Entry',                              # TC - Paste + New Line
       '<Shift-Control-v>' => sub { ::paste_newline(); }, );                # TC - Paste + New Line
   #

MenuStructure.pm - Add the Paste + New Line block following the Paste block

       [
           'command', 'Paste',
           -accelerator => 'Ctrl+v',
           -command     => sub { ::paste(); },
       ],
       [                                                   # TC - Paste + New Line
           'command', 'Paste + New Line',                  # TC - Paste + New Line
           -accelerator => 'Shift+Ctrl+v',                 # TC - Paste + New Line
           -command     => sub { ::paste_newline(); },     # TC - Paste + New Line
       ],                                                  # TC - Paste + New Line

Utilities.pm

In the BEGIN section insert &paste_newline

    @EXPORT = qw(... &paste &paste_newline &entrypaste ...

After the sub paste block add the following

    ## Paste with New Line added - Cosmas
    sub paste_newline {
       my $textwindow = $::textwindow;
        $textwindow->clipboardPaste;
       $textwindow->insert('insert', "\n");
    }
   
    #

Paste + New Line Guiguts 1.0.2x

In Utilities.pm, search for "sub paste {", add the following block below that subroutine.

       ## Paste with New Line added - Cosmas
       sub paste_newline {
           my $textwindow = $::textwindow;
           if ( $textwindow->OverstrikeMode ) {
            my @ranges = $textwindow->tagRanges('sel');
                if (@ranges) {
                  my $end   = pop @ranges;
                  my $start = pop @ranges;
                  $textwindow->delete( $start, $end );
                  }
                $textwindow->clipboardPaste;
                $textwindow->insert( 'insert', "\n");
              } else {
                $textwindow->clipboardPaste;
              }
        }


In MenuStructure.pm, search for the "Paste" command block and add the following block below that. (Note: GG V. 1.0.2x has the Paste command multiple times in it!!)

        [
           'command', 'Paste w/ newline',  # Added by Cosmas
           -command     => sub { ::paste_newline() },
           -accelerator => 'Ctrl+Shift+v
       ],


Guiguts - Enhancement - Wrap With /X X/

To add the ability to 'wrap' blocks with /X X/ (or by proper substitution /f f/ or /L L/ when run), you must modify the following Guiguts files:


MenuStructure.pm

1) Add the following code ABOVE the block containing 'command', 'Su~rround Selection With...',:

       [
           'command', 'Surround Selection With /X X/',
           -accelerator => ,
           -command     => \&::surroundx
       ],


SelectionMenu.pm

2) Under "BEGIN {" section, add "&surroundx" to the @EXPORT list.

3) Add the following code ABOVE the "sub surround {" block:

       #
       # -- TC Added so user can wrap selected text with /X X/
       #
       sub surroundx {
           my ( $textwindow, $top ) = ( $::textwindow, $::top );
           if ( defined( $::lglobal{surpop} ) ) {
               $::lglobal{surpop}->deiconify;
               $::lglobal{surpop}->raise;
               $::lglobal{surpop}->focus;
           } else {
               $::lglobal{surpop} = $top->Toplevel;
               $::lglobal{surpop}->title('Surround With');
               my $f = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
               $f->Label( -text => "Surround the selection with:\n\\n will be replaced with a newline.", )
                 ->pack(
                   -side   => 'top',
                   -pady   => 5,
                   -padx   => 2,
                   -anchor => 'n'
                 );
               my $f1      = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
               my $surstrt = $f1->Entry(
                   -textvariable => \$::lglobal{surstrt},
                   -width        => 8,
                   -background   => $::bkgcolor,
                   -relief       => 'sunken',
               )->pack(
                   -side   => 'left',
                   -pady   => 5,
                   -padx   => 2,
                   -anchor => 'n'
               );
               my $surend = $f1->Entry(
                   -textvariable => \$::lglobal{surend},
                   -width        => 8,
                   -background   => $::bkgcolor,
                   -relief       => 'sunken',
               )->pack(
                   -side   => 'left',
                   -pady   => 5,
                   -padx   => 2,
                   -anchor => 'n'
               );
               my $f2    = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
               my $gobut = $f2->Button(
                   -activebackground => $::activecolor,
                   -command          => sub {
                       ::surroundit( $::lglobal{surstrt}, $::lglobal{surend}, $textwindow );
                   },
                   -text  => 'Surround',
                   -width => 35            # TC - Increased it so user can grab title bar!
               )->pack(
                   -side   => 'top',
                   -pady   => 5,
                   -padx   => 2,
                   -anchor => 'n'
               );
               ::initialize_popup_with_deletebinding('surpop');
               $surstrt->insert( 'end', '/X\n' ) unless ( $surstrt->get );  # -- /X = linefeed
               $surend->insert( 'end', '\nX/' )  unless ( $surend->get );   # -- line feed + X/
           }
       }


Under Development -- Guiguts Enhancement -- Wrap with /X, /$, /L or /f

The goal is to produce a popup box with radio buttons which will allow the user to 'wrap' the selected text with /X X/, /$ $/, /L L/, or /f f/. The popup would show the appropriate start and end code. The user WOULD be able to modify the code or alternately just have the four radio buttone, show which was selected "The selection will be wrapped with /X X/." (or whichever was selected!)

   #
   # -- TC Added so user can wrap selected text with /X X/
   #
   sub surroundx {
       my ( $textwindow, $top ) = ( $::textwindow, $::top );
       if ( defined( $::lglobal{surpop} ) ) {
           $::lglobal{surpop}->deiconify;
           $::lglobal{surpop}->raise;
           $::lglobal{surpop}->focus;
       } else {
           $::lglobal{surpop} = $top->Toplevel;
           $::lglobal{surpop}->title('Surround With');
           my $f = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
           my $frame1 = $::lglobal{surpop}->Frame->pack;
           $f->Label( -text => "Surround the selected block with ...", )
             ->pack(
               -side   => 'top',
               -pady   => 5,
               -padx   => 2,
               -anchor => 'n'
             );
        ##
        ## Radio Button Choices
           my $xsel1 = $frame1->Radiobutton(                  # TC - Added /X X/ Surround
               -variable    => \$::lglobal{surrnd},
               -selectcolor => $::lglobal{checkcolor},
               -value       => 'X',
               -text        => '/X X/',
           )->grid( -row => 1, -column => 1, -pady => 5 );
           my $xsel2 = $frame1->Radiobutton(                  # TC - Added /$ $/ Surround
               -variable    => \$::lglobal{surrnd},
               -selectcolor => $::lglobal{checkcolor},
               -value       => '$',
               -text        => '/$ $/',
           )->grid( -row => 1, -column => 2, -pady => 5 );
           my $xsel3 = $frame1->Radiobutton(                  # TC - Added /L L/ Surround
               -variable    => \$::lglobal{surrnd},
               -selectcolor => $::lglobal{checkcolor},
               -value       => 'L',
               -text        => '/L L/',
           )->grid( -row => 1, -column => 3, -pady => 5 );
           my $xsel4 = $frame1->Radiobutton(                  # TC - Added /f f/ Surround
               -variable    => \$::lglobal{surrnd},
               -selectcolor => $::lglobal{checkcolor},
               -value       => 'f',
               -text        => '/f f/',
           )->grid( -row => 1, -column => 4, -pady => 5 );
        # End Surround Choices
        #
           my $f1      = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
        ##
   	    my $surst = join("/", $f1, "\n");   #  Use the value from the Radiobutton Choice
   	    my $surnd = join("\n", $f1, "/n");  #  Use the value from the Radiobutton Choice
        ##
        ## Fill the left and right boxes with the split values!
           my $surstrt = $f1->Entry(
               -textvariable => \$::lglobal{surstt},
               -width        => 8,
               -background   => $::bkgcolor,
               -relief       => 'sunken',
           )->pack(
               -side   => 'left',
               -pady   => 5,
               -padx   => 2,
               -anchor => 'n'
           );
           my $surend = $f1->Entry(
               -textvariable => \$::lglobal{surnd},
               -width        => 8,
               -background   => $::bkgcolor,
               -relief       => 'sunken',
           )->pack(
               -side   => 'left',
               -pady   => 5,
               -padx   => 2,
               -anchor => 'n'
           );
           my $f2    = $::lglobal{surpop}->Frame->pack( -side => 'top', -anchor => 'n' );
           my $gobut = $f2->Button(
               -activebackground => $::activecolor,
               -command          => sub {
                   ::surroundit( $::lglobal{surstrt}, $::lglobal{surend}, $textwindow );
               },
               -text  => 'Surround',
               -width => 35            # TC - Increased it so user can grab title bar!
           )->pack(
               -side   => 'top',
               -pady   => 5,
               -padx   => 2,
               -anchor => 'n'
           );
           ::initialize_popup_with_deletebinding('surpop');
          #
          ## I think this change will do what you want. I haven't tested it, though. --ortonmc
           #$surstrt->insert( 'end', '/X\n' ) unless ( $surstrt->get );  # -- need values from Radiobutton Choice
           #$surend->insert( 'end', '\nX/' )  unless ( $surend->get );   # -- need values from Radiobutton Choice
           $surstrt->insert( 'end', '/${surrnd}\n' ) unless ( $surstrt->get );
           $surend->insert( 'end', '\n${surrnd}/' )  unless ( $surend->get );
       }
   }