Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Search
Editing
Module talk:Citation/CS1
From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
Namespaces
Module
Discussion
More
More
Page actions
Read
Edit source
New topic
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!
== Code to try out -- [[User:Notjusttired|notjusttired]] == Collected Lua code snippets for possibly creating automatic author links * grab first word of name, removing . or comma, as taken from [[Module:Citation/CS1]] check for spaces in url <pre > local function normalize_name(the_str) --replace curly apostrophe or wrong hyphen symbol with correct ones for links result = false if not (the_str:match("(%A+)") == nil) then if not (the_str == "") then --there's some non-letters the_str = the_str:gsub("β","'") the_str = the_str:gsub("%β","-") the_str = the_str:gsub("%β","-") the_str = the_str:gsub("%β","-") the_str = the_str:gsub("%β","-") result = the_str end end return result; end </pre > <pre > local function first_name(the_str) -- trim comma, full stop, semicolon --allowed punctuation: dash/hyphen (em dash) and straight apostrophe result = false --find first word according to space if not (the_str == nil) then the_str = the_str:match("^(%S+)") end --strip trailing punctuation the_str = the_str:gsub("%.","") the_str = the_str:gsub("%,", "") the_str = the_str:gsub("%;", "") --replace curly apostrophe or wrong hyphen symbol with correct ones for links the_str = normalize_name(the_str) if the_str == '' then --if empty return false result = false else result = the_str end return result; end </pre > * Check if string empty or spaces exist in it by creating local function in module - this will ignore any authors with several last names <pre> local function check_authorname( name_str) result = true if (name_str == nil or name_str == '') then -- value must not be empty result = false end if nil == name_str:match ("^%S+$") then -- value must not contain spaces result = false end return result; end </pre > * If author last name exists and first name exist, concatenate for author-link (author2-link etc) (first name may be an initial, which we can sort with redirects) ** and if author last name exists and first name does not exist, use last name for author-link (author2-link etc) <pre> local function make_authorlink (first_str, last_str) first_str = first_name(first_str) last_str = normalize_name(last_str) result = '' if check_authorname(last_str) == true then if check_authorname(first_str) == true then result = first_str..' '..last_str else --last name without first name is also valid eg for organizations result = last_str end end return result; end </pre > ** but only if a page with that name already exists??? <pre> </pre > * loop through authors 1 to 19, until no more authors exist <pre> </pre > ==Link to other modules == * use require, invoke eg ''' getauthorlink = require ('Module:Citation/CS1/Getauthorlink'); ''' * call functions with modulename.functionname(params) eg ''' getauthorlink.make_authorlink(first_str, last_str) ''' * passing parameters to / from new module ==Testing == *[https://www.tutorialspoint.com/execute_lua_online.php Test online] [http://tpcg.io/iBdQSs code here] <pre > </pre > ==Lua code for possible date fixes == 2009-04 for instance - may be fixed by future citoid release [[User:Notjusttired|notjusttired]]
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)
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