Jump to content
Wikipedia The Free Encyclopedia

Module:Get short description

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Not to be confused with Module:GetShortDescription.

Implements {{get short description }}.

The above documentation is transcluded from Module:Get short description/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}

 localfunctiongetContent(title)
 localsuccess,titleObj=pcall(mw.title.new,title)
 ifnotsuccessthenreturnnilend
 returntitleObj:getContent()
 end

 functionp.main(frame,title)
 localtitle=frame.args[1]
 localwikitext=getContent(title)
 ifwikitext==nilthenreturn""end
 wikitext=frame:preprocess(wikitext)
 localstartIndex,endIndex=string.find(wikitext,"<div class=\"shortdescription nomobile noexcerpt noprint searchaux\" style=\"display:none\">")
 ifstartIndex==nilthen
 returnnil
 end
 localdescriptionStart=endIndex+1
 localdescriptionEnd=string.find(wikitext,"</div>",descriptionStart)
 ifdescriptionEnd==nilthen
 returnnil
 end
 returnstring.sub(wikitext,descriptionStart,descriptionEnd-1)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /