Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Search
Editing
Module:Glossary
From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
Namespaces
Module
Discussion
More
More
Page actions
Read
Edit source
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ This module provides helper functions for Template:Glossary_entry. Created by Pyrrhus for me-pedia.org November 2019 ]] local gloss = {} --[[ tooltipCleanse: (adapted from Module:String.replace) This function allows one to cleanse pre-processed, pre-HTML wikitext for use as a tooltip text. It removes: 1) <ref> strip markers of the form '"`UNIQ--ref-00000001-QINU`"' 2) all other strip markers, except for <nowiki> strip markers 3) tracking categories of the form 'Category:tracking_category', with brackets 4) superscripts, such as citation needed, of the form <sup> ... </sup> It also protects double quotation marks so that the tooltip can be specified in a <span title="mytooltip"></span> construct. What is "pre-processed, pre-HTML wikitext", you ask? I'm not sure. It might be "parsed, but not HTML rendered". Again, I'm really not sure. Usage: {{#invoke:Glossary|tooltipCleanse|source=my_preprocessed_preHTML_wikitext}} ]] function gloss.tooltipCleanse( frame ) local my_args = gloss._getParameters( frame.args, {'source'} ) local source_str = my_args['source'] or '' local trackPattern = '%[%[[Cc]ategory:[^%]]*%]%]' local supPattern = "<sup.+</sup>" if source_str == '' then return source_str end -- remove all strip markers, including <ref> -- (except <nowiki> strip markers) source_str = mw.text.unstrip( source_str ) -- remove superscripts such as citation needed source_str = mw.ustring.gsub( source_str, supPattern, '' ) -- remove tracking categories source_str = mw.ustring.gsub( source_str, trackPattern, '' ) -- protect double quotes source_str = mw.ustring.gsub( source_str, "\"", '"' ) return source_str end --[[ hostname: This function returns the hostname for a URL ]] function gloss.hostname( frame ) local new_args = gloss._getParameters( frame.args, {'url'} ) local myUrl = new_args['url'] or '' local myUrlObject = mw.uri.new( myUrl ) return myUrlObject["host"] end --[[ _getParameters: (copied from Module:String) Helper function that populates the argument list given that user may need to use a mix of named and unnamed parameters. This is relevant because named parameters are not identical to unnamed parameters due to string trimming, and when dealing with strings we sometimes want to either preserve or remove that whitespace depending on the application. ]] function gloss._getParameters( frame_args, arg_list ) local new_args = {} local index = 1 local value for _, arg in ipairs( arg_list ) do value = frame_args[arg] if value == nil then value = frame_args[index] index = index + 1 end new_args[arg] = value end return new_args end return gloss
Summary:
Please make sure your edits are consistent with
MEpedia's guidelines
.
By saving changes, you agree to the
Terms of use
, and you irrevocably agree to release your contribution under the
CC BY-SA 3.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Glossary/doc
(
edit
)
Navigation
Navigation
Skip to content
Main page
Browse
Become an editor
Random page
Popular pages
Abbreviations
Glossary
About MEpedia
Links for editors
Contents
Guidelines
Recent changes
Pages in need
Search
Help
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs