Jump to content
Wikipedia The Free Encyclopedia

Module:Gaps

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]

Implements {{Gaps }}, which adds a small gap of space with cascading style sheets (C.S.S.) between every parameter.

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

 localp={}

 localgetArgs

 functionp.main(frame)
 ifnotgetArgsthen
 getArgs=require('Module:Arguments').getArgs
 end
 localargs=getArgs(frame,{wrappers='Template:Gaps'})

 localret=mw.html.create('span')
 :css({['white-space']='nowrap',
 ['font-size']=args.size})

 ifargs.lhsthen
 ret:wikitext(args.lhs..' = ')
 end

 localgap=string.lower(args.gapor'')

 localgapSize,gapUnit=string.match(gap,'([%d%.]+)%s*([ep][mnx])')

 localacceptedUnits={em='em',en='en',px='px'}

 gapUnit=acceptedUnits[gapUnit]

 ifgapSizeandgapUnitthen
 gap=gapSize..gapUnit
 else
 gap='0.25em'
 end

 fork,vinipairs(args)do
 ifk==1then
 ret:wikitext(v)
 else
 ret:tag('span')
 :css('margin-left',gap)
 :wikitext(v)
 end
 end

 ifargs.ethen
 ret
 :tag('span')
 :css({['margin-left']='0.27em',
 ['margin-right']='0.27em'})
 :wikitext(×ばつ')
 :done()
 :wikitext(args.baseor'10')
 :tag('span')
 :css('display','none')
 :wikitext('^')
 :done()
 :tag('sup')
 -- the double parentheses here are not redundant.
 -- they keep the second return value from being passed
 :wikitext((mw.ustring.gsub(args.e,'-','−')))
 :done()
 end

 ifargs.uthen
 ret:wikitext(' '..args.u)
 end

 returnret
 end

 returnp

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