Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Amadalvarez (talk | contribs) at 15:13, 16 July 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 100

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
<!--
Paràmetres comodí bloc "característiques"-->
|  data35 =  {{{bloc_caracteristiques_especial|}}}
| label36 = {{{etiqueta_caracteristiques1|}}}
|  data36 = {{{nom_caracteristiques1|}}}
| label37 = {{{etiqueta_caracteristiques2|}}}
|  data37 = {{{nom_caracteristiques2|}}}
| label38 = {{{etiqueta_caracteristiques3|}}}
|  data38 = {{{nom_caracteristiques3|}}}
| label39 = {{{etiqueta_caracteristiques4|}}}
|  data39 = {{{nom_caracteristiques4|}}}
| label40 = {{{etiqueta_caracteristiques5|}}}
|  data40 = {{{nom_caracteristiques5|}}}
|header41 = {{#if: {{{estatus|}}}{{{nom_anterior|}}} {{{originaris|}}} {{{fusio|}}}
              {{{predecessor|}}}{{{data_fundacio|}}} {{{lloc_fundacio|}}}{{{fundador|}}}
              {{{successor|}}} {{{extincio|}}} {{{establerta_nom1|}}}{{{establerta_nom2|}}}
              {{{establerta_nom3|}}} {{{establerta_nom4|}}}{{{establerta_nom5|}}} {{{bloc_historia_especial|}}}  
              {{{nom_historia1|}}}{{{nom_historia2|}}}{{{nom_historia3|}}}{{{nom_historia4|}}}
              {{{nom_historia5|}}}{{{escissio_de|}}}{{{escissio_en|}}}{{{refundacio|}}}{{{redissolucio|}}}  
            |{{GetLabelFix|P1454|lang={{{lang|}}}}}<!-- Història -->}}
| label42 = {{GetLabelFix|Q2628882|lang={{{lang|}}}}}<!--  Estatus&nbsp;legal -->
|  data42 = {{{estatus|}}}
| label44  = {{GetLabelFix|P807|lang={{{lang|}}}}}
|  data44  = {{{escissio_de|}}}
| label45  = {{GetLabelFix|T0045|lang={{{lang|}}}}}<!-- Fusió&nbsp;de -->
|  data45  = {{{originaris|}}}
| label47  = {{GetLabelFix|P1365|lang={{{lang|}}}}}
|  data47  = {{if empty|{{{predecessor|}}} |{{{nom_anterior|}}} }}
| label49  = {{GetLabelFix|P571|lang={{{lang|}}}}}
|  data49  = {{#if: {{{data_fundacio|}}}<!--
            -->|{{{data_fundacio|}}}{{#if: {{{lloc_fundacio|}}}{{{origen|}}}
                                      |&nbsp;a&nbsp;{{{lloc_fundacio|{{{origen|}}}}}} 
             }}                     }}
| label51  = {{GetLabelFix|P740|lang={{{lang|}}}}}
|  data51  = {{#if: {{{data_fundacio|}}} |<!-- no posar lloc fundació, perquè s'ha posat abans-->|{{{lloc_fundacio|}}} }}
| label55  = {{GetLabelFix|P112|lang={{{lang|}}}}}
|  data55  =  {{{fundador|}}} 
| label57  = {{GetLabelFix|Q124964|lang={{{lang|}}}}}<!-- Coalició -->
|  data57   = {{{coalicio|}}}
| label58  = {{GetLabelFix|T0046|lang={{{lang|}}}}}<!-- Fusionada&nbsp;amb -->
|  data58  =  {{{fusio|}}}
| label59  = {{GetLabelFix|Q18511800|lang={{{lang|}}}}}<!-- Escissió&nbsp;en -->
|  data59  = {{{escissio_en|}}}
| label60  = {{GetLabelFix|P576|lang={{{lang|}}}}}<!-- Dissolució -->
|  data60  = {{{extincio|}}} 
| label61  = {{GetLabelFix|T0047|lang={{{lang|}}}}}<!-- Refundació -->
|  data61  = {{{refundacio|}}}  
| label62  = {{GetLabelFix|T0048|lang={{{lang|}}}}}<!-- Redissolució -->
|  data62  = {{{redissolucio|}}}
| label63  = {{GetLabelFix|P1366|lang={{{lang|}}}}}
|  data63  = {{{successor|}}}
| label65  = {{GetLabelFix|P2348|lang={{{lang|}}}}}
|  data65  = {{{periode|}}}
]==========]

-- STEP 4: Save this module.

-- STEP 5: You can now output the incremented text with the following code:
--                {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.

-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.

-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!

local p = {}
 
local function replace(prefix, num, suffix)
    return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
 
function p.main(frame)
    -- Increment the template text.
    templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
    -- Add pre tags and escape html etc. if the pre option is set.
    if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
        templatetext = mw.text.nowiki(templatetext)
        templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
            .. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">' 
            .. templatetext .. '</pre>'
    end
    return templatetext
end
 
return p