This module provides many useful utility functions for creating and processing wikilinks within Wiktionary.
full_link(term, alt, lang, sc, face, id, annotations, allowSelfLink, dontLinkRecons)
Creates a full link, with annotations, in the style of {{l}}
. The parameters are: term (page name), alternative display, language object, script code, script face (see Module:script utilities#tag_text
), senseid, table of annotations (see format_link_annotations
). All parameters may be nil
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:
language_link
on the term/alt forms, to remove diacritics in the page name, process any embedded wikilinks and create links to appendix pages when necessary.Module:script utilities#tag_text
to add the appropriate language and script tags to the term.format_link_annotations(lang, info)
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:
genders
tr
pr
gloss
pos
lit
Any of the above values can be omitted from the info
parameter. If a completely empty table is given (with no annotations at all), then an empty string is returned.
language_link(text, alt, lang, id, allowSelfLink)
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 Module:script utilities#tag_text
to add such wrappers itself at some point.
It accepts the following parameters:
text
alt
parameter is ignored in this case.alt
nil
, the text
parameter is used instead (much like regular wikilinks). If text
contains wikilinks in it, this parameter is ignored and has no effect.lang
id
{{senseid}}
. This is optional.allowSelfLink
true
, the function will also generate links to the current page. The default (false
) 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):
*
, 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.:
, 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:
{{l|en|*nix}}
links to Appendix:English/nix (*
is interpreted as a reconstruction), but {{l|en|:*nix}}
links to *nix.{{l|sl|Franche-Comté}}
links to Franche-Comte ("é" is converted to "e" by makeEntryName
), but {{l|sl|:Franche-Comté}}
links to Franche-Comté.remove_links(text)
Replaces all ] with their linktitle as simple text. This function can be invoked either from a template or from another module.