Wikisource:TemplateScript

From Wikisource
(Redirected from Wikisource:TS)
Jump to navigation Jump to search
TemplateScript

TemplateScript adds one-click actions to the sidebar when editing pages. For example, you can automatically fix common OCR errors by clicking a "Clean up OCR" link. You can import libraries of useful actions maintained by the community below, or write your own scripts.

Proofreading[edit]

Usage[edit]

This library is useful when proofreading pages in the Page: namespace. To enable it:

  1. Paste this code into your common.js or global.js:
    /**
     * Add several tools useful when proofreading pages in the Page: namespace.
     * @see https://en.wikisource.org/wiki/Wikisource:TemplateScript
     */
    mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:TemplateScript/proofreading.js&action=raw&ctype=text/javascript');
    
  2. (optional) Go to Special:TemplateScript to disable scripts you don't use.

Scripts[edit]

This library adds the following links to your sidebar:

  • Add header adds the {{running header}} template to the header (and will use the special header for the current work if it's known). See here for instructions on how to use this script once installed Wikisource:TemplateScript/RunningHeader
  • Add footer adds a reference list to the footer if the page contains references.
  • Clean up OCR makes many automatic corrections and cleanup when proofreading a page after OCR:
    • clean up format:
    • clean up whitespace:
      • remove trailing spaces;
      • remove spacing around em dashes or punctuation marks;
      • replace consecutive spaces with one space;
    • clean up newlines:
      • join words that are hyphenated across a line break;
      • move lines beginning with a quote character to a new paragraph;
      • move punctuation on a new line back onto previous line;
      • remove single line breaks (no effect in wikitext and usually an unneeded word wrap);
      • remove forced hard breaks at the end of paragraphs;
    • convert characters:
      • convert double hyphens to em dashes;
      • convert common HTML entity codes (like —) to characters (like );
      • convert curved quotes (“”‘’`) to straight quotes ("');
      • convert diacritic templates (like {{ae}}) to characters (like æ);
    • correct common OCR errors:
      • remove numerals at the end of the page text (nearly always page numbers in the footer);
      • convert '1' parsed as 'i' (e.g., i919);
      • correct 'th' parsed as 'tli' (e.g., tliethe);
      • correct 'll' parsed as 'U' (e.g., aUall);
      • correct 'oul' parsed as 'oid' (e.g., woiddwould);
      • correct missing apostrophes (e.g., he she's).
    You should always carefully review the changes after applying this script, since some changes may not always be correct.
  • Make reference automatically gathers references. As you work your way through the page, when you encounter a reference, just mark it with <ref></ref> tags and continue. Once you've got to the end of the page and proofed the references, simply highlight each reference in turn, and use this function to move it to its proper position.
  • Convert to small caps converts the selected text to Small Caps using the {{small-caps}} template.
  • Convert to uppercase converts the selected text to UPPERCASE.

Typography[edit]

Usage[edit]

This library adds scripts for adding diacritics (like àéîö) and changing letter case. To enable it:

  1. Paste this code into your common.js or global.js:
    /**
     * Add several tools for editing typography like diacritics and letter case.
     * @see https://en.wikisource.org/wiki/Wikisource:TemplateScript
     */
    mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:TemplateScript/typography.js&action=raw&ctype=text/javascript');
    
  2. (optional) Go to Special:TemplateScript to disable scripts you don't use.

Scripts[edit]

This library adds the following links to your sidebar:

  • Make title link converts the selected text into a link with title case (like "THE MAN FROM SNOWY RIVER" → "[[The Man from Snowy River|THE MAN FROM SNOWY RIVER]]").
  • Make author link converts the selected text into an author link with appropriate capitalisation (like "John Smith" → "[[Author:John Smith|John Smith]]" or "SMITH, JOHN" → "[[Author:John Smith|SMITH, JOHN]]").
  • Convert to Small Caps converts the selected text to Small Caps. This adds the {{sc|...}} template, and converts the text to title case if it's in UPPERCASE.
  • Convert to UPPER converts the selected text to UPPERCASE.
  • Add diaeresis (ä) adds a diaeresis mark to the selected character (like "a" → "ä").
  • Add acute (á) adds an acute accent to the selected character (like "a" → "á").
  • Add grave (à) adds a grave accent to the selected character (like "a" → "à").
  • Add circumflex (â) adds a circumflex to the selected character (like "a" → "â").
  • Add macron (ā) adds a macron to the selected character (like "a" → "ā").
  • Add ligature or hook converts the selected text to a ligature (like "ae" → "æ") or adds a hook (like "c" → "ç").