Module:User:Isomorphyc/links-draft/documentation

This module provides many useful utility functions for creating and processing wikilinks within Wiktionary.

full_link
Creates a full link, with annotations, in the style of. The parameters are: term (page name), alternative display, language object, script code, script face (see ), senseid, table of annotations (see  ). All parameters may be  except for the annotations, but an error will be shown if the term, alt and transliteration (in the annotations) are all missing.

The function will:
 * Try to determine the script, based on the characters found in the term or alt parameter, if the script was not given.
 * Call  on the term/alt forms, to remove diacritics in the page name, process any embedded wikilinks and create links to appendix pages when necessary.
 * Call  to add the appropriate language and script tags to the term.
 * Generate a transliteration, based on the alt or term parameters, if the script is not Latin and no transliteration was provided.
 * Add the annotations (transliteration, gender, gloss etc.) after the link.

format_link_annotations
Formats annotations that are displayed with a link. Annotations are the extra bits of information that are displayed following the linked term, and include things such as gender, transliteration, gloss and so on. The first parameter is the language object, the second is a table possessing some or all of the following keys:
 * Table containing a list of gender specifications in the style of Module:gender and number.
 * Table containing a list of gender specifications in the style of Module:gender and number.


 * Transliteration.
 * Transliteration.


 * Phonetic respelling.
 * Phonetic respelling.


 * Gloss that translates the term in the link, or gives some other descriptive information.
 * Gloss that translates the term in the link, or gives some other descriptive information.


 * Part of speech of the linked term. If the given parameter matches one of the templates in Category:Part of speech tags, then call that to show a part-of-speech tag. Otherwise, just show the given text as it is.
 * Part of speech of the linked term. If the given parameter matches one of the templates in Category:Part of speech tags, then call that to show a part-of-speech tag. Otherwise, just show the given text as it is.


 * Literal meaning of the term, if the usual meaning is figurative or idiomatic.
 * Literal meaning of the term, if the usual meaning is figurative or idiomatic.

Any of the above values can be omitted from the  parameter. If a completely empty table is given (with no annotations at all), then an empty string is returned.

language_link
Creates a basic link to the given term. It links to the language section (such as #English), but it does not add language and script wrappers, so any code that uses this function should call  to add such wrappers itself at some point.

It accepts the following parameters:


 * The text to turn into a link. This is generally the name of a page. The string can contain wikilinks already embedded in them, which can also have their own alternative display text. These are processed individually just like a single link would be. The  parameter is ignored in this case.
 * The text to turn into a link. This is generally the name of a page. The string can contain wikilinks already embedded in them, which can also have their own alternative display text. These are processed individually just like a single link would be. The  parameter is ignored in this case.


 * The alternative display for the link, if this is different from the linked page. If this is, the   parameter is used instead (much like regular wikilinks). If   contains wikilinks in it, this parameter is ignored and has no effect.
 * The alternative display for the link, if this is different from the linked page. If this is, the   parameter is used instead (much like regular wikilinks). If   contains wikilinks in it, this parameter is ignored and has no effect.


 * The language object for the term being linked.
 * The language object for the term being linked.


 * An additional sense ID to insert into the link. This is used in conjunction with . This is optional.
 * An additional sense ID to insert into the link. This is used in conjunction with . This is optional.


 * If, the function will also generate links to the current page. The default  will not generate a link but generate a bolded "self link" instead.
 * If, the function will also generate links to the current page. The default  will not generate a link but generate a bolded "self link" instead.

The following special options are processed for each link (both simple text and with embedded wikilinks):
 * The target page name will be processed to generate the correct entry name. This is done via Module:languages and is generally used to automatically strip dictionary-only diacritics that are not part of the normal written form of a language.
 * If the text starts with, then the term is considered a reconstructed term, and a link to the Appendix: namespace will be created. If the text contains embedded wikilinks, then   is automatically applied to each one individually, while preserving the displayed form of each link as it was given. This allows linking to phrases containing multiple reconstructed terms, while only showing the * once at the beginning.
 * If the text starts with, then the link is treated as "raw" and the above steps are skipped. This can be used in rare cases where the page name begins with   or if diacritics should not be stripped. For example:
 * links to Appendix:English/nix ( is interpreted as a reconstruction), but  links to *nix.
 * links to Franche-Comte ("é" is converted to "e" by ), but  links to Franche-Comté.
 * A link to the correct language section is added, along with the sense ID.

remove_links
Replaces all wikilinks with their linktitle as simple text. This function can be invoked either from a template or from another module.