Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Guild of Archivists
Search
Editing
Module:Dni-utils/parse
From Guild of Archivists
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!
local p = {} local args = {} local origArgs local root local function parseDniWord(input) local result = '' local word = mw.text.trim(input) local first = mw.ustring.sub(word,1,1) local last = mw.ustring.sub(word,-1,-1) local prefix = '' local suffix = '' if (word == mw.ustring.lower(mw.title.getCurrentTitle().rootText)) then prefix = '\'\'\'' suffix = prefix end if (word == '') then result = ' ' elseif (word == ' ') then result = ' ' elseif (word == '.' or word == '?' or word == '!' or word == ',') then result = first elseif (first == '-') then result = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix elseif (last == '-') then result = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix elseif (first == '.' or first == '!' or first == '?' or first == ',') then result = first..prefix..'[[Dictionary:'..mw.ustring.sub(word,2,-1)..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix elseif (last == ',') then result = prefix..'[[Dictionary:'..mw.ustring.sub(word,1,-2)..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix..last else result = prefix..'[[Dictionary:'..word..'|'..word..']]'..suffix end return result end function p.parsed_dni(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame.args end local result = '' for word in ipairs(origArgs) do result = result..parseDniWord(origArgs[word],count) end return result end return p
Summary:
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GoArch:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Dni-utils/parse/doc
(
edit
)
Navigation
Navigation
Main Page
Random page
Categories
All pages
Recent changes
Resources
D'ni dictionary
Reference material
Utilities
Community
Forums
Jalak Game Directory
Projects
Apocrypha
Unexplored Branches
All projects
Contribute
Stubs
Wanted
Cleanup
Dead ends
Image requested
Help
Help
Guide
Policies
Wiki tools
Wiki tools
Special pages
Page values
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs