Wikisource:Tools and scripts/More editing buttons

From Wikisource
Jump to: navigation, search

Instructions[edit]

  • 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 buttons[edit]

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 buttons[edit]

Characters[edit]

Dagger[edit]

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

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

Ellipsis[edit]

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

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

M-dash[edit]

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

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

N-dash[edit]

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

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

Pound[edit]

Button link: Ansi 0163.svg
What it does: Inserts a pound (sterling) sign (£)

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

Text effects[edit]

Strikethrough[edit]

Button link: Button strike.png
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"
})

Underline[edit]

Button link: Button underline.png
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 caps[edit]

Button link: Button romain.png
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 text[edit]

Button link: Button big.png
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 text[edit]

Button link: Button small.png
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 size[edit]

Button link: Button paragraphe 5.png
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"
})


Links[edit]

Link to Wikipedia article[edit]

Button link: Button link to Wikipedia.png
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 entry[edit]

Button link: Button wikification.png
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 Wikisource[edit]

Button link: Button biocitas.png
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 subpage[edit]

Button link: Button Link DifferentName.png
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 link[edit]

Button link: Button relative link.png
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 formatting[edit]

Poem[edit]

Button link: Button definition list.png
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"
})

Score[edit]

Button link: Button note.png
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 left[edit]

Button link: Button align left.png
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 center[edit]

Button link: Button center.png
What it does: Centers text accross the screen.

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

Align text right[edit]

Button link: Button align right.png
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"
})

Indentation[edit]

Button link: Button shifting.png
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 break[edit]

Button link: Break-button-bg.png
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 word[edit]

Start[edit]

Button link: Hyphenated word start.svg
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-"
})
End[edit]

Button link: Hyphenated word end.svg
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 elements[edit]

Add notes and references[edit]

Button link: Button reflink.png
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"
})

Noinclude[edit]

Button link: Button noinclude.png
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 & end[edit]

  • Used for marking section for sectional transclusion
Begin[edit]

Button link: Tag green.png
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="',
  '" />',
  ""
})
End[edit]

Button link: Tag red.png
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 pages[edit]

Button link: Button indented transcluded pages.png
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: Button verse.png
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: Button reflink.png
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}}

substitution[edit]

Button link: Button subst.png
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": ""
})