Wikisource:Tools and scripts/More editing buttons

InstructionsEdit

  • How to install:
  1. Go to common javascript file (Special:MyPage/common.js) they can be added to specific skins if preferred
  2. Edit the page and copy the code highlighted below, then save the page.
  3. Bypass your browser's cache by using the instruction on that page to reload.
  4. You should see the new edit buttons when you edit a page.
  • How to use:

Most buttons work with a selection,

  1. make a selection to highlight the text and click the button, or
  2. click the button to add the code at the insertion point, then paste or type to replace selection.

You can use the code to design new edit buttons, and add them in this page for other editors to use.

Hiding buttonsEdit

Existing buttons in the default toolbar can be less useful at Wikisource, or you may want to keep your toolbar to a smaller size. Contributors can hide buttons by editing their personal style sheet(Special:MyPage/common.css)

For example, the following code if inserted to your style sheet removes external links, headlines, signature, horizontal rule, media and maths tag, which are seldom needed for transcribing.

#mw-editbutton-extlink { display: none; }
#mw-editbutton-headline { display: none; }
#mw-editbutton-signature { display: none; }
#mw-editbutton-hr { display: none; }
#mw-editbutton-media { display: none; }
#mw-editbutton-math { display: none; }

List of extra buttonsEdit

CharactersEdit

DaggerEdit

Button link:  
What it does: Inserts a dagger (†)

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/b/b1/Button_dagger.png",
  "Dagger",
  '†',
  '',
  ""
})

EllipsisEdit

Button link:  
What it does: Inserts an ellipsis (…)

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/2/22/Button_ellipsis.png",
  "Ellipsis",
  '…',
  '',
  ""
})

M-dashEdit

Button link:  
What it does: Inserts an m-dash (—)

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/8/8b/Button_m-dash.png",
  "M-dash",
  '—',
  '',
  ""
})

N-dashEdit

Button link:  
What it does: Inserts an n-dash (—)

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/8/8b/Button_n-dash.png",
  "N-dash",
  '–',
  '',
  ""
})

PoundEdit

Button link:  
What it does: Inserts a pound (sterling) sign (£)

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/1/16/Ansi_0163.svg",
  "Pound",
  '£',
  '',
  ""
})

Text effectsEdit

StrikethroughEdit

Button link:  
What it does: Crosses out highlighted text. Converts "apple" to "<s>apple</s>", which looks like "apple".

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png",
  "Strikethrough",
  '<s>',
  '</s>',
  "Insert text here"
})

UnderlineEdit

Button link:  
What it does: Underlines highlighted text. Converts "apple" to "<u>apple</u>", which looks like "apple".

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/f/fd/Button_underline.png",
  "Underline",
  '<u>',
  '</u>',
  "Insert text here"
})

Small capsEdit

Button link:  
What it does: Wraps text in a {{sc}} template.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/4/4e/Button_romain.png",
  "Small caps",
  '{{sc|',
  '}}',
  ""
})


Larger textEdit

Button link:  
What it does: Converts highlighted text to a bigger font size. Converts "big" to "<big>big</big>", which looks like "big". Useful for headers and title pages of works.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/5/56/Button_big.png",
  "larger",
  '{{larger|',
  '}}',
  "Insert text here"
})


Smaller textEdit

Button link:  
What it does: Converts highlighted text to a smaller font size.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/5/58/Button_small.png",
  "Smaller",
  '{{smaller|',
  '}}',
  "Insert text here"
})


Font sizeEdit

Button link:  
What it does: This converts highlighted text to a specific font size which is customizable by changing the size number.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/7/79/Button_paragraphe_5.png",
  "Font size",
  '<font size="5">',
  '</font>',
  "Insert text here"
})


LinksEdit

Link to Wikipedia articleEdit

Button link:  
What it does: Creates a link from the highlighted text to the respective Wikipedia article entry. Converts "apple" to "[[w:apple|]]", which looks like "apple". Allows the reader to research biographies, events, descriptions and other information when reading our Wikisource texts. This can also be substituted to link to any other Wikimedia sister project by simply changing the piped link structure in the code.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/7/7f/Button_link_to_Wikipedia.png",
  "Wikipedia link",
  '[[w:',
  '|]]',
  "Insert link here"
})

Link to Wiktionary entryEdit

Button link:  
What it does: Creates a link from the highlighted text to the respective Wiktionary entry. Converts "apple" to "[[wikt:apple|]]", which looks like "apple". Allows the reader to research the meanings of terms on our Wikisource texts. Useful for unusual or ancient terms. This can also be substituted to link to any other Wikimedia sister project by simply changing the piped link structure in the code.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/0/0d/Button_wikification.png",
  "Wiktionary link",
  '[[wikt:',
  '|]]',
  "Insert link here"
})

Link to Author page on WikisourceEdit

Button link:  
What it does: Creates a link from the highlighted text to the respective author page. Converts "William Shakespeare" to "[[Author:William Shakespeare|]]", which looks like "William Shakespeare". Notice that the Author: prefix is not visible. This can be changed by removing the " | " from the link.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png",
  "Author link",
  '[[Author:',
  '|]]',
  "Insert link here"
})

Link to a subpageEdit

Button link:  
What it does: Creates a link from the highlighted text to a subpage from the current page. On the page The Double Dealer, converts the text "Act I" to "[[/Act I|]]", which looks like "/Act I". The actual Wikisource link would be The Double Dealer/Act I.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/0/0c/Button_Link_DifferentName.png",
  "Subpage",
  '[[/',
  '|]]',
  "Insert link here"
})

Relative linkEdit

Button link:  
What it does: Wraps the text in a relative link ([[../link location/]]).

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/2/23/Button_relative_link.png",
  "Relative link",
  '[[../',
  '/]]',
  ""
})

Page formattingEdit

PoemEdit

Button link:  
What it does: Converts highlighted text to poem format, allowing for better representation of the original work.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/d/d3/Button_definition_list.png",
  "Poem",
  '<poem>',
  '</poem>',
  "Insert text here"
})

ScoreEdit

Button link:  
What it does: Converts highlighted text to score format.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/b/b0/Button_note.png",
  "Score",
  '<score>',
  '</score>',
  "Insert score here"
})

Align text leftEdit

Button link:  
What it does: Aligns highlighted text to the left-hand side of the screen.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/e/ea/Button_align_left.png",
  "Align Left",
  '<div style="text-align:left">',
  '</div>',
  "Insert text here"
})

Align text centerEdit

Button link:  
What it does: Centers text across the screen.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png",
  "Centered text",
  '<center>',
  '</center>',
  "Insert text here"
})

Align text rightEdit

Button link:  
What it does: Aligns highlighted text to the right-hand side of the screen.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png",
  "Align Right",
  '<div style="text-align:right">',
  '</div>',
  "Insert text here"
})

IndentationEdit

Button link:  
What it does: Adds an indentation to the first sentence of a paragraph. To use, simply put the cursor at the beginning of the paragraph and press the button link.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/8/8e/Button_shifting.png",
  "Insert indent",
  '<div style="text-indent: 3em">',
  '',
  ""
})

Line breakEdit

Button link:  
What it does: Adds a link break <br />

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/4/48/Break-button-bg.png",
     "speedTip": "br ",
     "tagOpen": '<br />',
     "tagClose": '',
     "sampleText": ""
})

Hyphenated wordEdit

StartEdit

Button link:  
What it does: Wraps text Template:hyphenated word start; requires second word to be manually added after the pipe

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/0/0c/Hyphenated_word_start.svg",
     "speedTip": "hws ",
     "tagOpen": '{{hyphenated word start|',
     "tagClose": '|}}',
     "sampleText": "first-"
})
EndEdit

Button link:  
What it does: Wraps text with Template:hyphenated word end; requires second word to be manually added after the pipe

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/0/07/Hyphenated_word_end.svg",
     "speedTip": "hwe ",
     "tagOpen": '{{hyphenated word end|',
     "tagClose": '|}}',
     "sampleText": ""
})

Page elementsEdit

Add notes and referencesEdit

Button link:  
What it does: Converts highlighted text into a footnote. Converts "This is a footnote." to "<ref>This is a footnote.</ref>", which looks like "[1]". To show the footnote, place "<references/>" anywhere on the page (though usually at the end), which looks like this:

  1. This is a footnote.
mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
  "Reference",
  '<ref>',
  '</ref>',
  "Insert text here"
})

NoincludeEdit

Button link:  
What it does: Wraps the text in <noinclude> tags.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/d/d5/Button_noinclude.png",
  "Noinclude",
  '<noinclude>',
  '</noinclude>',
  "Insert text here"
})


Sections begin & endEdit

  • Used for marking section for sectional transclusion
BeginEdit

Button link:  
What it does: Creates a<section begin="LABEL" /> tag for use in text transclusion.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/0/06/Tag_green.png",
  "section begin",
  '<section begin="',
  '" />',
  ""
})
EndEdit

Button link:  
What it does: Creates a<section end="LABEL" /> tag for use in text transclusion.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/d/dd/Tag_red.png",
  "section begin",
  '<section end="',
  '" />',
  ""
})

Transcluded pagesEdit

Button link:  
What it does: Inserts a <pages/> tag. This is the "usual" method of transcluding pages.

mw.toolbar.addButton({
  "//upload.wikimedia.org/wikipedia/commons/7/74/Button_indented_transcluded_pages.png",
  "transcluded pages",
  '<pages index="',
  '" from= to= />',
  ""
})

Using {{#tag:}}Edit

Some formatting in Wikisource may require substitution inside tags. The following templates do such tasks

Block center and substituted <poem>Edit

Button link:  
What it does: Wraps <poem> around blocked text, which in turn is wrapped inside a centred block

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/4/4f/Button_verse.png",
     "speedTip": "spm",
     "tagOpen": '{{block center|{{subst:#tag:poem|',
     "tagClose": '}}}}',
     "sampleText": "insert text"
})

Sample output {{block center|{{subst:#tag:poem|insert text}}}}


substituted <ref>Edit

Note: this code should replace a standard <ref> tag to avoid confusion

Button link:  
What it does: Wraps around text, converts it to a reference

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
     "speedTip": "ref",
     "tagOpen": '{{subst:#tag:ref|',
     "tagClose": '}}',
     "sampleText": "insert text"
})

Sample output {{subst:#tag:ref|insert text}}

Note: Contributors who wish to then have further parameters liked name or follow should manually append tags like

  • {{subst:#tag:ref|insert text|name=ref1}}
  • {{subst:#tag:ref|insert text|follow=ref1}}

substitutionEdit

Button link:  
What it does: wraps text in {{subst:}}

mw.toolbar.addButton({
     "imageFile": "//upload.wikimedia.org/wikipedia/commons/2/20/Button_subst.png",
     "speedTip": "s: ",
     "tagOpen": '{{subst:',
     "tagClose": '}}',
     "sampleText": ""
})