User:SF2001/DP-book-review-1909
Jump to navigation
Jump to search
This autohotkey macro was used to greatly accelerate formatting of "Book review digest, v. 5, 1909" projectID5844552f5801c [1]. It is likely to be a very useful base for accelerating formatting of other Book Review Digests. It will probably not be able to be used directly as the format of the books changes from year to year and PM instructions are likely to be different.
Without any "premarking" the macro does a good job of
- Bolding the names of reviewing publications
- Putting no wrap mark up around reviewing publications
- Putting no wrap mark up around call numbers if they are strictly numeric.
- If the proofer has put the smaller numerical note in the correct place
- Bolding author names
- Putting block quotes around the book information
- Putting the extra line before book information to indicate a new section
You can "premark" the text with a "`" which is the upper left most key on a US keyboard.
- Put the ` on a line by itself and the macro will insert a <tb> with appropriate blank lines
- Put the ` after the period after an author's name when there is no small numerical note
Where it does badly:
- If the author's name wraps to the next line the bolding will not be done and the opening "/#" will not be placed
- If the call number has an alphabetic character. It will just be left alone.
- If the call number has been split into a separate paragraph an extra blank line will be before it looking like a new section.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance Force ;This AutoHotKey script is to help Distributed Proofreader Formatters ; Specifically the "Book review digest" listings ; ;>>>> YOU STILL MUST PROOFREAD AFTER.<<<<<< ;The script makes mistakes and you're smarter than a script ;========= Do the work. ` is selected as it is already used a lot for marking up =========================== ~LButton & `:: Clipboard := ; clear out the clipboard so the wait two statements below will work SendInput, {Ctrl down}ac{Ctrl up} ClipWait ; ;There was a bug where the publication at very end of doc was left a mess ; precondition by adding an extra blank line at the end ; No need to remove later as DP will strip it out ;There was a bug where the paragraph with the author's name at the top of the file would leave a mess ; precondition by adding an extra blank line at the beginning ; It will be removed later or you wind up with an illegal three blank lines in a row at the top. ;Add a line break a the beginning and at the end. It helps formatting if the paragraph ends at the end of a page Clipboard := "`r`n" . Clipboard . "`r`n`r`n" ;=========== CALL NUMBER ========= ;Look for call number of format ; n-nnnnnn ; Second set of nnnnn may be three to five characters long ; Some rare call numbers have alphabetic characters and it won't work for them; ;Markup the call number with nowrap and add appropriate blank lines above and below. ;put call number on a line by itself in case it is not. Clipboard := RegExReplace(Clipboard, " (\d-\d{3,5}\.)(\R)" , "$2$1$2") ;Wrap the call number in nowrap with extra lines Clipboard := RegExReplace(Clipboard, "\R(\d-\d{3,5}\.)(\R)" , "$2$2/*$2$1$2*/$2") ;================ THOUGHT BREAK =========== ;Change a lonely "`" into a thought break ;Foofer must put the accent mark on the line where a thought break belongs Clipboard := RegExReplace(Clipboard, "(\R)``\R" , "$1$1<tb>$1$1") ;========= AUTHOR BOLD ============ ;For the paragraph where the author's name is: ; Bold author name ; Wrap paragraph with "#" block-quote tag ; Add an extra blank line above to indicate this is a section ;Typically requires Foofer to put an accent mark just after the string that should be bolded. ; ;Sometimes no need to manually mark. Some entries are followed by a number in square brackets] Clipboard := RegExReplace(Clipboard, "(\[\d{1,2}\])" , "``$1") ;In case someone added a "`" before the bracketed number, compensate by reducing back to a single: don't punish them Clipboard := StrReplace(Clipboard, "````", "``") ;Put blockquote wrap at beginning of paragraph, add an extra blank line before, and leave flag behind for next step. Clipboard := RegExReplace(Clipboard, "(\R)\R(.+?)``" , "$1$1$1/#$1<b>$2</b>``") ;wrap the end of the paragraph with closing blockquote. and remove flag Clipboard := RegExReplace(Clipboard, "s)``(.+?)(\R)\R" , "$1$2#/$2$2") ;============ PUBLICATION NAME ==================== ;There is a list of publications where reviews are taken from ; Mark the pub names bold ; Mark the paragraph with the pub name with "/**/" nowrap tags ; When multiple nowrap paragraphs are in a row, delete the redundant nowrap tags ; ;This is a list of the publications compiled from the document after many pages of reviewing. ; It is almost certainly incomplete and will need to be added to as new pubs are encountered ; Just add a new one to the end of the quoted string separated by a vertical bar | publications := "N. Y. Times.|Lit. D.|Sat. R.|R. of Rs.|Arena.|Dial.|Nation.|Outlook.|Int. Studio.|Nation.|Ath.|Cath. World.|Nature.|Spec.|Engin. D.|Engin. N.|Engin. Rec.|Ann. Am. Acad.|Educ. R.|Ind.|Bib. World.|Bookm.|A. L. A. Bkl.|Survey.|Yale R.|Science, n.s.|Forum.|Am. Hist. R.|J. Pol. Econ.|Econ. Bull.|Eng. Hist. R.|Pol. Sci. Q.|No. Am.|Putnam's.|Am. J. Soc.|Elec. World.|Atlan.|J. Philos.|Philos. R.|Psychol. Bull.|Phys. R.|Int. J. Ethics.|Am. J. Theol.|El. School T.|School R.|Ecclesiastical R.|Lond. Times.|Class. J.|London Times.|Hibbert J.|Class. Philol.|Mod. Philol.|Bot. Gaz.|Char.|J. Geol." ;Reformat the publication name so AHK can use them. publications := StrReplace(publications, "." , "\.") ; ;Mark the pub name as bold and leave a flag for the next step Clipboard := RegExReplace(Clipboard, "(" . publications . ") ", "<nowrap><b>$1</b> ") ; ;Add nowrap flags at beginning of paragraph and leave flag for next step ; ".*?" required as sometimes the pub name is on the left margina and some times also has plus and/or minus signs Clipboard := RegExReplace(Clipboard, "(\R)(.*?)<nowrap>", "$1/*$1$2<nowrap>") ;Add nowrap flag to end of paragraphs and remove flag Clipboard := RegExReplace(Clipboard, "s)<nowrap>(.+?)(\R)\R" , "$1$2*/$2$2") ;Combine two nowraps in a row into a single no wrap Clipboard := RegExReplace(Clipboard, "\*\/(\R)\R\/\*", " ") ;clean up indenting of + and minus and pub name ;Look for a publication that is directly after a newline Clipboard := RegExReplace(Clipboard, "(\R)<b>(" . publications . ")" , "$1 <b>$2" ) ;Look for a publication that has a single +/- before it Clipboard := RegExReplace(Clipboard, "(\R)([+|-]) <b>(" . publications . ")" , "$1 $2 <b>$3" ) ;Look for a publication that has a double +/- before it Clipboard := RegExReplace(Clipboard, "(\R[+|-] [+|-]) <b>(" . publications . ")" , "$1 <b>$2" ) ;================ CLEAN UP ======================= ;delete the extra new line at the very top. must be a very simple way to do it Clipboard := RegExReplace(Clipboard, "s)\R(.+)" , "$1") ; Type the modified input string back in, ; then move cursor up to the top so you can start proofreading with fewer keystrokes. ; because you are proofreading! ;SendInput, {Ctrl down}v{Ctrl up} SendInput, {Ctrl down}av{Ctrl up} SendInput, {Home}{Up} ; Go to top of page SendInput, ^{Home} return ; This ends the hotkey. The code below this point will not get triggered.