CINXE.COM
Modul:Buffer - Wikipedija, prosta enciklopedija
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available" lang="sl" dir="ltr"> <head> <meta charset="UTF-8"> <title>Modul:Buffer - Wikipedija, prosta enciklopedija</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )slwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":[",\t.",".\t,"],"wgDigitTransformTable":["",""], "wgDefaultDateFormat":"dmy full","wgMonthNames":["","januar","februar","marec","april","maj","junij","julij","avgust","september","oktober","november","december"],"wgRequestId":"0df81199-6fbc-437c-8fd0-aba5ccbe06e8","wgCanonicalNamespace":"Module","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":828,"wgPageName":"Modul:Buffer","wgTitle":"Buffer","wgCurRevisionId":5602693,"wgRevisionId":5602693,"wgArticleId":505123,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Strani z napakami v sklicevanju","Popolnoma zaščiteni moduli","Moduli za splošno uporabo","Moduli odvisni od zaščite strani"],"wgPageViewLanguage":"sl","wgPageContentLanguage":"sl","wgPageContentModel":"Scribunto","wgRelevantPageName":"Modul:Buffer","wgRelevantArticleId":505123,"wgIsProbablyEditable":false,"wgRelevantPageIsProbablyEditable":false,"wgRestrictionEdit":["sysop"],"wgRestrictionMove":["sysop"],"wgNoticeProject":"wikipedia", "wgCiteReferencePreviewsActive":true,"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":true,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":30000,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q19967589","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={ "ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","ext.cite.styles":"ready","ext.math.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","site","mediawiki.page.ready","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.CommonsDirekt","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents", "ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","wikibase.client.vector-2022","ext.checkUser.clientHints","wikibase.sidebar.tracking"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=sl&modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=sl&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=sl&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Modul:Buffer - Wikipedija, prosta enciklopedija"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//sl.m.wikipedia.org/wiki/Modul:Buffer"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedija (sl)"> <link rel="EditURI" type="application/rsd+xml" href="//sl.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://sl.wikipedia.org/wiki/Modul:Buffer"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.sl"> <link rel="alternate" type="application/atom+xml" title="Atom-vir strani »Wikipedija«" href="/w/index.php?title=Posebno:ZadnjeSpremembe&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-828 ns-subject page-Modul_Buffer rootpage-Modul_Buffer skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Pojdi na vsebino</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Projekt"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Glavni meni" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Glavni meni</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Glavni meni</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">prestavi v stransko letvico</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">skrij</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigacija </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage" class="mw-list-item"><a href="/wiki/Glavna_stran" title="Obiščite glavno stran [z]" accesskey="z"><span>Glavna stran</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Pomo%C4%8D:Uvod"><span>Naučite se urejati</span></a></li><li id="n-Izbrani-članki" class="mw-list-item"><a href="/wiki/Wikipedija:Izbrani_%C4%8Dlanki"><span>Izbrani članki</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Posebno:Naklju%C4%8Dno" title="Naložite naključno stran [x]" accesskey="x"><span>Naključna stran</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Posebno:ZadnjeSpremembe" title="Seznam zadnjih sprememb Wikipedije [r]" accesskey="r"><span>Zadnje spremembe</span></a></li> </ul> </div> </div> <div id="p-obcestvo" class="vector-menu mw-portlet mw-portlet-obcestvo" > <div class="vector-menu-heading"> Skupnost </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Pomo%C4%8D:Vsebina" title="Kraj, kjer lahko prejmete pomoč"><span>Pomoč</span></a></li><li id="n-Pod-lipo" class="mw-list-item"><a href="/wiki/Wikipedija:Pod_lipo"><span>Pod lipo</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedija:Portal_skupnosti" title="O projektu, kaj lahko storite, kje lahko kaj najdete"><span>Portal skupnosti</span></a></li><li id="n-contact" class="mw-list-item"><a href="/wiki/Wikipedija:Stik_z_nami"><span>Stik z nami</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Glavna_stran" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedija" src="/static/images/mobile/copyright/wikipedia-wordmark-sl.svg" style="width: 7.4375em; height: 1.375em;"> <img class="mw-logo-tagline" alt="prosta enciklopedija" src="/static/images/mobile/copyright/wikipedia-tagline-sl.svg" width="118" height="13" style="width: 7.375em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Posebno:Iskanje" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Preiščite viki [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Iskanje</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Iskanje v Wikipediji" aria-label="Iskanje v Wikipediji" autocapitalize="sentences" title="Preiščite viki [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Posebno:Iskanje"> </div> <button class="cdx-button cdx-search-input__end-button">Išči</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Osebna orodja"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Videz"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Videz" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Videz</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="//donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_sl.wikipedia.org&uselang=sl" class=""><span>Denarni prispevki</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Posebno:Registracija&returnto=Modul%3ABuffer" title="Predlagamo vam, da si ustvarite račun in se prijavite, vendar to ni obvezno." class=""><span>Ustvari račun</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Posebno:Prijava&returnto=Modul%3ABuffer" title="Prijava je zaželena, vendar ni obvezna [o]" accesskey="o" class=""><span>Prijava</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Več možnosti" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Osebna orodja" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Osebna orodja</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="Uporabniški meni" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="//donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_sl.wikipedia.org&uselang=sl"><span>Denarni prispevki</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Posebno:Registracija&returnto=Modul%3ABuffer" title="Predlagamo vam, da si ustvarite račun in se prijavite, vendar to ni obvezno."><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Ustvari račun</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Posebno:Prijava&returnto=Modul%3ABuffer" title="Prijava je zaželena, vendar ni obvezna [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Prijava</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Strani za neprijavljene urejevalce <a href="/wiki/Pomo%C4%8D:Uvod" aria-label="Več o urejanju"><span>več o tem</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Posebno:MojiPrispevki" title="Seznam urejanj s tega IP-naslova [y]" accesskey="y"><span>Prispevki</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Posebno:MojPogovor" title="Pogovor o urejanjih s tega IP-naslova [n]" accesskey="n"><span>Pogovorna stran</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Projekt"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Vsebina" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Vsebina</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">prestavi v stransko letvico</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">skrij</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">Uvod</div> </a> </li> <li id="toc-Usage" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Usage"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Usage</span> </div> </a> <button aria-controls="toc-Usage-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek Usage</span> </button> <ul id="toc-Usage-sublist" class="vector-toc-list"> <li id="toc-require'Module:Buffer'" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#require'Module:Buffer'"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1</span> <span>require'Module:Buffer'</span> </div> </a> <ul id="toc-require'Module:Buffer'-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Basic_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Basic_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2</span> <span>Basic functions</span> </div> </a> <ul id="toc-Basic_functions-sublist" class="vector-toc-list"> <li id="toc-Buffer_object" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.1</span> <span>Buffer object</span> </div> </a> <ul id="toc-Buffer_object-sublist" class="vector-toc-list"> <li id="toc-Buffer.last_concat" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#Buffer.last_concat"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.1.1</span> <span>Buffer.last_concat</span> </div> </a> <ul id="toc-Buffer.last_concat-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Buffer:" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.2</span> <span>Buffer:_</span> </div> </a> <ul id="toc-Buffer:-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_nil" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_nil"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.3</span> <span>Buffer:_nil</span> </div> </a> <ul id="toc-Buffer:_nil-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_all" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_all"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.4</span> <span>Buffer:_all</span> </div> </a> <ul id="toc-Buffer:_all-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_in" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_in"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.5</span> <span>Buffer:_in</span> </div> </a> <ul id="toc-Buffer:_in-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_out" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_out"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.6</span> <span>Buffer:_out</span> </div> </a> <ul id="toc-Buffer:_out-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_str" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_str"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.7</span> <span>Buffer:_str</span> </div> </a> <ul id="toc-Buffer:_str-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_cc" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_cc"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.8</span> <span>Buffer:_cc</span> </div> </a> <ul id="toc-Buffer:_cc-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_parent" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_parent"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.9</span> <span>Buffer:_parent</span> </div> </a> <ul id="toc-Buffer:_parent-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:getParent" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:getParent"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.10</span> <span>Buffer:getParent</span> </div> </a> <ul id="toc-Buffer:getParent-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:killParent" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:killParent"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2.11</span> <span>Buffer:killParent</span> </div> </a> <ul id="toc-Buffer:killParent-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Stream_mode" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Stream_mode"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3</span> <span>Stream mode</span> </div> </a> <ul id="toc-Stream_mode-sublist" class="vector-toc-list"> <li id="toc-Buffer:stream" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:stream"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3.1</span> <span>Buffer:stream</span> </div> </a> <ul id="toc-Buffer:stream-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Stream-Buffer_object" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Stream-Buffer_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3.2</span> <span>Stream-Buffer object</span> </div> </a> <ul id="toc-Stream-Buffer_object-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Stream-Buffer:each" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Stream-Buffer:each"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3.3</span> <span>Stream-Buffer:each</span> </div> </a> <ul id="toc-Stream-Buffer:each-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> <li id="toc-HTML_library_extension" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#HTML_library_extension"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>HTML library extension</span> </div> </a> <button aria-controls="toc-HTML_library_extension-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek HTML library extension</span> </button> <ul id="toc-HTML_library_extension-sublist" class="vector-toc-list"> <li id="toc-Buffer_functions_for_HTML" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Buffer_functions_for_HTML"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Buffer functions for HTML</span> </div> </a> <ul id="toc-Buffer_functions_for_HTML-sublist" class="vector-toc-list"> <li id="toc-Buffer:_inHTML" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_inHTML"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1.1</span> <span>Buffer:_inHTML</span> </div> </a> <ul id="toc-Buffer:_inHTML-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:getHTML" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:getHTML"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1.2</span> <span>Buffer:getHTML</span> </div> </a> <ul id="toc-Buffer:getHTML-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_html" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_html"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1.3</span> <span>Buffer:_html</span> </div> </a> <ul id="toc-Buffer:_html-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-HTML_object_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#HTML_object_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>HTML object functions</span> </div> </a> <ul id="toc-HTML_object_functions-sublist" class="vector-toc-list"> <li id="toc-Buffer-HTML_object" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer-HTML_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2.1</span> <span>Buffer-HTML object</span> </div> </a> <ul id="toc-Buffer-HTML_object-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Element-Buffer_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Element-Buffer_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Element-Buffer functions</span> </div> </a> <ul id="toc-Element-Buffer_functions-sublist" class="vector-toc-list"> <li id="toc-Element-Buffer_object" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Element-Buffer_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.1</span> <span>Element-Buffer object</span> </div> </a> <ul id="toc-Element-Buffer_object-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Element-Buffer:done" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Element-Buffer:done"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.2</span> <span>Element-Buffer:done</span> </div> </a> <ul id="toc-Element-Buffer:done-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Element-Buffer:tag" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Element-Buffer:tag"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.3</span> <span>Element-Buffer:tag</span> </div> </a> <ul id="toc-Element-Buffer:tag-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Element-Buffer:_add" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Element-Buffer:_add"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4</span> <span>Element-Buffer:_add</span> </div> </a> <ul id="toc-Element-Buffer:_add-sublist" class="vector-toc-list"> <li id="toc-args.argName" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.argName"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.1</span> <span>args.<i>argName</i></span> </div> </a> <ul id="toc-args.argName-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.cssName" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.cssName"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.2</span> <span>args.<i>cssName</i></span> </div> </a> <ul id="toc-args.cssName-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.tag†" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.tag†"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.3</span> <span>args.tag<sup>†</sup></span> </div> </a> <ul id="toc-args.tag†-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.done†" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.done†"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.4</span> <span>args.done<sup>†</sup></span> </div> </a> <ul id="toc-args.done†-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.allDone" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.allDone"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.5</span> <span>args.allDone</span> </div> </a> <ul id="toc-args.allDone-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.globalFunction‡" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.globalFunction‡"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.6</span> <span>args.<i>globalFunction</i><sup>‡</sup></span> </div> </a> <ul id="toc-args.globalFunction‡-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-args.htmlFunction" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#args.htmlFunction"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3.4.7</span> <span>args.<i>htmlFunction</i></span> </div> </a> <ul id="toc-args.htmlFunction-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Loadable_convenience_extensions" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Loadable_convenience_extensions"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Loadable convenience extensions</span> </div> </a> <button aria-controls="toc-Loadable_convenience_extensions-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek Loadable convenience extensions</span> </button> <ul id="toc-Loadable_convenience_extensions-sublist" class="vector-toc-list"> <li id="toc-Global_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Global_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>Global functions</span> </div> </a> <ul id="toc-Global_functions-sublist" class="vector-toc-list"> <li id="toc-Buffer:_G" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_G"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.1</span> <span>Buffer:_G</span> </div> </a> <ul id="toc-Buffer:_G-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_R" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_R"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.2</span> <span>Buffer:_R</span> </div> </a> <ul id="toc-Buffer:_R-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_2" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_2"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.3</span> <span>Buffer:_2</span> </div> </a> <ul id="toc-Buffer:_2-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Buffer:_B" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_B"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.4</span> <span>Buffer:_B</span> </div> </a> <ul id="toc-Buffer:_B-sublist" class="vector-toc-list"> <li id="toc-Buffer-nil_object" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#Buffer-nil_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.4.1</span> <span>Buffer-nil object</span> </div> </a> <ul id="toc-Buffer-nil_object-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-G_object" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#G_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.5</span> <span>_G object</span> </div> </a> <ul id="toc-G_object-sublist" class="vector-toc-list"> <li id="toc-direct_call" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#direct_call"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.5.1</span> <span>direct call</span> </div> </a> <ul id="toc-direct_call-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-chain_call" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#chain_call"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.5.2</span> <span>chain call</span> </div> </a> <ul id="toc-chain_call-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Buffer-variable_object" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Buffer-variable_object"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>Buffer-variable object</span> </div> </a> <ul id="toc-Buffer-variable_object-sublist" class="vector-toc-list"> <li id="toc-Buffer:_var" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Buffer:_var"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2.1</span> <span>Buffer:_var</span> </div> </a> <ul id="toc-Buffer:_var-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-String,_mw.ustring,_and_mw.text_libraries" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#String,_mw.ustring,_and_mw.text_libraries"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3</span> <span>String, mw.ustring, and mw.text libraries</span> </div> </a> <ul id="toc-String,_mw.ustring,_and_mw.text_libraries-sublist" class="vector-toc-list"> <li id="toc-Basic_usage" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Basic_usage"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3.1</span> <span>Basic usage</span> </div> </a> <ul id="toc-Basic_usage-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Empty_Buffer_interface" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Empty_Buffer_interface"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3.2</span> <span>Empty Buffer interface</span> </div> </a> <ul id="toc-Empty_Buffer_interface-sublist" class="vector-toc-list"> <li id="toc-Special_case:_Element-Buffer" class="vector-toc-list-item vector-toc-level-4"> <a class="vector-toc-link" href="#Special_case:_Element-Buffer"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3.2.1</span> <span>Special case: Element-Buffer</span> </div> </a> <ul id="toc-Special_case:_Element-Buffer-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Modified_.._operator" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Modified_.._operator"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Modified .. operator</span> </div> </a> <button aria-controls="toc-Modified_.._operator-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek Modified .. operator</span> </button> <ul id="toc-Modified_.._operator-sublist" class="vector-toc-list"> <li id="toc-with_non-tables" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#with_non-tables"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>with non-tables</span> </div> </a> <ul id="toc-with_non-tables-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-with_tables" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#with_tables"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>with tables</span> </div> </a> <ul id="toc-with_tables-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-for_Element-Buffers" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#for_Element-Buffers"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>for Element-Buffers</span> </div> </a> <ul id="toc-for_Element-Buffers-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-require'Module:Buffer'._pairs" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#require'Module:Buffer'._pairs"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>require'Module:Buffer'.__pairs</span> </div> </a> <button aria-controls="toc-require'Module:Buffer'._pairs-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek require'Module:Buffer'.__pairs</span> </button> <ul id="toc-require'Module:Buffer'._pairs-sublist" class="vector-toc-list"> <li id="toc-Mapping_process" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Mapping_process"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Mapping process</span> </div> </a> <ul id="toc-Mapping_process-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Iterators" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Iterators"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>Iterators</span> </div> </a> <ul id="toc-Iterators-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Appendix" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Appendix"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Appendix</span> </div> </a> <button aria-controls="toc-Appendix-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Vklopi podrazdelek Appendix</span> </button> <ul id="toc-Appendix-sublist" class="vector-toc-list"> <li id="toc-Tips_and_style_recommendations" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Tips_and_style_recommendations"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Tips and style recommendations</span> </div> </a> <ul id="toc-Tips_and_style_recommendations-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Examples" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Examples"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2</span> <span>Examples</span> </div> </a> <ul id="toc-Examples-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Vsebina" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Vklopi kazalo vsebine" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Vklopi kazalo vsebine</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-namespace">Modul</span><span class="mw-page-title-separator">:</span><span class="mw-page-title-main">Buffer</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="P9jdi na članek v drugem jeziku. Na voljo v 65 jezikih." > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-65" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">65 jezikov</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ab mw-list-item"><a href="https://ab.wikipedia.org/wiki/%D0%90%D0%BC%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Buffer" title="Амодуль:Buffer – abhaščina" lang="ab" hreflang="ab" data-title="Амодуль:Buffer" data-language-autonym="Аԥсшәа" data-language-local-name="abhaščina" class="interlanguage-link-target"><span>Аԥсшәа</span></a></li><li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D9%88%D8%AD%D8%AF%D8%A9:Buffer" title="وحدة:Buffer – arabščina" lang="ar" hreflang="ar" data-title="وحدة:Buffer" data-language-autonym="العربية" data-language-local-name="arabščina" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-arz mw-list-item"><a href="https://arz.wikipedia.org/wiki/%D9%88%D8%AD%D8%AF%D8%A9:Buffer" title="وحدة:Buffer – Egyptian Arabic" lang="arz" hreflang="arz" data-title="وحدة:Buffer" data-language-autonym="مصرى" data-language-local-name="Egyptian Arabic" class="interlanguage-link-target"><span>مصرى</span></a></li><li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – azerbajdžanščina" lang="az" hreflang="az" data-title="Modul:Buffer" data-language-autonym="Azərbaycanca" data-language-local-name="azerbajdžanščina" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-azb mw-list-item"><a href="https://azb.wikipedia.org/wiki/%D9%85%D8%A7%DA%98%D9%88%D9%84:Buffer" title="ماژول:Buffer – South Azerbaijani" lang="azb" hreflang="azb" data-title="ماژول:Buffer" data-language-autonym="تۆرکجه" data-language-local-name="South Azerbaijani" class="interlanguage-link-target"><span>تۆرکجه</span></a></li><li class="interlanguage-link interwiki-ban mw-list-item"><a href="https://ban.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – balijščina" lang="ban" hreflang="ban" data-title="Modul:Buffer" data-language-autonym="Basa Bali" data-language-local-name="balijščina" class="interlanguage-link-target"><span>Basa Bali</span></a></li><li class="interlanguage-link interwiki-bcl mw-list-item"><a href="https://bcl.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – Central Bikol" lang="bcl" hreflang="bcl" data-title="Module:Buffer" data-language-autonym="Bikol Central" data-language-local-name="Central Bikol" class="interlanguage-link-target"><span>Bikol Central</span></a></li><li class="interlanguage-link interwiki-bh mw-list-item"><a href="https://bh.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – Bhojpuri" lang="bh" hreflang="bh" data-title="Module:Buffer" data-language-autonym="भोजपुरी" data-language-local-name="Bhojpuri" class="interlanguage-link-target"><span>भोजपुरी</span></a></li><li class="interlanguage-link interwiki-bi mw-list-item"><a href="https://bi.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – bislamščina" lang="bi" hreflang="bi" data-title="Module:Buffer" data-language-autonym="Bislama" data-language-local-name="bislamščina" class="interlanguage-link-target"><span>Bislama</span></a></li><li class="interlanguage-link interwiki-blk mw-list-item"><a href="https://blk.wikipedia.org/wiki/%E1%80%99%E1%80%B1%E1%80%AC%E1%80%BA%E1%80%82%E1%80%BB%E1%80%B0%E1%80%B8:Buffer" title="မော်ဂျူး:Buffer – Pa'O" lang="blk" hreflang="blk" data-title="မော်ဂျူး:Buffer" data-language-autonym="ပအိုဝ်ႏဘာႏသာႏ" data-language-local-name="Pa'O" class="interlanguage-link-target"><span>ပအိုဝ်ႏဘာႏသာႏ</span></a></li><li class="interlanguage-link interwiki-bn mw-list-item"><a href="https://bn.wikipedia.org/wiki/%E0%A6%AE%E0%A6%A1%E0%A6%BF%E0%A6%89%E0%A6%B2:Buffer" title="মডিউল:Buffer – bengalščina" lang="bn" hreflang="bn" data-title="মডিউল:Buffer" data-language-autonym="বাংলা" data-language-local-name="bengalščina" class="interlanguage-link-target"><span>বাংলা</span></a></li><li class="interlanguage-link interwiki-bs mw-list-item"><a href="https://bs.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – bosanščina" lang="bs" hreflang="bs" data-title="Modul:Buffer" data-language-autonym="Bosanski" data-language-local-name="bosanščina" class="interlanguage-link-target"><span>Bosanski</span></a></li><li class="interlanguage-link interwiki-ceb mw-list-item"><a href="https://ceb.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – sebuanščina" lang="ceb" hreflang="ceb" data-title="Module:Buffer" data-language-autonym="Cebuano" data-language-local-name="sebuanščina" class="interlanguage-link-target"><span>Cebuano</span></a></li><li class="interlanguage-link interwiki-ckb mw-list-item"><a href="https://ckb.wikipedia.org/wiki/%D9%85%DB%86%D8%AF%DB%8C%D9%88%D9%88%D9%84:Buffer" title="مۆدیوول:Buffer – osrednja kurdščina" lang="ckb" hreflang="ckb" data-title="مۆدیوول:Buffer" data-language-autonym="کوردی" data-language-local-name="osrednja kurdščina" class="interlanguage-link-target"><span>کوردی</span></a></li><li class="interlanguage-link interwiki-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – danščina" lang="da" hreflang="da" data-title="Modul:Buffer" data-language-autonym="Dansk" data-language-local-name="danščina" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-dty mw-list-item"><a href="https://dty.wikipedia.org/wiki/%E0%A4%AE%E0%A5%8B%E0%A4%A1%E0%A5%8D%E0%A4%AF%E0%A5%81%E0%A4%B2:Buffer" title="मोड्युल:Buffer – Doteli" lang="dty" hreflang="dty" data-title="मोड्युल:Buffer" data-language-autonym="डोटेली" data-language-local-name="Doteli" class="interlanguage-link-target"><span>डोटेली</span></a></li><li class="interlanguage-link interwiki-en mw-list-item"><a href="https://en.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – angleščina" lang="en" hreflang="en" data-title="Module:Buffer" data-language-autonym="English" data-language-local-name="angleščina" class="interlanguage-link-target"><span>English</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Buffer" title="پودمان:Buffer – perzijščina" lang="fa" hreflang="fa" data-title="پودمان:Buffer" data-language-autonym="فارسی" data-language-local-name="perzijščina" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fo mw-list-item"><a href="https://fo.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – ferščina" lang="fo" hreflang="fo" data-title="Module:Buffer" data-language-autonym="Føroyskt" data-language-local-name="ferščina" class="interlanguage-link-target"><span>Føroyskt</span></a></li><li class="interlanguage-link interwiki-ga mw-list-item"><a href="https://ga.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – irščina" lang="ga" hreflang="ga" data-title="Module:Buffer" data-language-autonym="Gaeilge" data-language-local-name="irščina" class="interlanguage-link-target"><span>Gaeilge</span></a></li><li class="interlanguage-link interwiki-gn mw-list-item"><a href="https://gn.wikipedia.org/wiki/M%C3%B3dulo:Buffer" title="Módulo:Buffer – gvaranijščina" lang="gn" hreflang="gn" data-title="Módulo:Buffer" data-language-autonym="Avañe'ẽ" data-language-local-name="gvaranijščina" class="interlanguage-link-target"><span>Avañe'ẽ</span></a></li><li class="interlanguage-link interwiki-gu mw-list-item"><a href="https://gu.wikipedia.org/wiki/%E0%AA%B5%E0%AA%BF%E0%AA%AD%E0%AA%BE%E0%AA%97:Buffer" title="વિભાગ:Buffer – gudžaratščina" lang="gu" hreflang="gu" data-title="વિભાગ:Buffer" data-language-autonym="ગુજરાતી" data-language-local-name="gudžaratščina" class="interlanguage-link-target"><span>ગુજરાતી</span></a></li><li class="interlanguage-link interwiki-hi mw-list-item"><a href="https://hi.wikipedia.org/wiki/%E0%A4%AE%E0%A5%89%E0%A4%A1%E0%A5%8D%E0%A4%AF%E0%A5%82%E0%A4%B2:Buffer" title="मॉड्यूल:Buffer – hindijščina" lang="hi" hreflang="hi" data-title="मॉड्यूल:Buffer" data-language-autonym="हिन्दी" data-language-local-name="hindijščina" class="interlanguage-link-target"><span>हिन्दी</span></a></li><li class="interlanguage-link interwiki-hif mw-list-item"><a href="https://hif.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – Fiji Hindi" lang="hif" hreflang="hif" data-title="Module:Buffer" data-language-autonym="Fiji Hindi" data-language-local-name="Fiji Hindi" class="interlanguage-link-target"><span>Fiji Hindi</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – indonezijščina" lang="id" hreflang="id" data-title="Modul:Buffer" data-language-autonym="Bahasa Indonesia" data-language-local-name="indonezijščina" class="interlanguage-link-target"><span>Bahasa Indonesia</span></a></li><li class="interlanguage-link interwiki-ilo mw-list-item"><a href="https://ilo.wikipedia.org/wiki/Modulo:Buffer" title="Modulo:Buffer – ilokanščina" lang="ilo" hreflang="ilo" data-title="Modulo:Buffer" data-language-autonym="Ilokano" data-language-local-name="ilokanščina" class="interlanguage-link-target"><span>Ilokano</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Buffer" title="モジュール:Buffer – japonščina" lang="ja" hreflang="ja" data-title="モジュール:Buffer" data-language-autonym="日本語" data-language-local-name="japonščina" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-jv mw-list-item"><a href="https://jv.wikipedia.org/wiki/Modhul:Buffer" title="Modhul:Buffer – javanščina" lang="jv" hreflang="jv" data-title="Modhul:Buffer" data-language-autonym="Jawa" data-language-local-name="javanščina" class="interlanguage-link-target"><span>Jawa</span></a></li><li class="interlanguage-link interwiki-ka mw-list-item"><a href="https://ka.wikipedia.org/wiki/%E1%83%9B%E1%83%9D%E1%83%93%E1%83%A3%E1%83%9A%E1%83%98:Buffer" title="მოდული:Buffer – gruzijščina" lang="ka" hreflang="ka" data-title="მოდული:Buffer" data-language-autonym="ქართული" data-language-local-name="gruzijščina" class="interlanguage-link-target"><span>ქართული</span></a></li><li class="interlanguage-link interwiki-kaa mw-list-item"><a href="https://kaa.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – karakalpaščina" lang="kaa" hreflang="kaa" data-title="Module:Buffer" data-language-autonym="Qaraqalpaqsha" data-language-local-name="karakalpaščina" class="interlanguage-link-target"><span>Qaraqalpaqsha</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EB%AA%A8%EB%93%88:Buffer" title="모듈:Buffer – korejščina" lang="ko" hreflang="ko" data-title="모듈:Buffer" data-language-autonym="한국어" data-language-local-name="korejščina" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-ku mw-list-item"><a href="https://ku.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – kurdščina" lang="ku" hreflang="ku" data-title="Modul:Buffer" data-language-autonym="Kurdî" data-language-local-name="kurdščina" class="interlanguage-link-target"><span>Kurdî</span></a></li><li class="interlanguage-link interwiki-lt mw-list-item"><a href="https://lt.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – litovščina" lang="lt" hreflang="lt" data-title="Module:Buffer" data-language-autonym="Lietuvių" data-language-local-name="litovščina" class="interlanguage-link-target"><span>Lietuvių</span></a></li><li class="interlanguage-link interwiki-lv mw-list-item"><a href="https://lv.wikipedia.org/wiki/Modulis:Buffer" title="Modulis:Buffer – latvijščina" lang="lv" hreflang="lv" data-title="Modulis:Buffer" data-language-autonym="Latviešu" data-language-local-name="latvijščina" class="interlanguage-link-target"><span>Latviešu</span></a></li><li class="interlanguage-link interwiki-mad mw-list-item"><a href="https://mad.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – madurščina" lang="mad" hreflang="mad" data-title="Modul:Buffer" data-language-autonym="Madhurâ" data-language-local-name="madurščina" class="interlanguage-link-target"><span>Madhurâ</span></a></li><li class="interlanguage-link interwiki-mk mw-list-item"><a href="https://mk.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB:Buffer" title="Модул:Buffer – makedonščina" lang="mk" hreflang="mk" data-title="Модул:Buffer" data-language-autonym="Македонски" data-language-local-name="makedonščina" class="interlanguage-link-target"><span>Македонски</span></a></li><li class="interlanguage-link interwiki-ml mw-list-item"><a href="https://ml.wikipedia.org/wiki/%E0%B4%98%E0%B4%9F%E0%B4%95%E0%B4%82:Buffer" title="ഘടകം:Buffer – malajalamščina" lang="ml" hreflang="ml" data-title="ഘടകം:Buffer" data-language-autonym="മലയാളം" data-language-local-name="malajalamščina" class="interlanguage-link-target"><span>മലയാളം</span></a></li><li class="interlanguage-link interwiki-mr mw-list-item"><a href="https://mr.wikipedia.org/wiki/%E0%A4%B5%E0%A4%BF%E0%A4%AD%E0%A4%BE%E0%A4%97:Buffer" title="विभाग:Buffer – maratščina" lang="mr" hreflang="mr" data-title="विभाग:Buffer" data-language-autonym="मराठी" data-language-local-name="maratščina" class="interlanguage-link-target"><span>मराठी</span></a></li><li class="interlanguage-link interwiki-ms mw-list-item"><a href="https://ms.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – malajščina" lang="ms" hreflang="ms" data-title="Modul:Buffer" data-language-autonym="Bahasa Melayu" data-language-local-name="malajščina" class="interlanguage-link-target"><span>Bahasa Melayu</span></a></li><li class="interlanguage-link interwiki-my mw-list-item"><a href="https://my.wikipedia.org/wiki/%E1%80%99%E1%80%B1%E1%80%AC%E1%80%BA%E1%80%82%E1%80%BB%E1%80%B0%E1%80%B8:Buffer" title="မော်ဂျူး:Buffer – burmanščina" lang="my" hreflang="my" data-title="မော်ဂျူး:Buffer" data-language-autonym="မြန်မာဘာသာ" data-language-local-name="burmanščina" class="interlanguage-link-target"><span>မြန်မာဘာသာ</span></a></li><li class="interlanguage-link interwiki-or mw-list-item"><a href="https://or.wikipedia.org/wiki/%E0%AC%AE%E0%AC%A1%E0%AD%8D%E0%AD%9F%E0%AD%81%E0%AC%B2:Buffer" title="ମଡ୍ୟୁଲ:Buffer – odijščina" lang="or" hreflang="or" data-title="ମଡ୍ୟୁଲ:Buffer" data-language-autonym="ଓଡ଼ିଆ" data-language-local-name="odijščina" class="interlanguage-link-target"><span>ଓଡ଼ିଆ</span></a></li><li class="interlanguage-link interwiki-pa mw-list-item"><a href="https://pa.wikipedia.org/wiki/%E0%A8%AE%E0%A9%8C%E0%A8%A1%E0%A8%BF%E0%A8%8A%E0%A8%B2:Buffer" title="ਮੌਡਿਊਲ:Buffer – pandžabščina" lang="pa" hreflang="pa" data-title="ਮੌਡਿਊਲ:Buffer" data-language-autonym="ਪੰਜਾਬੀ" data-language-local-name="pandžabščina" class="interlanguage-link-target"><span>ਪੰਜਾਬੀ</span></a></li><li class="interlanguage-link interwiki-pnb mw-list-item"><a href="https://pnb.wikipedia.org/wiki/%D9%85%D8%A7%DA%88%DB%8C%D9%88%D9%84:Buffer" title="ماڈیول:Buffer – Western Punjabi" lang="pnb" hreflang="pnb" data-title="ماڈیول:Buffer" data-language-autonym="پنجابی" data-language-local-name="Western Punjabi" class="interlanguage-link-target"><span>پنجابی</span></a></li><li class="interlanguage-link interwiki-ps mw-list-item"><a href="https://ps.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – paštunščina" lang="ps" hreflang="ps" data-title="Module:Buffer" data-language-autonym="پښتو" data-language-local-name="paštunščina" class="interlanguage-link-target"><span>پښتو</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/M%C3%B3dulo:Buffer" title="Módulo:Buffer – portugalščina" lang="pt" hreflang="pt" data-title="Módulo:Buffer" data-language-autonym="Português" data-language-local-name="portugalščina" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ro mw-list-item"><a href="https://ro.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – romunščina" lang="ro" hreflang="ro" data-title="Modul:Buffer" data-language-autonym="Română" data-language-local-name="romunščina" class="interlanguage-link-target"><span>Română</span></a></li><li class="interlanguage-link interwiki-sco mw-list-item"><a href="https://sco.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – škotščina" lang="sco" hreflang="sco" data-title="Module:Buffer" data-language-autonym="Scots" data-language-local-name="škotščina" class="interlanguage-link-target"><span>Scots</span></a></li><li class="interlanguage-link interwiki-sd mw-list-item"><a href="https://sd.wikipedia.org/wiki/%D9%85%D8%A7%DA%8A%D9%8A%D9%88%D9%84:Buffer" title="ماڊيول:Buffer – sindščina" lang="sd" hreflang="sd" data-title="ماڊيول:Buffer" data-language-autonym="سنڌي" data-language-local-name="sindščina" class="interlanguage-link-target"><span>سنڌي</span></a></li><li class="interlanguage-link interwiki-shn mw-list-item"><a href="https://shn.wikipedia.org/wiki/%E1%80%99%E1%80%B1%E1%82%83%E1%82%87%E1%81%B5%E1%80%BB%E1%80%B0%E1%80%B8:Buffer" title="မေႃႇၵျူး:Buffer – šanščina" lang="shn" hreflang="shn" data-title="မေႃႇၵျူး:Buffer" data-language-autonym="ၽႃႇသႃႇတႆး " data-language-local-name="šanščina" class="interlanguage-link-target"><span>ၽႃႇသႃႇတႆး </span></a></li><li class="interlanguage-link interwiki-si mw-list-item"><a href="https://si.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – sinhalščina" lang="si" hreflang="si" data-title="Module:Buffer" data-language-autonym="සිංහල" data-language-local-name="sinhalščina" class="interlanguage-link-target"><span>සිංහල</span></a></li><li class="interlanguage-link interwiki-simple mw-list-item"><a href="https://simple.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – Simple English" lang="en-simple" hreflang="en-simple" data-title="Module:Buffer" data-language-autonym="Simple English" data-language-local-name="Simple English" class="interlanguage-link-target"><span>Simple English</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB:Buffer" title="Модул:Buffer – srbščina" lang="sr" hreflang="sr" data-title="Модул:Buffer" data-language-autonym="Српски / srpski" data-language-local-name="srbščina" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-tdd mw-list-item"><a href="https://tdd.wikipedia.org/wiki/%E1%A5%9B%E1%A5%A8%E1%A5%9D%E1%A5%B1_%E1%A5%93%E1%A5%A7%E1%A5%B0:Buffer" title="ᥛᥨᥝᥱ ᥓᥧᥰ:Buffer – Tai Nuea" lang="tdd" hreflang="tdd" data-title="ᥛᥨᥝᥱ ᥓᥧᥰ:Buffer" data-language-autonym="ᥖᥭᥰ ᥖᥬᥲ ᥑᥨᥒᥰ" data-language-local-name="Tai Nuea" class="interlanguage-link-target"><span>ᥖᥭᥰ ᥖᥬᥲ ᥑᥨᥒᥰ</span></a></li><li class="interlanguage-link interwiki-tg mw-list-item"><a href="https://tg.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB:Buffer" title="Модул:Buffer – tadžiščina" lang="tg" hreflang="tg" data-title="Модул:Buffer" data-language-autonym="Тоҷикӣ" data-language-local-name="tadžiščina" class="interlanguage-link-target"><span>Тоҷикӣ</span></a></li><li class="interlanguage-link interwiki-th mw-list-item"><a href="https://th.wikipedia.org/wiki/%E0%B8%A1%E0%B8%AD%E0%B8%94%E0%B8%B9%E0%B8%A5:Buffer" title="มอดูล:Buffer – tajščina" lang="th" hreflang="th" data-title="มอดูล:Buffer" data-language-autonym="ไทย" data-language-local-name="tajščina" class="interlanguage-link-target"><span>ไทย</span></a></li><li class="interlanguage-link interwiki-tk mw-list-item"><a href="https://tk.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – turkmenščina" lang="tk" hreflang="tk" data-title="Module:Buffer" data-language-autonym="Türkmençe" data-language-local-name="turkmenščina" class="interlanguage-link-target"><span>Türkmençe</span></a></li><li class="interlanguage-link interwiki-tr mw-list-item"><a href="https://tr.wikipedia.org/wiki/Mod%C3%BCl:Arabellek" title="Modül:Arabellek – turščina" lang="tr" hreflang="tr" data-title="Modül:Arabellek" data-language-autonym="Türkçe" data-language-local-name="turščina" class="interlanguage-link-target"><span>Türkçe</span></a></li><li class="interlanguage-link interwiki-tt mw-list-item"><a href="https://tt.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Buffer" title="Модуль:Buffer – tatarščina" lang="tt" hreflang="tt" data-title="Модуль:Buffer" data-language-autonym="Татарча / tatarça" data-language-local-name="tatarščina" class="interlanguage-link-target"><span>Татарча / tatarça</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Buffer" title="Модуль:Buffer – ukrajinščina" lang="uk" hreflang="uk" data-title="Модуль:Buffer" data-language-autonym="Українська" data-language-local-name="ukrajinščina" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-ur mw-list-item"><a href="https://ur.wikipedia.org/wiki/%D9%85%D8%A7%DA%88%DB%8C%D9%88%D9%84:Buffer" title="ماڈیول:Buffer – urdujščina" lang="ur" hreflang="ur" data-title="ماڈیول:Buffer" data-language-autonym="اردو" data-language-local-name="urdujščina" class="interlanguage-link-target"><span>اردو</span></a></li><li class="interlanguage-link interwiki-uz mw-list-item"><a href="https://uz.wikipedia.org/wiki/Modul:Buffer" title="Modul:Buffer – uzbeščina" lang="uz" hreflang="uz" data-title="Modul:Buffer" data-language-autonym="Oʻzbekcha / ўзбекча" data-language-local-name="uzbeščina" class="interlanguage-link-target"><span>Oʻzbekcha / ўзбекча</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/M%C3%B4_%C4%91un:Buffer" title="Mô đun:Buffer – vietnamščina" lang="vi" hreflang="vi" data-title="Mô đun:Buffer" data-language-autonym="Tiếng Việt" data-language-local-name="vietnamščina" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/Module:Buffer" title="Module:Buffer – kitajščina" lang="zh" hreflang="zh" data-title="Module:Buffer" data-language-autonym="中文" data-language-local-name="kitajščina" class="interlanguage-link-target"><span>中文</span></a></li><li class="interlanguage-link interwiki-zh-min-nan mw-list-item"><a href="https://zh-min-nan.wikipedia.org/wiki/%E6%A8%A1%E7%B5%84:Buffer" title="模組:Buffer – min nan kitajščina" lang="nan" hreflang="nan" data-title="模組:Buffer" data-language-autonym="閩南語 / Bân-lâm-gú" data-language-local-name="min nan kitajščina" class="interlanguage-link-target"><span>閩南語 / Bân-lâm-gú</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/%E6%A8%A1%E7%B5%84:Buffer" title="模組:Buffer – kantonščina" lang="yue" hreflang="yue" data-title="模組:Buffer" data-language-autonym="粵語" data-language-local-name="kantonščina" class="interlanguage-link-target"><span>粵語</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q19967589#sitelinks-wikipedia" title="Uredi medjezikovne povezave" class="wbc-editpage">Uredi povezave</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Imenski prostori"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-module" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Modul:Buffer" title="Prikaže stran modula [c]" accesskey="c"><span>Modul</span></a></li><li id="ca-talk" class="new vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Pogovor_o_modulu:Buffer&action=edit&redlink=1" rel="discussion" class="new" title="Pogovor o vsebinski strani (stran ne obstaja) [t]" accesskey="t"><span>Pogovor</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Spremeni različico jezika" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Pogledi"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Modul:Buffer"><span>Preberi</span></a></li><li id="ca-viewsource" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Modul:Buffer&action=edit" title="Ta stran je zaščitena. Ogledate si lahko njeno izvorno kodo. [e]" accesskey="e"><span>Izvorno besedilo</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Modul:Buffer&action=history" title="Prejšnje redakcije te strani [h]" accesskey="h"><span>Zgodovina</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Orodja strani"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Orodja" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Orodja</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Orodja</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">prestavi v stransko letvico</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">skrij</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="Več možnosti" > <div class="vector-menu-heading"> Dejanja </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Modul:Buffer"><span>Preberi</span></a></li><li id="ca-more-viewsource" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Modul:Buffer&action=edit"><span>Izvorno besedilo</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Modul:Buffer&action=history"><span>Zgodovina</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> Splošno </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Posebno:KajSePovezujeSem/Modul:Buffer" title="Seznam vseh strani, ki se povezujejo sem [j]" accesskey="j"><span>Kaj se povezuje sem</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Posebno:RecentChangesLinked/Modul:Buffer" rel="nofollow" title="Zadnje spremembe na straneh, s katerimi se povezuje ta stran [k]" accesskey="k"><span>Povezane spremembe</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Posebno:PosebneStrani" title="Seznam vseh posebnih strani [q]" accesskey="q"><span>Posebne strani</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Modul:Buffer&oldid=5602693" title="Trajna povezava na to redakcijo strani"><span>Trajna povezava</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Modul:Buffer&action=info" title="Več informacij o tej strani"><span>Podatki o strani</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Posebno:UrlShortener&url=https%3A%2F%2Fsl.wikipedia.org%2Fwiki%2FModul%3ABuffer"><span>Pridobi skrajšani URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Posebno:QrCode&url=https%3A%2F%2Fsl.wikipedia.org%2Fwiki%2FModul%3ABuffer"><span>Prenesi kodo QR</span></a></li> </ul> </div> </div> <div id="p-electronpdfservice-sidebar-portlet-heading" class="vector-menu mw-portlet mw-portlet-electronpdfservice-sidebar-portlet-heading" > <div class="vector-menu-heading"> Natisni/izvozi </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="electron-print_pdf" class="mw-list-item"><a href="/w/index.php?title=Posebno:DownloadAsPdf&page=Modul%3ABuffer&action=show-download-screen"><span>Prenesi kot PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="javascript:print();" rel="alternate" title="Različica te strani za tisk [p]" accesskey="p"><span>Različica za tisk</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> V drugih projektih </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Module:Buffer" hreflang="en"><span>Wikimedijina zbirka</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q19967589" title="Povezava na ustrezni predmet v podatkovni shrambi [g]" accesskey="g"><span>Predmet v Wikipodatkih</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Orodja strani"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Videz"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Videz</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">prestavi v stransko letvico</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">skrij</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">Iz Wikipedije, proste enciklopedije</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="sl" dir="ltr"><style data-mw-deduplicate="TemplateStyles:r6309531">.mw-parser-output .ombox{margin:4px 0;border-collapse:collapse;border:1px solid #a2a9b1;background-color:var(--background-color-neutral-subtle,#f8f9fa);box-sizing:border-box;color:var(--color-base,#202122)}.mw-parser-output .ombox.mbox-small{font-size:88%;line-height:1.25em}.mw-parser-output .ombox-speedy{border:2px solid #b32424;background-color:#fee7e6}.mw-parser-output .ombox-delete{border:2px solid #b32424}.mw-parser-output .ombox-content{border:1px solid #f28500}.mw-parser-output .ombox-style{border:1px solid #fc3}.mw-parser-output .ombox-move{border:1px solid #9932cc}.mw-parser-output .ombox-protection{border:2px solid #a2a9b1}.mw-parser-output .ombox .mbox-text{border:none;padding:0.25em 0.9em;width:100%}.mw-parser-output .ombox .mbox-image{border:none;padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .ombox .mbox-imageright{border:none;padding:2px 0.9em 2px 0;text-align:center}.mw-parser-output .ombox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ombox .mbox-invalid-type{text-align:center}@media(min-width:720px){.mw-parser-output .ombox{margin:4px 10%}.mw-parser-output .ombox.mbox-small{clear:right;float:right;margin:4px 0 4px 1em;width:238px}}body.skin--responsive .mw-parser-output table.ombox img{max-width:none!important}@media screen{html.skin-theme-clientpref-night .mw-parser-output .ombox-speedy{background-color:#310402}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .ombox-speedy{background-color:#310402}}</style><table class="plainlinks ombox ombox-protection" role="presentation"><tbody><tr><td class="mbox-image"><span typeof="mw:File"><a href="/wiki/Slika:Full-protection-shackle.svg" class="mw-file-description" title="Stran zaščiten/a"><img alt="Stran zaščiten/a" src="//upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/40px-Full-protection-shackle.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/60px-Full-protection-shackle.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/80px-Full-protection-shackle.svg.png 2x" data-file-width="512" data-file-height="512" /></a></span></td><td class="mbox-text"><b>Ta modul/a je trenutno <a href="/w/index.php?title=Pomo%C4%8D:Za%C5%A1%C4%8Dita&action=edit&redlink=1" class="new" title="Pomoč:Zaščita (stran ne obstaja)">zaščiten/a</a> pred urejanjem.</b><br />Glej <a href="/wiki/Wikipedija:Pravila_za%C5%A1%C4%8Dite_strani" title="Wikipedija:Pravila zaščite strani">politiko zaščite</a> in <a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Posebno%3ALog&page=Modul%3ABuffer&type=protect">dnevnik zaščite</a> za več informacij. O morebitnih spremembah lahko razpravljate na <a href="/w/index.php?title=Pogovor_o_modulu:Buffer&action=edit&redlink=1" class="new" title="Pogovor o modulu:Buffer (stran ne obstaja)">pogovorni strani</a>, <span class="plainlinks"><a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Pogovor_o_modulu%3ABuffer&preload=Predloga%3APo%C5%A1lji+zahtevo+za+urejanje%2Fpreload&action=edit&section=new&editintro=Predloga%3AEdit+protected%2Feditintro&preloadtitle=Zahteva+za+urejanje+dne+25.+november+2024&preloadparams%5B%5D=edit+fully-protected&preloadparams%5B%5D=Modul%3ABuffer">oddate zahtevo za urejanje</a></span>, ali zaprosite <a href="/wiki/Wikipedija:Administratorji" title="Wikipedija:Administratorji">administratorja</a> ali <a href="/w/index.php?title=Wikipedija:Urejevalec_predlog&action=edit&redlink=1" class="new" title="Wikipedija:Urejevalec predlog (stran ne obstaja)">urejevalca predlog</a> za dovoljenje za urejanje, če je <a href="/wiki/Pomo%C4%8D:Manj%C5%A1e_urejanje" title="Pomoč:Manjše urejanje">nekontroverzno</a> in podprto s <a href="/wiki/Wikipedija:Soglasje" title="Wikipedija:Soglasje">soglasjem</a>. <a href="/wiki/Wikipedija:Predlogi_za_za%C5%A1%C4%8Dito_strani" title="Wikipedija:Predlogi za zaščito strani">Zaprosite</a> lahko tudi za odstranjenje zaščite.</td></tr></tbody></table><div id="template-documentation" class="template-documentation iezoomfix"><div style="padding-bottom: 3px; border-bottom: 1px solid #aaa; margin-bottom: 1ex;"><span style="font-size: 150%"><span typeof="mw:File"><span><img alt="Documentation icon" src="//upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Template-info.png/50px-Template-info.png" decoding="async" width="50" height="22" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Template-info.png/75px-Template-info.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Template-info.png/100px-Template-info.png 2x" data-file-width="706" data-file-height="316" /></span></span> Dokumentacija modula</span><span class="mw-editsection plainlinks" id="doc_editlinks">[<a href="/wiki/Modul:Buffer/dok" title="Modul:Buffer/dok">predogled</a>] [<a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/dok&action=edit">uredi</a>] [<a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/dok&action=history">zgodovina</a>] [<span class="noprint plainlinks purgelink"><a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer&action=purge"><span title="Osveži to stran">osveži</span></a></span>]</span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r6309531"><table class="plainlinks ombox ombox-notice" role="presentation"><tbody><tr><td class="mbox-image"><span typeof="mw:File"><span><img alt="Ready for use" src="//upload.wikimedia.org/wikipedia/commons/thumb/0/03/Green_check.svg/40px-Green_check.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/0/03/Green_check.svg/60px-Green_check.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/0/03/Green_check.svg/80px-Green_check.svg.png 2x" data-file-width="600" data-file-height="600" /></span></span></td><td class="mbox-text">Ta modul je ocenjen kot <a href="/wiki/Kategorija:Moduli_za_splo%C5%A1no_uporabo" title="Kategorija:Moduli za splošno uporabo">pripravljen za splošno uporabo</a>. Dosegel je zrelo obliko in naj bi bil razmeroma brez napak ter pripravljen za uporabo, kjer je to primerno. Lahko ga omenite na straneh pomoči in v drugih virih o Wikipediji kot možnost za učenje novih uporabnikov. Da bi zmanjšali obremenitev strežnikov in slab izhod, ga je treba izboljšati s <a href="/w/index.php?title=Wikipedija:Peskovnik_in_testni_primeri_predloge&action=edit&redlink=1" class="new" title="Wikipedija:Peskovnik in testni primeri predloge (stran ne obstaja)">testiranjem v peskovniku</a>, namesto ponavljajočega se urejanja poskusov in napak.</td></tr></tbody></table> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r6309531"><table class="plainlinks ombox ombox-content" role="presentation"><tbody><tr><td class="mbox-image"><span typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Ambox_important.svg/40px-Ambox_important.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Ambox_important.svg/60px-Ambox_important.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Ambox_important.svg/80px-Ambox_important.svg.png 2x" data-file-width="40" data-file-height="40" /></span></span></td><td class="mbox-text"><b>Predloga se uporablja na <a href="/wiki/Posebno:NajboljPovezanePredloge" title="Posebno:NajboljPovezanePredloge">številnih straneh</a>.</b><br />Z urejanjem te predloge lahko zelo obremenite strežnike, zato pred uvedbo vse spremembe, ki jih želite uvesti, preizkusite na njenih podstraneh (<a href="/w/index.php?title=Modul:Buffer/peskovnik&action=edit&redlink=1" class="new" title="Modul:Buffer/peskovnik (stran ne obstaja)">/peskovnik</a> oziroma <a href="/w/index.php?title=Modul:Buffer/testniprimeri&action=edit&redlink=1" class="new" title="Modul:Buffer/testniprimeri (stran ne obstaja)">/testniprimeri</a>) ali na svojih lastnih podstraneh. Preizkusite jih lahko tudi v posebnem <a href="/wiki/Predloga:Peskovnik_za_predloge" title="Predloga:Peskovnik za predloge">peskovniku za predloge</a>. Preizkušene spremembe se lahko v predlogo dodajo z enim samim urejanjem. Preden predlogo spremenite, se o spremembah rajši pogovorite na <a href="/w/index.php?title=Pogovor_o_modulu:Buffer&action=edit&redlink=1" class="new" title="Pogovor o modulu:Buffer (stran ne obstaja)">njeni pogovorni strani</a>.</td></tr></tbody></table> <style data-mw-deduplicate="TemplateStyles:r6032236">@media all and (max-width:720px){body.skin-minerva .mw-parser-output .tocright{display:none}.mw-parser-output .tocright{width:100%!important}}@media all and (min-width:720px){.mw-parser-output .tocright{float:right;clear:right;width:auto;margin:0 0 0.5em 1em}.mw-parser-output .tocright-clear-left{clear:left}.mw-parser-output .tocright-clear-both{clear:both}.mw-parser-output .tocright-clear-none{clear:none}}</style><div class="tocright"><meta property="mw:PageProp/toc" /></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r6309531"><table class="plainlinks ombox ombox-notice" role="presentation"><tbody><tr><td class="mbox-image"><span typeof="mw:File"><span><img alt="Zaščiten" src="//upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/40px-Full-protection-shackle.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/60px-Full-protection-shackle.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/4/44/Full-protection-shackle.svg/80px-Full-protection-shackle.svg.png 2x" data-file-width="512" data-file-height="512" /></span></span></td><td class="mbox-text">Ta modul je <a href="/wiki/Kategorija:Moduli_odvisni_od_za%C5%A1%C4%8Dite_strani" title="Kategorija:Moduli odvisni od zaščite strani">odvisen od zaščite strani</a>. Je <a href="/wiki/Wikipedija:Predloge_visokega_tveganja" title="Wikipedija:Predloge visokega tveganja">zelo viden modul</a>, ki ga uporabljajo številne strani, ali pa je pogosto <a href="/wiki/Wikipedija:Substitucija_predlog" title="Wikipedija:Substitucija predlog">substituiran</a>. Ker bi vandalizem ali napake vplivale na številne strani in bi lahko celo trivialno urejanje povzročilo veliko obremenitev strežnikov, je <a href="/wiki/Wikipedija:Pravila_za%C5%A1%C4%8Dite_strani" title="Wikipedija:Pravila zaščite strani">zaščiten</a> pred urejanjem.</td></tr></tbody></table> <p>This was originally developed to optimize string concatenation as a helper method within <a href="/wiki/Modul:Asbox" title="Modul:Asbox">Module:Asbox</a>, but has been generalized for all modules. </p><p>The interface for <a href="#Buffer_object">Module:Buffer objects</a> is similar to that of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> objects in that you may build complex strings with independent child nodes. In most cases, you may use Buffer objects like a normal string, including using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">..</code> operator. See also: <a href="#String,_mw.ustring,_and_mw.text_libraries">#String, mw.ustring, and mw.text libraries</a> </p><p>Additionally, there are several specialized forms and extended objects, described further in their respective sections: </p> <dl><dd><table> <tbody><tr> <td><div style="margin:0; column-width: 15em; -moz-column-width: 15em; -webkit-column-width: 15em; width:49em;"> <ul><li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="#_G_object">_G (callable)</a></li></ul> </div> </td></tr></tbody></table></dd></dl> <p>Last but not least, this module has an ordered <a href="#require'Module:Buffer'._pairs">__pairs</a> which can be more thorough than <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. (Even reads nil keys!) The <span title="This is a bad Star Trek joke">logical uniqueness</span> of this iterator may be reason enough to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> Module:Buffer. </p> <div class="mw-heading mw-heading2"><h2 id="Usage">Usage</h2></div> <p><span class="anchor" id="module"></span><span class="anchor" id="initialize"></span> </p> <div class="mw-heading mw-heading3"><h3 id="require'Module:Buffer'"><span id="require.27Module:Buffer.27"></span>require'Module:Buffer'</h3></div> <pre><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </pre> <p>Creates a new Module:Buffer object when the module returned by <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> is called as a function—i.e., there is no 'main'. </p><p>Because <span title="i.e. never accept arguments"><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></span> are a <a href="/w/index.php?title=Pet_peeve&action=edit&redlink=1" class="new" title="Pet peeve (stran ne obstaja)">pet peeve</a> of this developer, this forwards arguments to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>; if that op is not desired, you may chain a Buffer object function directly to the module and the self-action will be redirected to a new Buffer object—i.e <a href="#Buffer:_inHTML"><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">:</span><span class="n">_inHTML</span><span class="s1">'table'</span></code></a> is equivalent to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">():</span><span class="n">_inHTML</span><span class="s1">'table'</span></code>.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>note 1<span class="cite-bracket">]</span></a></sup> </p><p>The global variable <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> is "magic" when passed as the first arg. Such enables the <a href="#Global_functions">global functions</a> and, if followed by a <code>name</code> string, will declare the new Buffer with that name in the global scope. If the argument following <i>name</i> is a table with no metatable, it and any other <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> are forwarded to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>; otherwise, as long as the first vararg is not nil or false, this passes them to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>note 2<span class="cite-bracket">]</span></a></sup> The _G passed may also gain a __call <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> (details at <a href="#G_object">_G object</a>). </p><p><span class="anchor" id="recycling"></span> As a final note, if you <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> text from a module which returns a Buffer object, it may be more efficient to create a new Buffer via chaining <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> after a require statement for the other module and use <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> at the point where you would append the required text. (Best add <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="c1">--:_in == indirect require Module:Buffer</span></code> so future editors won't hunt for <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kr">function</span> <span class="p">...:</span><span class="nf">_in</span></code> at the other module) </p> <div class="mw-heading mw-heading3"><h3 id="Basic_functions">Basic functions</h3></div> <p><span class="anchor" id="Buffer"></span> </p> <div class="mw-heading mw-heading4"><h4 id="Buffer_object">Buffer object</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p> <div class="dablink">See also <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> for advanced string conversion.</div> <p>Get a Buffer as a <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> via a function call on the Buffer <i>object</i> (as opposed to <a href="#require'Module:Buffer'">a call on the <i>module</i></a>). This is basically shorthand for <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, or, with no args, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. However, if this Buffer is in <a href="#raw">raw mode</a><sup id="cite_ref-raw_3-0" class="reference"><a href="#cite_note-raw-3"><span class="cite-bracket">[</span>note 3<span class="cite-bracket">]</span></a></sup> or contains at least one <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> index, this reconstructs the Buffer by creating a new table, coercing it contents to strings and appending them sequentially to the temporary "buffer" via <code>new-<a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></code> (or a similar process). </p><p>Unconventionally, any <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>-type position passed as <code>i</code> or <code>j</code> are treated as <i>relative to length</i>; that is, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is equivalent to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> (which obviates the need to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> <i>Buffer</i> just to use the <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>). Moreover, unlike table.concat, this automatically adjusts numerical<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>note 4<span class="cite-bracket">]</span></a></sup> positions to be within the range of the lowest and greatest indicies. </p><p>Note you may append a Buffer object without tostring coercion to an <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> object via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> (though not mw.html:wikitext because of type checking). </p> <div class="mw-heading mw-heading5"><h5 id="Buffer.last_concat">Buffer.last_concat</h5></div> <p>When strung without a (<a href="#valid">valid</a>) <code>sep</code>, the result is cached at <code>Buffer.last_concat</code>. Until purged, future calls to return that Buffer as a string will return this index instead.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>note 5<span class="cite-bracket">]</span></a></sup> </p><p>This should clear automatically whenever a Buffer object function changes the contents of a Buffer. You may manually purge the cache by setting this key to nil, as well as by passing nothing to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:">Buffer:_</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p> <div class="dablink">See also <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> for a faster, simpler version of this op.</div> <p>Appends a value to the Buffer. In rough terms, <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="s1">'string1'</span><span class="p">:</span><span class="n">_</span><span class="s1">'string2'</span></code> is the same as <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span> <span class="o">=</span> <span class="n">Buffer</span><span class="o">..</span><span class="s1">'string1'</span><span class="o">..</span><span class="s1">'string2'</span></code>. (It may help to imagine <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">:_</code> as a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">..</code> that has stood up and is now casting a shadow.) <span class="anchor" id="valid"></span><span class="anchor" id="invalid"></span><span class="anchor" id="no-op"></span> </p><p>If passed an <i>invalid</i> <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">value</code> listed below, this is a no-op: </p> <ul><li><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></li> <li><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></li> <li>empty <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, or any table such that <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> returns an empty string (or nil/false)</li> <li><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> without a __tostring metamethod and which <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">table</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code> is nil or false</li></ul> <p>A table with no __tostring will pass through <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> before insertion. An <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> may be thrown if the table would cause table.concat to error. (Use <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> instead for such tables.) </p><p>When passed <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> of type <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, the argument is identical to <i>pos</i> for <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. In fact, assuming a <a href="#valid">valid value</a>, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is exactly the same as <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>Just like with the position arguments of <a href="#Buffer">Buffer()</a>, any <i>pos</i> of type <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> would be treated as relative to length. <span class="anchor" id="raw"></span> </p><p>Set <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">raw</code> to true to force append a <i>value</i> without tostring coercion, including <a href="#no-op">invalid</a> values. If given only two (non-self) arguments with the second being a boolean, then the second is read as <i>raw</i> instead. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_nil">Buffer:_nil</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Removes the value buffered at <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code>. As with <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, a string <i>pos</i> string is treated as <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">#</span><span class="n">Buffer</span> <span class="o">+</span> <span class="n">pos</span></code>. </p><p>If a non-boolean <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">replacement</code> is provided, then it will replace the value indexed at <i>pos</i>. Passing a boolean as the second argument is a no-op. </p><p>When <i>replacement</i> is nil, the op is basically <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. As with the positional arguments of other Buffer methods, any numerical string <i>pos</i> is added to length, such that <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> removes the last item. Note the only type check on replacement is a direct comparison to both booleans (nil is implied). Any other type, including strings, sets the Buffer to <a href="#raw">raw mode</a>. </p><p>A <i>pos</i> that is omitted, nil, or false has the same effect as though <code>'0'</code> (or <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>) were passed. Given only one non-numerical argument which evaluates true but <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> would return it as nil, this treats it as though it were passed as the second. If passed a non-numerical <i>pos</i> with any other argument, including nil, this is effectively a no op (though may still purge the <a href="#Buffer.last_concat">cache</a>). </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_all">Buffer:_all</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Takes a table <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">value</code>, iterates through all number keys <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, appending each <a href="#valid">valid</a> value to the end of the Buffer. In contrast to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, this starts at the most negative key (down to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>) and ends at the most positive index, continuing through any nil keys and includes <a href="/w/index.php?title=Double-precision_floating-point_format&action=edit&redlink=1" class="new" title="Double-precision floating-point format (stran ne obstaja)">non-integer number keys</a>. </p><p>A table <i>value</i> that has no metatable will have its contents iterated by this function before moving on to the next value. All other data types are processed by <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. <span class="anchor" id="nanKeys"></span> </p><p>By default, this ignores non-number keys unless <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">nanKeys</code> evaluates true. If so, non-number keys are processed after number keys. Keep in mind such keys are iterated in <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> order, though an order may be imposed by wrapping each pair in a table indexed at a number key. </p><p>If given a <code><i>value</i> = <i>pos</i></code> pair, defined as a number or number string indexed at a non-number key, then they will be passed as the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">value</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> arguments for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. Thus, </p> <dl><dd><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></dd></dl> <p>produces the same result as: </p> <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="mi">1</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="mi">2</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="kr">if</span> <span class="n">variable</span> <span class="kr">then</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="kr">else</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="s1">'four'</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="s1">'zero'</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span><span class="c1">--vs :_all{four='1',zero=1}; less redundant would be</span> <span class="kr">end</span> <span class="c1">-- :_all{'four',zero=1}, but that doesn't demo string numbers</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="s1">'... done'</span> <span class="c1">--returns "1234... done" if variable evaluates true or "zero123four... done" if false</span> </pre></div> </td></tr></tbody></table></dd></dl> <p>If a non-number key points to a value that cannot be coerced into a <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> then the pair may be treated as <code><i>functionName</i> = <i>args</i></code>, when <i>functionName</i> matches a Buffer object function and <i>args</i> is not boolean. If <i>args</i> is such that <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">value</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code> evaluates true, then this will pass the return of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> to the named function; otherwise, the value is passed as is.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>note 6<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_in">Buffer:_in</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Passes any arguments to <a href="#require'Module:Buffer'">Module:Buffer</a> to create a new Buffer object, sets an external reference to the parent Buffer and returns the child.<sup id="cite_ref-in-dependents_7-0" class="reference"><a href="#cite_note-in-dependents-7"><span class="cite-bracket">[</span>note 7<span class="cite-bracket">]</span></a></sup> </p><p>This does <u>not</u> append the child to the parent. (See <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>) </p><p>Also, be aware that Buffer parent references are <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. Thus, if you were to (re-)set a local variable that is currently set to the parent, such could trigger immediate garbage collection on the parent. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_out">Buffer:_out</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p><a href="#Buffer_object">Joins a Buffer</a> with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">sep</code> and appends result to its parent, which is returned. If no parent is found, this is a no-op and returns the same Buffer. </p><p>When given two or more arguments, this reads the first as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">ops</code>—the number of :_out() operations to perform.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>note 8<span class="cite-bracket">]</span></a></sup> This applies the first <i>sep</i> in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">sep-list</code> for the current Buffer, the second for its parent, the third for its grandparent, and so on. </p><p>If the last item is a <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, then any <i>nil</i> in <i>sep-list</i> default to <code><i>table</i>[1]</code>; any <i>false</i> mean "no-sep".<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>note 9<span class="cite-bracket">]</span></a></sup> The table may be the second arg (i.e. <i>sep-list</i> may be omitted). If it has other keys, then <i>table[n]</i> would apply instead of <i>table[1]</i>, making these synonymous:<br /> <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p><p>The number <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">0</span></code> is "magic" when passed as the first arg (even by itself), joining and appending to the same Buffer <i>after</i> it has been <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. This is the only method by which a Buffer in <a href="#raw">raw mode</a> may lose that status. Parent references are preserved. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_str">Buffer:_str</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Joins a Buffer with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">sep</code> and returns the string. </p><p>This uses the same helper method as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> to handle multiple arguments, with which, if provided, this creates a new temporary Buffer to which this appends the results of the number of generations specified by <code>ops</code>, with each ancestor in front of its descendants. This then performs one additional concat op using the <i>sep</i> at <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">ops</span> <span class="o">+</span> <span class="mi">1</span></code> and returns the result. If a parent-less Buffer is reached before <i>ops</i>, then the sep that follows its op number will separate the generations. </p><p>When no <a href="#valid">valid</a> <i>sep</i> is given, this returns a string identical to what would append to the next ancestor, if those arguments were passed to Buffer:_out instead and one additional :_out() op performed. </p><p>However, because this does not actually append child Buffers to their parent, the result may differ where this would insert the sep at <i>ops + 1</i> and Buffer:_out would place the parent's sep between it and its child instead. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_cc">Buffer:_cc</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Nils all keys of the table referenced by <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">clear</code> and unsets its metatable. If <i>clear</i> evaluates false, this simply purges the cache at <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p><p>If given a table to <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">copy</code>, this will duplicate all key-value pairs of <i>copy</i> into <i>clear</i>, cloning any table value recursively via <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_cc</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span></code>. This returns the Buffer unless passed the number <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">0</span></code> as <i>clear</i>, which causes this to create a new table and return that instead. Passing <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kc">true</span></code> as <i>copy</i> is equivalent to passing the Buffer itself. If <i>copy</i> is not a table, then it will be set as the first item in <i>clear</i> as long as it is not <i>false</i>. </p><p>While this may resemble <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, there are several differences, namely that this: </p> <ul><li>Gives <i>clear</i> the same metatable as <i>copy</i> (or sets <code>meta</code>, if given) as opposed to a "clone" of the metatable.</li> <li>Conserves <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> attribute (though empty strings may replace some nil keys<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>note 10<span class="cite-bracket">]</span></a></sup>)</li> <li><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luarefs</a> values and iterates without invoking any __pairs <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>.</li> <li>Includes Buffer parent and <a href="#raw">raw</a> attributes (stored externally)</li></ul> <p>To obtain the key-value pairs left as empty strings in the previous copy op in a table, simply call this again such with value such that <code>rawequal(clear, copy)</code> is true; call :getParent() on this table returns <i>clear</i> (useful after leeaving the local scope which referenced <i>clear</i>). </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_parent">Buffer:_parent</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p> <div class="dablink">To skip generations without breaking the Buffer chain, see <a href="#global_functions">#global functions</a>.</div> <p>Resembling the reverse of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, this calls <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> on the Buffer's parent with the arguments given and appends the strung ancestor(s) to the current Buffer, which is returned. </p><p>The parent is unaffected by this operation and may still be retrieved via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> or re-appended again with this function. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:getParent">Buffer:getParent</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p> <div class="dablink">Note that there is no 'getChild' method<sup id="cite_ref-in-dependents_7-1" class="reference"><a href="#cite_note-in-dependents-7"><span class="cite-bracket">[</span>note 7<span class="cite-bracket">]</span></a></sup></div> <p>Returns parent Buffer, or, if none exists, creates a new Buffer and returns it as the adopted parent. As with <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, this does not automatically append the adoptive child to the new parent. </p><p>Pass a non-false <code>value</code> and this performs an op on the parent object. </p><p>If passed anything other than <i>value</i> (including nil), this requires that <i>value</i> names a function available to the parent object, which this calls and forwards the additional <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p><p>Pass only a table <i>value</i> which has no metatable and this forwards <i>value</i> to the parent which calls <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p><p>Given only a string starting with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">_</code> and naming a parent function, this calls it on the parent without arguments. Any other <a href="#valid">valid</a> singular argument <a href="#Buffer:">appends</a> to the end of the parent Buffer.<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>note 11<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:killParent">Buffer:killParent</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Unsets Buffer parent reference. </p><p>If passed any args, they are forwarded to the current parent, if one exists, via Buffer:getParent as a "parting gift". In either case, returns the current Buffer. </p><p>This is not necessary for <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> since Buffer parent references are weak. Rather, use this when it is desirable to assign a new parent via Buffer:getParent or, for example, to prevent the inclusion of an ancestor when passing <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> as <i>ops</i> for functions such as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> (more useful when <a href="#recycling">recycling Module:Buffer</a> from another Module). </p> <div class="mw-heading mw-heading3"><h3 id="Stream_mode">Stream mode</h3></div> <div class="mw-heading mw-heading4"><h4 id="Buffer:stream">Buffer:stream</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Switches a Buffer to <a href="#Stream-Buffer">stream mode</a>. While streaming, the __call metamethod will append values to the end of the Buffer instead of the <a href="#Buffer_object">usual op</a>. </p><p>Aside from that, there is only one other function: <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. Any args passed to Buffer:stream are forwarded to that function for a reason that should be evident when you finish reading this very short section. </p><p>No special action is needed to exit this mode. The normal call to string op is restored upon the use of any regular Buffer function or any operation which coerces the Buffer into a string (e.g. the <code>..</code> operator). </p><p><span class="anchor" id="Stream-Buffer"></span> </p> <div class="mw-heading mw-heading4"><h4 id="Stream-Buffer_object">Stream-Buffer object</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a><span class="anchor" id="streaming"></span><span class="anchor" id="calling_a_Buffer:stream"></span> </p><p>Stream-Buffer objects accept only one argument which they append if <a href="#valid">valid</a>. That is, the op is a streamlined version of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> sans the <i>pos</i> and <i>raw</i> args. </p><p>This also exploits <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> to append a series of string literals (and tables) with nothing between them (or only <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> if desired). </p><p>For example, both A and B will produce identical strings: </p> <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">local</span> <span class="n">A</span> <span class="o">=</span> <span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">:</span><span class="n">stream</span><span class="s1">'A string of text may flow''with nothing between each string'</span> <span class="s1">'or perhaps only a space'</span> <span class="s1">'or even tab and line-break characters''and continue to append individually''for use with a joiner'</span> <span class="kd">local</span> <span class="n">B</span> <span class="o">=</span> <span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">:</span><span class="n">_</span><span class="s1">'A string of text may flow'</span><span class="p">:</span><span class="n">_</span><span class="s1">'with nothing between each string'</span> <span class="p">:</span><span class="n">_</span> <span class="s1">'or perhaps only a space'</span> <span class="p">:</span><span class="n">_</span><span class="s1">'or even tab and line-break characters'</span><span class="p">:</span><span class="n">_</span><span class="s1">'and continue to append individually'</span><span class="p">:</span><span class="n">_</span><span class="s1">'for use with a joiner'</span> <span class="n">mw</span><span class="p">.</span><span class="n">log</span><span class="p">(</span><span class="n">A</span><span class="o">==</span><span class="n">B</span><span class="p">,</span> <span class="n">A</span><span class="p">:</span><span class="n">_str</span><span class="s1">' '</span><span class="p">)</span> <span class="kc">true</span> <span class="n">A</span> <span class="n">string</span> <span class="n">of</span> <span class="n">text</span> <span class="n">may</span> <span class="n">flow</span> <span class="n">with</span> <span class="n">nothing</span> <span class="n">between</span> <span class="n">each</span> <span class="n">string</span> <span class="ow">or</span> <span class="n">perhaps</span> <span class="n">only</span> <span class="n">a</span> <span class="n">space</span> <span class="ow">or</span> <span class="n">even</span> <span class="n">tab</span> <span class="ow">and</span> <span class="n">line</span><span class="o">-</span><span class="kr">break</span> <span class="n">characters</span> <span class="ow">and</span> <span class="n">continue</span> <span class="n">to</span> <span class="n">append</span> <span class="n">individually</span> <span class="kr">for</span> <span class="n">use</span> <span class="n">with</span> <span class="n">a</span> <span class="n">joiner</span> </pre></div> </td></tr></tbody></table></dd></dl> <div class="mw-heading mw-heading4"><h4 id="Stream-Buffer:each">Stream-Buffer:each</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Appends an undetermined number of <a href="#valid">valid</a> values to the Buffer object.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>note 12<span class="cite-bracket">]</span></a></sup> </p><p>If the above line gives you <a href="/w/index.php?title=D%C3%A9j%C3%A0_vu&action=edit&redlink=1" class="new" title="Déjà vu (stran ne obstaja)">Déjà vu</a>, that is because it is drawn from <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. However, unlike mw.html:wikitext, this does <i>not</i> stop at the first <i>nil</i> value.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>note 13<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="HTML_library_extension">HTML library extension</h2></div> <p>Upon the first call to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, Module:Buffer clones the <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, adding Module:Buffer's __eq and __concat metamethods along with a few additional functions. </p><p>Objects with this modified metatable are referred to as <b>Buffer-HTML objects</b>. Yet, though dressed in bells and whistles, they are only named with <i>Buffer</i> as an adverb since they lack most Buffer object functions. </p><p>In contrast, the <b>Element-Buffer</b> (returned by <a href="#Buffer-HTML">the function call on a Buffer-HTML object</a>) is a true Buffer object with specialized "tricks" allowing complex structures to be built via both mw.html and Buffer object methods as well as through a <a href="#Element-Buffer:_add">builder that perhaps marries the best of both worlds</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Buffer_functions_for_HTML">Buffer functions for HTML</h3></div> <div class="mw-heading mw-heading4"><h4 id="Buffer:_inHTML">Buffer:_inHTML</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Accepts the same parameters as <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> to create and return a <a href="#Buffer-HTML">modified mw.html object</a>. As with <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, this does <i>not</i> append the child object to the parent Buffer and instead sets a Buffer-style parent reference. </p><p>An exception to the above is when chaining this to an <a href="#Element-Buffer"><i>Element-</i>Buffer</a> and such produces a <i>selfClosing</i> tag; when both conditions are met, this appends the tag and returns to the same Buffer.<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>note 14<span class="cite-bracket">]</span></a></sup> </p><p>Unlike mw.html.create, if <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">args</code> has keys other than <code>args.parent</code> and <code>args.selfClosing</code>, it will pass for further processing through <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> (a cousin of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> that handles mw.html functions). Moreover, if passed a table where mw.html.create expects <i>tagName</i>, this treats it as <i>args</i> instead. </p><p>Finally, this does not automatically set the <code>mw.html.parent</code> reference, making this an alternative to mw.html:tag </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:getHTML">Buffer:getHTML</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Available only after <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is used the first time. <span class="anchor" id="lastHTML"></span> </p><p>Accepts the same arguments as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, however this instead return the last Buffer-HTML object ("lastHTML") created, or, if available, the lastHTML passed to any of the following functions: </p> <ul><li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></li> <li><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> (except when passed <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">0</span></code>)</li></ul> <div class="mw-heading mw-heading4"><h4 id="Buffer:_html">Buffer:_html</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Available only after <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is used the first time. </p><p>This (re-)appends the <a href="#lastHTML">last Buffer-HTML object</a> to the current Buffer object. The <code>raw</code> and <code>pos</code> args are generally the same as those in <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p><p>When called with no arguments on an <i>Element-</i>Buffer, this appends lastHTML without <a href="#raw">string coercion</a>. Be warned however that if the Element-Buffer belongs to lastHTML or one of its tags, such will cause an <a href="/w/index.php?title=Infinite_loop&action=edit&redlink=1" class="new" title="Infinite loop (stran ne obstaja)">infinite loop</a>, which can be avoided by passing an explicit nil to append lastHTML as a string.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>note 15<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="HTML_object_functions">HTML object functions</h3></div> <p>Buffer-HTML objects may be used like any mw.html object. (In fact, merely replacing <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">mw.html.create</code> with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">require'Module:Buffer':_inHTML</code> in an existing Module should produce the same output.) </p><p><span class="anchor" id="wrapper"></span> Most mw.html functions are unchanged, except <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> are embedded in a wrapper function that checks whether they return a normal mw.html object. If so, switches the metatable to convert it to a Buffer-HTML object and sets a parent reference. <sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>note 16<span class="cite-bracket">]</span></a></sup> </p><p>As a side bonus, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">..</code> may be used on Buffer-mw.html objects directly (no <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> needed). </p><p><span class="anchor" id="Buffer-HTML"></span> </p> <div class="mw-heading mw-heading4"><h4 id="Buffer-HTML_object">Buffer-HTML object</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Call this object as a function to return its <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">.</span><span class="n">nodes</span></code> index<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>note 17<span class="cite-bracket">]</span></a></sup>, which this converts to an <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> object, granting it the same metatable as regular Module:Buffer objects (as well as several additional "tricks") and assigning the Buffer-HTML as its parent Buffer.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>note 18<span class="cite-bracket">]</span></a></sup> </p><p>This takes one argument which is forwarded to its Element-Buffer. Tables pass to the specialized HTML builder <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. All other <a href="#valid">#valid</a> values are appended to its Element-Buffer via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. </p> <table style="float:right"> <tbody><tr> <td><a href="/w/index.php?title=Predloga:TOC_tab&action=edit&redlink=1" class="new" title="Predloga:TOC tab (stran ne obstaja)">Predloga:TOC tab</a> </td></tr></tbody></table><span class="anchor" id="HTML_version"></span> <p>You cannot chain call regular Buffer functions on a Buffer-HTML object; however, since mw.html functions cannot read Buffer-style parent references, modified versions of methods that return <a href="#Buffer:_inHTML">the parent Buffer</a> are available to Buffer-HTML without having to call into the Element-Buffer. For convenience, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> is called automatically prior to the op, though after the <code>lastHTML</code> reference has been set for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>note 19<span class="cite-bracket">]</span></a></sup> </p> <dl><dd><table> <tbody><tr> <td><div style="margin:0; column-width: 15em; -moz-column-width: 15em; -webkit-column-width: 15em; width:49em;"> <ul><li><b><a href="#Buffer:getParent">:getParent</a></b></li> <li><b><a href="#Buffer:killParent">:killParent</a></b></li> <li><b><a href="#Buffer:_out">:_out</a></b> <span class="reference"><sup id="ref_html-0-out{{{3}}}">[[#note_html-0-out{{{3}}}|[0]]]</sup></span><span class="reference"><sup id="ref_html-ops-out{{{3}}}">[[#note_html-ops-out{{{3}}}|[$]]]</sup></span></li> <li><b><a href="#Buffer:_str">:_str</a></b> <span class="reference"><sup id="ref_html-0-str{{{3}}}">[[#note_html-0-str{{{3}}}|[0]]]</sup></span><span class="reference"><sup id="ref_html-ops-str{{{3}}}">[[#note_html-ops-str{{{3}}}|[$]]]</sup></span></li> <li><b><a href="#Buffer:_parent">:_parent</a></b> <span class="reference"><sup id="ref_html-parent{{{3}}}">[[#note_html-parent{{{3}}}|[^]]]</sup></span></li></ul> </div> <div style="font-size:smaller"> <p><span class="citation wikicite" id="endnote_html-0-out"><sup></sup><span class="citation wikicite" id="endnote_html-0-str"><sup>0</sup> if passed <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">0</span></code> as the first argument, these do not redirect the self-action via <code>:allDone()</code>, however, these always return a Buffer-HTML object (think <code><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></code>). <span class="citation wikicite" id="endnote_html-0-out-perm"><sup></sup>For :_out only, the "magic" number zero <i>permanently</i> consolidates <code>Buffer-HTML.nodes</code> (whether or not converted)</span> just like <code>:_out(0)</code> on a normal Buffer except it would not unset raw mode on an Element-Buffer.</span></span> </p><p><span class="citation wikicite" id="endnote_html-ops-out"><sup></sup><span class="citation wikicite" id="endnote_html-ops-str"><sup>$</sup> When passed a <a href="#valid">valid</a> sep for the first op, these temporarily<span class="reference"><sup id="ref_html-0-out-perm"><a href="#note_html-0-out-perm">[0]</a></sup></span> switch the Element-Buffer (or unconverted .nodes) with a table containing only the concatenated string before stringing the Buffer-HTML in the first op. As with the non-HTML versions, only :_out appends the string to the parent Buffer.</span></span> </p><p><span class="citation wikicite" id="endnote_html-parent"><sup>^</sup> This takes arguments for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and calls it on the <a href="#Buffer:_inHTML">parent Buffer of the HTML tree</a>, returning and appending the result to the same Buffer-HTML object. In other words, the "auto-allDone" doesn't really apply here, or at least not in the same sense as with the other functions. (As a reminder, Buffer:_inHTML does not append to the parent Buffer those Buffer-HTML objects which it returns.)</span> </p> </div> </td></tr></tbody></table></dd></dl> <p>In addition to the above, <a href="#gfuncs">global functions</a> may be available to Buffer-HTML if enabled; these functions are the same for all Module:Buffer objects—i.e. the self action is never redirected. </p> <div class="mw-heading mw-heading3"><h3 id="Element-Buffer_functions">Element-Buffer functions</h3></div> <p><span class="anchor" id="Element-Buffer"></span> </p> <div class="mw-heading mw-heading4"><h4 id="Element-Buffer_object">Element-Buffer object</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Sharing the same metatable as with regular Buffer objects, Element-Buffers concatenate the same way when <a href="#Buffer_object">called</a> to produce a string analogous to the <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a> DOM <a rel="nofollow" class="external text" href="http://www.w3schools.com/jsref/prop_html_innerhtml.asp">"innerHTML"</a> property. In other words, when strung, it is generally the contents of the Buffer-HTML object without the "outerHTML" or tag. </p><p>There are exceptions to this "innerHTML" behavior. For instance, as appended to another object via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, an Element-Buffer and its Buffer-HTML are interchangeable (though appending the former via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> only includes the inner result). </p><p>Also, using the concatenation operator <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">..</span></code> on an Element-Buffer includes its tag in a manner depending on if it is selfClosing: </p> <ul><li>For most tags, the conjoined string is placed inside the tag, e.g. <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_inHTML</span><span class="s1">'p'</span> <span class="s1">'inner text'</span> <span class="o">..</span> <span class="mi">1</span></code> returns <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="s1">'<p>inner text1</p>'</span></code>.</li> <li>For selfClosers, the <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">..</span></code> op redirects to its Buffer-HTML, e.g. insert <a href="#Element-Buffer:_add"><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">:</span><span class="n">_add</span><span class="p">{</span><span class="n">selfClosing</span><span class="o">=</span><span class="kc">true</span><span class="p">}</span></code></a> in the above example before <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">..</span> <span class="mi">1</span></code> to produce <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="s1">'<p />1'</span></code>.</li></ul> <dl><dd><div class="rellink">Več informacij: <a href="#Modified_.._operator">#Modified .. operator</a></div></dd></dl> <p>You may use most Buffer object functions normally, however if there is a <a href="#HTML_version">Buffer-HTML version</a>, it instead behaves as though chained on the <a href="#Buffer-HTML">outer HTML object</a>.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>note 20<span class="cite-bracket">]</span></a></sup> You may also chain any mw.html object function. Unless otherwise indicated, such returns a <a href="#wrapper">wrapper</a> method that merely redirects the self-action to the outside Buffer-HTML.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>note 21<span class="cite-bracket">]</span></a></sup> </p><p>As a final note, Element-Buffers are in permanent <a href="#raw">raw mode</a> since it is expected that some mw.html method (e.g. :tag and :node) may or will append non-string elements. </p> <div class="mw-heading mw-heading4"><h4 id="Element-Buffer:done">Element-Buffer:done</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>When passed nothing, this should behave just like <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> as called the "outer" HTML object—returning <code>Buffer-HTML.parent</code>, if available, or Buffer-HTML if not. </p><p>However, this has been re-designed to accept <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">ops</code>, the number of :done() operations to perform. Thus, <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">done</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span></code> is equivalent to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">HTML</span><span class="p">:</span><span class="n">done</span><span class="p">():</span><span class="n">done</span><span class="p">():</span><span class="n">done</span><span class="p">():</span><span class="n">done</span><span class="p">()</span></code>. </p><p>Pass <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">0</span></code> (zero) as <i>dones</i> to return to the Element-Buffer's direct HTML container. </p><p>Finally, keep in mind that Buffer-HTML objects use the original mw.html:done (albeit in a light <a href="#wrapper">wrapper</a>). </p> <div class="mw-heading mw-heading4"><h4 id="Element-Buffer:tag">Element-Buffer:tag</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>This uses the same helper method as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> to handle arguments and produce new Buffer-HTML objects, selectively passing <i>args</i> to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> when it contains keys not used by <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>As may be expected, this differs from Buffer:_inHTML in that this actually appends the tag and will set a mw.html-style parent reference. This also lacks the other function's "auto-done" feature for selfClosing tags. </p><p>As with the other Element-Buffer remake of an mw.html method, the features described here do not apply to the version used by Buffer-HTML objects. </p> <div class="mw-heading mw-heading4"><h4 id="Element-Buffer:_add">Element-Buffer:_add</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Takes a table as its only argument. This then thoroughly iterates all number keys from lowest<sup><a href="#endnote_skip1">†</a></sup> to highest using <a href="#MBpairs">this module's custom __pairs</a> method. Most values append as wikitext if <a href="#valid">valid</a>. If a table is indexed at a number key, this <a href="/w/index.php?title=Recursion_(computer_science)&action=edit&redlink=1" class="new" title="Recursion (computer science) (stran ne obstaja)">recursively</a> iterates the table before moving on to the next key. </p><p>After processing all number key-value pairs, this then iterates the other (non-number) keys. For those naming a <a href="#Basic_functions">core Buffer object function</a>, this selectively unpacks <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">args</code> in a manner described at <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> when that function is passed the <i>nanKey</i> parameter (excepting that this does not read numbers as <i>pos</i>, i.e. treats them the same way as strings). </p><p>This also accepts keys naming <a href="#HTML_object_functions">HTML</a> and <a href="#Global_functions">global functions</a> as well as mw.html arguments. Thus, <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">tag</span> <span class="o">=</span> <span class="s1">'br'</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">}</span></code> appends a BR tag <i>after</i> the text and <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="p">{</span><span class="n">tag</span> <span class="o">=</span> <span class="s1">'br'</span> <span class="p">},</span> <span class="s1">'text'</span><span class="p">}</span></code> appends the BR before the text. Note however that how this handles <i>args</i> for such keys depends on the particular function or argument named: </p> <dl><dd><table> <tbody><tr> <td> <div class="mw-heading mw-heading6"><h6 id="args.argName">args.<i>argName</i></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">arg</span> <span class="o">=</span> <span class="n">value</span> <span class="p">}</span></code><br /> The effect of passing <i>args</i> with keys such as <code>args.selfClosing</code> and <code>args.parent</code> is the same as though <i>args</i> were passed to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. This also takes one additional <i>arg</i>, i.e. <code>args.tagName</code>, which value replaces the original <i>tagName</i> of the HTML object (or, if false, removes the tag). </p><p>Note that these are the only keys for which a boolean <i>arg</i> would result in an op. (For Buffer object functions that do not no-op when passed only a boolean, place the boolean in an <i>args</i> table for unpacking.) </p> <div class="mw-heading mw-heading6"><h6 id="args.cssName">args.<i>cssName</i></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">cssName</span> <span class="o">=</span> <span class="n">cssValue</span> <span class="p">}</span></code><br /> A non-number <i>key</i> and <i>value</i> pair may default as the <code>cssName</code> and <code>cssValue</code> parameters for <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> when the key matches none of the three <a href="#args.argsName">argName</a> keys nor the name of any available function for Buffer and mw.html objects. </p><p>This sends non-boolean <i>cssValue</i> though <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> prior to forwarding it to mw.html:css. Because this is the default, any typoed key goes to mw.html:css as <i>cssName</i>. Names of functions not yet <a href="#loadable">loaded</a> also end up there. </p><p>For convenience, any <code>_</code> character in the key string is automatically substituted with the <code>-</code> character; thus <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">border_bottom_style</span> <span class="o">=</span></code> is equivalent to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">[</span><span class="s1">'border-bottom-style'</span><span class="p">]</span> <span class="o">=</span></code>. </p><p>The form <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">-</span><span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">css</span> <span class="o">=</span> <span class="p">{</span> <span class="n">cssName</span> <span class="o">=</span> <span class="n">cssValue</span> <span class="p">}</span> <span class="p">}</span></code> also works (or to clear a previously set value; see example at <a href="#args.htmlFunction">args.htmlFunction</a> for more details). </p><p><span class="anchor" id="args.tag"></span> </p> <div class="mw-heading mw-heading6"><h6 id="args.tag†"><span id="args.tag.E2.80.A0"></span>args.tag<sup><a href="#endnote_skip1">†</a></sup></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">tag</span> <span class="o">=</span> <span class="n">tagName</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">tag</span> <span class="o">=</span> <span class="p">{</span> <span class="n">tagName</span><span class="p">,</span> <span class="n">args</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">list</span> <span class="p">}</span> <span class="p">}</span></code><br /> Set the key <code>args.tag</code> to a string and this calls <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> with it as the <i>tagName</i> argument. This then raw inserts the returned mw.html object ("tag"), emulating the effect of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> minus parent references, which are unnecessary. </p><p>Pair the <i>args.tag</i> key with a table value and this calls mw.html.create with <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">table</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code> as <i>tagName</i> (or nil if <a href="#invalid">#invalid</a>), appending it as described above for string values, but also pointing <code>tag.parent</code> to the <a href="#Buffer-HTML">Element-Buffer's parent</a> as well as temporarily setting the tag as the parent Buffer of <code>tag.nodes</code>. This then treats tag.nodes as a <i><a href="/w/index.php?title=Pseudo&action=edit&redlink=1" class="new" title="Pseudo (stran ne obstaja)">pseudo</a>-</i>Element-Buffer, <a href="/w/index.php?title=Recursion_(computer_science)&action=edit&redlink=1" class="new" title="Recursion (computer science) (stran ne obstaja)">recursing</a> tag.nodes as "self" and the table as <i>args</i>, though only iterating keys not equal to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">1</span></code> (or less).<a href="#endnote_skip1-tag"><sup>[*]</sup></a> </p><p>Note this appends normal mw.html objects. That said, most Buffer functions named in <i>args-list</i> should still work as though the tag and <code>tag.nodes</code> were Buffer objects.<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>note 22<span class="cite-bracket">]</span></a></sup> </p><p>Upon completing a recursive iteration for args.tag, this checks if the tag is selfClosing, in which case, this sets tag.nodes to nil. Likewise, if its tagName property evaluates false, this nils tag.styles and tag.attributes. Such presumes those properties will not be modified afterwards, so use mw.html:tag outside of Element-Buffer:_add if such is not the case. </p><p><span class="anchor" id="args.done"></span> </p> <div class="mw-heading mw-heading6"><h6 id="args.done†"><span id="args.done.E2.80.A0"></span>args.done<sup><a href="#endnote_skip1">†</a></sup></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">done</span> <span class="o">=</span> <span class="n">wikitext</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">done</span> <span class="o">=</span> <span class="p">{</span> <span class="n">ops</span><span class="p">,</span> <span class="n">args</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">list</span> <span class="p">}</span> <span class="p">}</span></code><br /> Similar to args.tag, this treats the first index of the table as the <i>ops</i> argument of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. After calling that function, this then iterates all subsequent keys in a recursive call on the Element-Buffer of the Buffer-HTML object returned. </p> <div class="mw-heading mw-heading6"><h6 id="args.allDone">args.allDone</h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">allDone</span> <span class="o">=</span> <span class="n">wikitext</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">allDone</span> <span class="o">=</span> <span class="p">{</span> <span class="n">args</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">list</span> <span class="p">}</span> <span class="p">}</span></code><br /> Similar to the previous two, except that the first index is not used as an argument; thus, the entire table is iterated. </p><p><span class="anchor" id="args.globalFunction"></span> </p> <div class="mw-heading mw-heading6"><h6 id="args.globalFunction‡"><span id="args.globalFunction.E2.80.A1"></span>args.<i>globalFunction</i><sup><a href="#endnote_skip2">‡</a></sup></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">globalFunction</span> <span class="o">=</span> <span class="n">name</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">globalFunction</span> <span class="o">=</span> <span class="p">{</span> <span class="n">name</span><span class="p">,</span> <span class="n">save</span><span class="p">,</span> <span class="n">args</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">list</span> <span class="p">}</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">_B</span> <span class="o">=</span> <span class="p">{</span> <span class="n">var</span><span class="p">,</span> <span class="n">args</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">list</span> <span class="p">}</span> <span class="p">}</span></code><br /> If the <a href="#gfuncs">global functions</a> have been loaded and a key matches one, this calls the function with the first two arguments <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luarefed</a> from the paired <i>args-list</i> table. This then recursively iterates the list, excluding keys less than or equal to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">2</span></code>, with whatever object is returned as <i>self</i>. However, if the returned object has a metatable and <code>object.nodes</code> exists, the <i>self</i> will be object.nodes instead. </p><p>Because <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> takes only one argument, args._B only unpacks the first index and starts the iteration after that key. </p><p>If neither of the first two keys evaluate true, this assumes the paired value is a string for use as the <i>name</i> argument for the function matching its key.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>note 23<span class="cite-bracket">]</span></a></sup> In that case, the current call stack's <i>self</i> (an Element-Buffer or <a href="#args.tag">tag.nodes</a> if this was called indirectly) is <i>self</i> for the global function. </p> <div class="mw-heading mw-heading6"><h6 id="args.htmlFunction">args.<i>htmlFunction</i></h6></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">htmlFunction</span> <span class="o">=</span> <span class="n">object</span> <span class="p">}</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">htmlFunction</span> <span class="o">=</span> <span class="p">{</span> <span class="n">arg</span><span class="o">-</span><span class="n">list</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="n">value</span> <span class="p">}</span> <span class="p">}</span></code><br /> If args.<i>key</i> matches an <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> that does not have its own args section, this checks if the associated <i>object</i> is table. If not a table, or if <code>object.nodes</code> evaluates true, this calls the mw.html function with the object as the only argument. </p><p>For table objects without an object.nodes, this iterates the table (non-recursively), repeatedly calling the named mw.html function with one or two arguments depending on key's type in each loop. Non-number key-value pairs are both passed as arguments. For numeric indices, only the value is passed. Boolean values are a no-op. </p><p>Unlike with most implementions of <a href="#MBpairs">Module:Buffer's __pairs</a>, this first loops through <i>non-</i>number keys, followed by number keys (still ordered from lowest to highest). Thus, something like <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_add</span><span class="p">{</span> <span class="n">attr</span> <span class="o">=</span> <span class="p">{</span> <span class="s1">'width'</span><span class="p">,</span> <span class="n">width</span> <span class="o">=</span> <span class="mi">20</span> <span class="p">}</span> <span class="p">}</span></code> is equivalent to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">attr</span><span class="p">(</span> <span class="s1">'width'</span><span class="p">,</span> <span class="mi">20</span> <span class="p">):</span><span class="n">attr</span><span class="p">(</span> <span class="s1">'width'</span> <span class="p">)()</span></code>, setting then unsetting the width attribute and returning the Element-Buffer for a net no-op (though the practical purpose of such is a mystery for this developer). </p><p>For <code>args.css</code> only, this auto-replaces underscores with hypens for string keys—i.e., you may save four keystrokes/pair by typing <code>css_property =</code> instead of <code>["css-property"] =</code>. This does not apply to strings indexed at number keys. </p><p><br /> </p> <div style="font-size:smaller;"> <hr /> <p><span class="citation wikicite" id="endnote_skip1"><sup>†</sup> Unlike with tables passed directly, <a href="/w/index.php?title=Recursion_(computer_science)&action=edit&redlink=1" class="new" title="Recursion (computer science) (stran ne obstaja)">recursive</a> iterations for functions marked with <sup>†</sup> start at the smallest number greater than <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">1</span></code> instead of negative infinity.</span> </p><p><span class="citation wikicite" id="endnote_skip2"><sup>‡</sup> The iteration may start after <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">2</span></code> for some global functions.</span> </p> </div> </td></tr></tbody></table></dd></dl> <p><span class="anchor" id="loadable"></span> </p> <div class="mw-heading mw-heading2"><h2 id="Loadable_convenience_extensions">Loadable convenience extensions</h2></div> <p>The methods here are loaded on demand or depend on subroutines which need initialization. </p><p>These methods can greatly simplify the structure of the modules which employ them by doing, in a fluent manner, many tasks which may otherwise force an awkward interruption in Buffer call chains. </p><p><span class="anchor" id="gfuncs"></span> </p> <div class="mw-heading mw-heading3"><h3 id="Global_functions">Global functions</h3></div> <p>Methods such as <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> traverse a node tree in only one direction. While fine for returning to an ancestor, they do not provide navigation to a non-ancestor (often necessary for templates with co-dependent parameters). Yet, repeated breaks in call chains to set local variables for several nodes of the same branch can look choppy if not confusing for nodes many generations removed from its declaration statement.<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>note 24<span class="cite-bracket">]</span></a></sup> </p><p>Templates with several conditionally-appended nodes with similar, but not identical, parts may present another conundrum for coders who must decide between having awkward call chain interruptions to store potentially repeated components as local variables or constructing a somewhat redundant module that is more susceptible to maintenance errors by future editors who may patch one code segment but miss the sibling buried within a convoluted nesting of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>This module's global functions and added <a href="/w/index.php?title=Syntactic_sugar&action=edit&redlink=1" class="new" title="Syntactic sugar (stran ne obstaja)">syntactic sugar</a> for the <a href="#G_object">_G object</a> were formulated to simplify such node trees with multi-conditional or repeating structures by providing concise in-chain variable declaration. The extension is enabled by passing your global table to the module—either in the initial call to <a href="#initialize">require'Module:Buffer'</a> (more instructions in that section) or to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> which forwards arguments to Module:Buffer.<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>note 25<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_G">Buffer:_G</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p> <style data-mw-deduplicate="TemplateStyles:r5590687">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}</style><div role="note" class="hatnote navigation-not-searchable">Ne zamenjajte za the <a href="#G_object">§ _G object</a>, which chain call looks the same but may behave differently..</div> <p>Pass <code>name</code> and <code>save</code> to assign the object passed as <i>save</i> to a global variable via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>note 26<span class="cite-bracket">]</span></a></sup> </p><p>Pass only <i>name</i> and this substitutes <i>self</i> for <i>save</i> to assign the Buffer object to <code>_G[name]</code> instead. Give an explicit nil as <i>save</i> to unset a global. This returns the Buffer object as well as any argument given after <i>name</i>. </p><p>This is a no-op when <i>name</i> is nil or a boolean, or, when <i>save</i> (eventually) evaluates true and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> also returns true. <span class="anchor" id="metaglobal"></span> </p><p>If the named global already exists, this "backs up" the old value by moving it to the meta __index of the global table, setting a new metatable if none exists.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>note 27<span class="cite-bracket">]</span></a></sup> Retrieving the old value requires unsetting the new one via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> (more details in that section). If overwritten a third time, the first value is discarded and the second takes its place in the back up. </p><p>If a metaglobal variable exists but the global is nil, this sets the global without unsetting the metaglobal (i.e. does not back up a nil global). An exception is when this is given an explicit nil as <i>save</i> and only the metaglobal exists; thus, passing nil twice for the same <i>name</i>, unsets the key in both the global table and its metaindex. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_R">Buffer:_R</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>This <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> with the global table as the first argument and <code>name</code> and <code>save</code> as the second and third, respectively, returning the Buffer object for call chaining.<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>example 1<span class="cite-bracket">]</span></a></sup> This is a no-op if <i>name</i> is nil or a boolean. </p><p><span class="anchor" id="new_G"></span> </p> <div class="rellink">Več informacij: <a href="#new_G_object">#new_G object</a></div> <p>Note that Buffer methods use a local variable <code>new_G</code> as a proxy for the global table _G; though not a global index, the string <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="s1">'new_G'</span></code> is a "magic word" that changes the destination for future <i>save</i> for this and Buffer:_G. </p><p>Pass a table as <code>var</code> (same place as <i>save</i>) to set as the <i>new</i> new_G. Any table such that <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">var</span><span class="p">.</span><span class="n">_G</span> <span class="o">==</span> <span class="nb">_G</span></code> is treated as a (former) new_G object. This <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> of former proxies and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> with the <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> __call method on non-new_G tables. Then, this, if third parameter <code>metaindex</code> equals: </p> <ul><li>nil — backs up the current proxy as the metaindex of the next (though this no-ops if <i>var</i> equals new_G to avoid cyclical indexing).</li> <li>false — leaves the metaindex intact (replacing the current proxy without back-up)</li> <li>true — unsets the metaindex of the next proxy</li> <li>any other value — sets that value as the metaindex of the next proxy. (Note new_G._G is not set until it is returned by <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>)</li></ul> <p>To omit or to pass nil/false as <i>var</i> has the same effect as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. Pass true instead and this treats it as though passed as <i>metaindex</i>, creating a new proxy without backing up the incumbent. </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_2">Buffer:_2</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>This returns the value indexed at key <code>name</code> in the global table. If it does not exist, this forwards both arguments to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and returns the saved value (which may be itself). </p><p>In other words, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is roughly equivalent to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="nb">_G</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="nb">_G</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="ow">or</span> <span class="n">save</span> <span class="ow">or</span> <span class="n">save</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">and</span> <span class="n">Buffer</span></code>. </p><p>The string <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="s1">'new_G'</span></code> will return the Module:Buffer local variable <code><a href="#new_G">new_G</a></code>, used as a proxy for the global variable _G. Given more than one argument, this forwards arguments to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> to assign another proxy global before returning the (newly-deposed) proxy. This then sets <code>new_G._G</code> to the original _G object for call chaining. (See § chain call in <a href="#G_object">_G object</a>). </p> <div class="mw-heading mw-heading4"><h4 id="Buffer:_B">Buffer:_B</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Takes only one argument and returns that argument. </p><p>Assuming the only <i>X</i> declared is <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and new_G equals _G, then <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> are equivalent.<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>note 28<span class="cite-bracket">]</span></a></sup> </p><p>When passed a variable that does not exist, this returns the Buffer nil object: </p><p><span class="anchor" id="Buffer-nil"></span> </p> <div class="mw-heading mw-heading5"><h5 id="Buffer-nil_object">Buffer-nil object</h5></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a><br /> <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>The Buffer-nil object is unique. Calling this as a function returns nothing (in contrast, calling an empty Buffer object returns an empty string). This does however have the Module:Buffer __concat metamethod, which treats this the same way as any <a href="#invalid">invalid</a> object (i.e. ignores it). </p><p>Appending this via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> or <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> has the same effect as appending nil. Passing this to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> returns nil instead of the string 'nil'. </p><p>The only real Buffer method in its meta __index is <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, however, any non-numerical key string retrieves a function that only returns the Buffer nil object for call chaining. In a sense, you can think of <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_B</span><span class="p">(</span><span class="n">var</span><span class="p">):...</span></code> as an <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kr">if</span> <span class="n">var</span><span class="o">~=</span><span class="kc">nil</span> <span class="kr">then</span> <span class="n">var</span><span class="p">:...</span></code> block around the following chain that ends in the next :_B(). </p><p>If <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, the clone will be a normal Buffer object. </p><p><span class="anchor" id="_G_object"></span> </p> <div class="mw-heading mw-heading4"><h4 id="G_object">_G object</h4></div> <p>The first _G variable <a href="#initialize">passed to this module</a> is given a __call metamethod that self-<a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luarefs</a> and returns in a manner that depends on whether it was called directly or from a chain.<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>example 2<span class="cite-bracket">]</span></a></sup> This module conserves any pre-existing metatable and alters no metamethod other than __call. </p> <dl><dd><table> <tbody><tr> <td> <div class="mw-heading mw-heading5"><h5 id="direct_call">direct call</h5></div> <p><code>_G( k, v )</code><br /> <code>_G'string'</code> </p><p>When called, the _G object self-sets any string passed as <code>k</code> with whatever is passed as <code>v</code>. This returns <i>v</i>, or nil if omitted (unlike with rawset, an explicit nil is not necessary to unset a variable with direct calls). </p><p>Note that <i>k</i> must be a string to declare or unset a global in this op. Tables passed as the first argument are treated as though this were executed via a call chain (discussed shortly). Passing <i>k</i> which is not one of those two types will throw an error. </p> <div class="mw-heading mw-heading5"><h5 id="chain_call">chain call</h5></div> <p><code>chained-object:_G( k, v )</code><br /> <code>chained-object:_G'string'</code> </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r5590687"><div role="note" class="hatnote navigation-not-searchable">Ne zamenjajte za <a href="#Buffer:_G">§ Buffer:_G</a>, the Buffer object function, which differences are noted in the final paragraph of this section..</div> <p>When used in a call chain, this rawsets the <i>k</i>ey-<i>v</i>alue pair in the chained object and returns that object. The _G object may chain itself when returning _G is desired for another op instead of <i>v</i>. </p><p>In contrast to the direct op, the in-chain op will index non-string <i>k</i> values. Moreover, this only unsets object[k] when passed an explicitly nil <i>v</i>. </p><p>If <i>v</i> is omitted in-chain, this uses the chained object as the missing argument; thus, (chained) <code>object:_G'string'</code> has identical effect and return to <code>_G('string', object)</code>. </p> </td></tr></tbody></table></dd></dl> <p>The same __call method is given to <a href="#new_G">new_G</a> objects created by Buffer:_R, however the direct call only works if its metaindex is the _G object. Any table such that <code>table._G</code> points to the _G object may chain save to itself regardless of metaindex. </p><p>Though the behavior of the chain op when <i>v</i> is omitted may be a <a href="/w/index.php?title=Dead_ringer_(idiom)&action=edit&redlink=1" class="new" title="Dead ringer (idiom) (stran ne obstaja)">dead ringer</a> to that of <a href="#Buffer:_G">Buffer:_G</a> when <i>save</i> is omitted and <a href="#new_G">new_G</a> is the chained object, mind that the Buffer object function sets keys in new_G variable rather than the chained (Buffer) object; in other words, this is unaffected by Buffer:_R reassigning new_G to another table. Also, this does not have the back up behavior of Buffer:_G. </p><p><span class="anchor" id="Buffer-variable"></span> </p> <div class="mw-heading mw-heading3"><h3 id="Buffer-variable_object">Buffer-variable object</h3></div> <div class="mw-heading mw-heading4"><h4 id="Buffer:_var">Buffer:_var</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>Raw appends a Buffer-variable object, which may appear as a different value each time the object (or its container) is converted to a string.<sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">[</span>example 3<span class="cite-bracket">]</span></a></sup> </p><p>Initialize a Buffer-variable object by passing as <code>var</code> a: </p> <ul><li>number - which, when strung the first time, appears as that number and reappears as <code>var + change</code> the next time it is strung.</li> <li>string - that transforms into the next <a href="/wiki/ASCII" title="ASCII">ASCII</a> character via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>.</li> <li>table - to return the first (non-nil) item, then the second, and so on as determined by <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, looping back to the first item after reaching the last. (Note the <i>change</i> argument does not apply to table-based Buffer-variables.)</li> <li>custom function - to be set as the _build and __tostring method of a variable-object, though instructions for coding such functions are beyond the scope of this manual.</li></ul> <p>Re-append the same variable object by passing <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kc">true</span></code> as the only argument. For non-table-based variables, you may specify <i>change</i> to append a sister object which transforms the value at the rate specified. Changes are cumulative. Thus, if the original is re-strung after a sister, its value will differ from that of its last appearance by the sum of the original and sister rates and vice versa. </p><p>Apply a <i>change</i> without appending a new variable object to the Buffer by passing <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kc">false</span></code>. The shift is effective immediately and may affect previously appended variable objects not yet <a href="#Buffer:_out">finalized</a>. Pass only false (i.e., omit <i>change</i>) to produce the same effect as stringing the original once. Note that the false-change is the only <i>change</i> table-based Buffer variables will honor.<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>note 29<span class="cite-bracket">]</span></a></sup> </p><p>Pass nothing to append a version which simply repeats the result of the last stringing. While generally identical in effect to the object generated by <code>:_var(true, 0)</code>, the Buffer-variable will return nothing if strung before any of its sisters. </p><p>If passed an explicit nil as the first argument, this is no-op. If passed a boolean before any Buffer-variable has been initialized, this is also a no-op. Note that any op disables future caching at <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> for all Buffer objects in your module (and in any module which may require it). </p><p><span class="anchor" id="library"></span> </p> <div class="mw-heading mw-heading3"><h3 id="String,_mw.ustring,_and_mw.text_libraries"><span id="String.2C_mw.ustring.2C_and_mw.text_libraries"></span>String, mw.ustring, and mw.text libraries</h3></div> <div class="mw-heading mw-heading4"><h4 id="Basic_usage">Basic usage</h4></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">functionName</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span></code> </p><p>You may directly chain any function from the following libraries on Buffer objects: </p> <dl><dd><table> <tbody><tr> <td><a href="/w/index.php?title=Predloga:Collist&action=edit&redlink=1" class="new" title="Predloga:Collist (stran ne obstaja)">Predloga:Collist</a> </td></tr></tbody></table></dd></dl> <p>Functions from these libraries added to the Module:Buffer metatable on-demand and placed within a wrapper method that strings the Buffer object for the first argument and then forwards the remaining arguments. </p><p>Thus, the following are equivalent: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">nowiki</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span></code> and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> </p><p>If a name exists in both the string and mw.ustring libraries, the string version takes precedence. You may <a href="/w/index.php?title=Prefix&action=edit&redlink=1" class="new" title="Prefix (stran ne obstaja)">prefix</a> the letter <i>u</i> on any mw.ustring function—e.g. Buffer:ulen returns the number of unicode characters and Buffer:len returns the number of bytes. </p><p>Buffer:gsub and Buffer:ugsub have a slightly different wrapper which substitutes the <code>repl</code> argument of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> when it evaluates false or is omitted with an empty string (otherwise the originals would throw an error). This saves a few keystrokes when removing characters via <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">gsub</span><span class="s1">'[pattern]'</span></code> as opposed to <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">gsub</span><span class="p">(</span> <span class="s1">'[pattern]'</span><span class="p">,</span> <span class="s1">''</span> <span class="p">)</span></code>. All other arguments are handled the same as with the other on-demand methods. </p><p>Library functions which take a non-string as the first argument are not supported. </p> <div class="mw-heading mw-heading4"><h4 id="Empty_Buffer_interface">Empty Buffer interface</h4></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>To obtain the first return value as a Buffer object (as opposed to whatever type the original normally returns), simply chain the imported method immediately after creating the new Buffer via <a href="#Buffer:_in">Buffer:_in</a>. Only empty Buffer objects which have a parent object will append the result of their parent in this manner. </p><p>This syntactic sugar allows two things: </p> <ul><li>For appending additional objects after the op via Buffer object methods.</li> <li>For chaining multiple <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> methods not chainable to strings—e.g., this: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_in</span><span class="p">():</span><span class="n">uformat</span><span class="p">(</span> <span class="p">...</span> <span class="p">):</span><span class="n">_in</span><span class="p">():</span><span class="n">toNFD</span><span class="p">():</span><span class="n">encode</span><span class="s1">'[<>#]'</span><span class="p">:</span><span class="n">match</span><span class="s1">'^(.-)==='</span></code></li></ul> <dl><dd>vs. the following which has the same order of operations albeit harder to see: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">mw</span><span class="p">.</span><span class="n">text</span><span class="p">.</span><span class="n">encode</span><span class="p">(</span> <span class="n">mw</span><span class="p">.</span><span class="n">ustring</span><span class="p">.</span><span class="n">toNFD</span><span class="p">(</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">uformat</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span> <span class="p">),</span> <span class="s1">'[<>#]'</span> <span class="p">):</span><span class="n">match</span><span class="s1">'^(.-)==='</span></code></dd></dl> <dl><dd><table> <tbody><tr> <td> <div class="mw-heading mw-heading5"><h5 id="Special_case:_Element-Buffer">Special case: Element-Buffer</h5></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">empty</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">functionName</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="p">:</span><span class="n">_in</span><span class="p">():</span><span class="n">functionName</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span></code> </p><p>The 'empty' behavior is different when chained to empty Element-Buffer or an empty child Buffer of an Element-Buffer. </p><p>Library methods chained to an empty Buffer which parent is an <a href="#Element-Buffer">Element-Buffer object</a> will instead string the grandparent <a href="#Buffer-HTML">Buffer-HTML object</a> for use as the first argument before appending the result to the new Buffer. This interface is provided because Buffer-HTML objects, which are not true Buffer objects, are unable to load these functions, making this the only chainable option for Scribunto methods that includes the outer tag of non-empty Element-Buffers. </p><p>Chained on an empty Element-Buffer, these methods will string the Buffer object which created its HTML tree via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a><sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">[</span>note 30<span class="cite-bracket">]</span></a></sup> and append the result to the Element-Buffer.<sup id="cite_ref-34" class="reference"><a href="#cite_note-34"><span class="cite-bracket">[</span>example 4<span class="cite-bracket">]</span></a></sup> </p> </td></tr></tbody></table></dd></dl> <div class="mw-heading mw-heading2"><h2 id="Modified_.._operator">Modified <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">..</code> operator</h2></div> <p>All "true" Buffer objects—e.g., the <a href="#Buffer_object">regular</a>, <a href="#Stream-Buffer">stream</a>, and <a href="#Element-Buffer">element</a> varieties—share the same <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. Some Buffer-<i>like</i> classes, namely <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaselfs</a> and the <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, also have this same metamethod. </p><p>The extended <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> operator does not append to Buffer objects. In other words, Buffers generally remain the same as before the op excepting those effects that apply whenever Buffers are strung (See <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>). </p> <div class="mw-heading mw-heading3"><h3 id="with_non-tables">with non-tables</h3></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span> <span class="o">..</span> <span class="n">value</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">value</span> <span class="o">..</span> <span class="n">Buffer</span></code> </p><p>Any non-table <code>value</code> may be joined a Buffer object with the concatenation operator <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">..</span></code> without error. </p><p>With the exception of Element-Buffers (which are a special case), the op passes each object, ordered left-to-right, to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> which inserts <a href="#valid">validated</a> items in a new table, which this returns through <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>Concatenating an <a href="#valid">invalid</a> <i>value</i> and a Buffer has generally the same effect as <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> unless such involves: </p> <ul><li>the Buffer-nil object — which produces an empty string (instead of nil)</li> <li>Element-Buffer objects — which returns the string of the parent Buffer-HTML<div class="rellink">Več informacij: <a href="#for_Element-Buffer_objects">#for Element-Buffer objects</a></div></li></ul> <div class="mw-heading mw-heading3"><h3 id="with_tables">with tables</h3></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span> <span class="o">..</span> <span class="n">table</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">table</span> <span class="o">..</span> <span class="n">Buffer</span></code> </p><p>The same general operation applies for tables as with non-tables—i.e., <a href="#valid">validated</a> values are inserted left-to-right into a new table to be joined by table.concat. In fact, tables which have a metatable (including Buffer objects which are not an Element-Buffer) are forwarded to Buffer:_ and processed the same way as non-tables. </p><p>Given a <code>table</code> for which <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> returns nil or false, this instead forwards the table to <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, which iterates every value indexed at a number key in sequential order, inserting those which are valid in the new table. </p><p>As a reminder, Buffer:_ validates tables with metatables that lack a __tostring method through table.concat, which throws an error on sequences containing one or more value that is neither a string nor a number. Such accounts for nearly all cases of breaking errors involving this op. </p><p>Note that the <i>valKey</i> parameter of Buffer:_all is not triggered. </p> <div class="mw-heading mw-heading3"><h3 id="for_Element-Buffers">for Element-Buffers</h3></div> <p><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">-</span><span class="n">Buffer</span> <span class="o">..</span> <span class="n">value</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">value</span> <span class="o">..</span> <span class="n">Element</span><span class="o">-</span><span class="n">Buffer</span></code><br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Element</span><span class="o">-</span><span class="n">Buffer</span> <span class="o">..</span> <span class="n">Element</span><span class="o">-</span><span class="n">Buffer</span></code> </p><p>To recap and expand upon <a href="#Element-Buffer">§ Element-Buffer-object</a>, the behavior of this op depends on whether its parent Buffer-HTML is <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> or if the other <i>value</i> is also an Element-Buffer. Also, the final result always includes the outer HTML object (i.e., the tag) in some manner. </p><p>For Element-Buffers of "open" tags, this op creates a table with a metaindex that references the parent of the Element-Buffer. The table is then effectively a "mirror" of the parent Buffer-HTML object except that it contains an empty table at <code>table.nodes</code>— the index of the Element-Buffer within its parent. This then populates the mirror's inner table with the string of the Element-Buffer and the other value, validated left-to-right, in a manner not unlike what this does with the temporary table it creates when concatenating non-element Buffers to another value. This then returns the mirror table through the __tostring metamethod of the mw.html library, yielding a string which resembles that of the parent tag but with <i>value</i> inserted in front of or behind the original inner text depending on whether <i>value</i> was to the left or right of the <code>..</code> operator, respectively. </p><p>When the selfClosing property of the parent evaluates true, this operates on the parent instead of the Element-Buffer—i.e., the resulting string will have <i>value</i> on the outside as opposed to within the tag (placing it inside would be pointless since selfClosing tags do not show inner contents). </p><p>If both operated objects are Element-Buffers, this mirrors the parent of the first. The inner table of the mirror is then populated by inserting the string of the first Element-Buffer followed by the string the parent Buffer-HMTL of the second. The resulting string would be as though the parent of the second were the last node of the first parent. Note that this Element-to-Element rule does not apply when the first Buffer belongs to a selfClosing tag (in which case, this behaves as though the selfClosing parent were to the left of the operator, returning a string with the selfClosing tag inside the tag of the second Element-Buffer in front the latter's inner contents.) </p><p>Finally, this combines an Element-Buffer and a table <i>value</i> which has no metatable by passing the table as <i>args</i> for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> with the mirror of the Element-Buffer as the "self". This avoids permanently changing the parent Buffer-HTML by setting a new table at <code>table.attributes</code> or <code>table.styles</code> in the mirror the first time methods such as <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, etc. attempt to access those tables, copying the original's via the recursive form of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. Note however that permanent changes may be made to other objects whenever methods such as via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> or <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> are keyed to navigate beyond the mirror or "sandbox". </p><p><span class="anchor" id="MBpairs"></span> </p> <div class="mw-heading mw-heading2"><h2 id="require'Module:Buffer'._pairs"><span id="require.27Module:Buffer.27._pairs"></span>require'Module:Buffer'.__pairs</h2></div> <p><a href="#MBpairs"><code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">.</span><span class="n">__pairs</span><span class="p">(</span> <span class="n">table</span><span class="p">,</span> <span class="n">flag</span><span class="p">,</span> <span class="n">ext</span> <span class="p">)</span></code></a> </p><p>Returns two values: an iterator function and the <code>table</code>. This is intended for use in the <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> <code>for</code>. </p><p>One distinctive feature of this pairs method is that it splits keys into two groups: <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luarefs</a> and non-numbers. This indexes each group of keys in its own "map" object, traversed by its own iterator function—i.e, iterating both sets of keys requires two separate for loops. Numeric keys are served in an orderly fashion as with <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> except that those which are negative, non-consecutive, and non-integer may be included. Moreover, this can find some keys paired with explicitly nil values.<sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span class="cite-bracket">[</span>example 5<span class="cite-bracket">]</span></a></sup> </p><p>The <code>flag</code> argument selects the iterator method returned for that loop. When <i>flag</i> is an explicit nil or omitted, this returns an iterator for number keys. If given any non-nil <i>flag</i> (i.e., false or any value that evaluates true), this returns a method for looping non-numeric keys. Because both sets are mapped at the same time, you may avoid a redundant mapping op in a subsequent loop by passing an explicit nil or false as <i>flag</i>—i.e., omitting <i>flag</i> or passing true indicate that re-mapping is desired. </p><p>This automatically selects certain tables for "mapless" iteration. Typically, mapless differs from mapped only in that it uses fewer server resources, though, as explained in the next section on mapping, it may "miss" keys in some cases. </p><p>Mapping behavior may be modified or extended by <code>ext</code>. To disable mapless iteration for the table, you may pass false as <i>ext</i>. If not nil or false, <i>ext</i> must be a pairs method that takes the table as its only argument and returns a function that may iterate its keys for mapping purposes. Note that re-mapping avoidance via <i>flag</i> does not apply if <i>ext</i> is explicitly given, though a nil <i>ext</i> does not disqualify a table from mapless iteration. <span class="anchor" id="mapping"></span> </p> <div class="mw-heading mw-heading3"><h3 id="Mapping_process">Mapping process</h3></div> <p>Tables are mapped in two stages. </p><p>The initial stage is a <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> which inserts integers between <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">1</span></code> and <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">#</span><span class="n">table</span></code> in the number key map. Because nothing is checked in this step, this may map keys which the <a href="#Iterators">numeric map iterator</a> would pair with nil values or with values from the table's <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>The second stage explores the table's keys with an <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> as the default <i>expression-list</i>, or, if <i>ext</i> evaluates true, the expression returned by <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">ext</span><span class="p">(</span> <span class="n">table</span> <span class="p">)</span></code>. This ignores keys already mapped in the first stage and checks if any unmapped key is a number before indexing it in the appropriate map group. Upon completion, if any new number key were found in the second stage, this runs the numeric map through <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. No order is imposed on the non-numeric map. </p><p>Alternatively, a table may qualify for "mapless" iteration if <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> is not nil, and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> returns nil. If either <i>flag</i> or <i>ext</i> are not nil, or if the table was previously mapped, such permanently disqualifies a table for mapless processing. </p><p>As a side note, if mapless numeric iteration occurs, this returns <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">iterator</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="kc">nil</span></code>. In other words, you may use <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> to confirm that the table qualifies for mapless iteration when it has a third explicit return (for debugging). </p> <div class="mw-heading mw-heading3"><h3 id="Iterators">Iterators</h3></div> <p><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> </p><p>One of four functions may be provided in the <i><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></i> returned by this pairs method, depending on which group of keys (numeric or non-numeric) and which iteration process (map-based or mapless) is indicated. </p><p>When <code>key</code> is nil or unspecified, map iterators will return the key object referenced by the first index of the relevant map along with the value it indexes. If passed the first mapped key, these iterators then return the second index mapped, which if passed in turn may retrieve the third and so on until the last mapped key has been served. </p><p>For numeric iteration, the mapless method returns <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="mi">1</span><span class="p">,</span> <span class="n">table</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code> when <i>key</i> is unspecified. If a <i>key</i> is given, it returns <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">key</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">table</span><span class="p">[</span> <span class="n">key</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">]</span></code> unless <i>key</i> is greater or equal to the length of the table, upon which it returns nil. For non-numeric keys, the mapless "iterator" is actually a no-op (empty) function which takes nothing, does nothing, and returns nothing—provided only to prevent an error when the for loop expects a function. </p><p>As mentioned (using different words), key-value pairs are served independently of whether or not <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">table</span><span class="p">[</span><span class="n">key</span><span class="p">]</span></code> exists and retrieved without using <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>. </p><p>For example, take a look at table <i>x</i> as declared in the following statement: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">{{{</span><span class="mi">1</span><span class="p">}}}</span></code>. Table <i>x</i> has a length equal to 8. With ipairs, the for loop stops after the first pair. In contrast, this module's __pairs method will loop all 8 keys declared—i.e., (1, 1), (2, nil), ... (7, nil), (8, 8). That said, this only iterates two keys if table <i>x</i> were declared as <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">{{{</span><span class="mi">1</span><span class="p">}}}</span></code> instead even though such is indistinguishable to Finally, the loop would continue to include any keys set to nil after the mapping process.</ref> </p><p>You may assign these iterators to a local variable to use them directly. If an unmapped table is given to a map iterator, it will forward the table to this pairs method for immediate mapping. Though no map table is produced for the mapless iteration, the pairs method does cache the length of the table at a map reference, which the iterator compares against <i>key</i> to determine when to stop. Unlike the map methods, the mapless iterator does not call the pairs method when such has been bypassed and instead compares <i>key</i> to the value returned by the <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, which may be unstable if the loop includes code that sets or unsets indicies within the table. Also, the mapless method will throw an error if given a table that has been mapped (when it attempts to compare <i>key</i> to a map object). </p> <div class="mw-heading mw-heading2"><h2 id="Appendix">Appendix</h2></div> <p><span class="anchor" id="tips"></span><span class="anchor" id="Tips"></span> </p> <div class="mw-heading mw-heading3"><h3 id="Tips_and_style_recommendations">Tips and style recommendations</h3></div> <ul><li>If <a href="#Buffer">joining Buffer</a> with a string immediately after <code>:_'<i>text</i>'</code>, place a space between 'string' and the <a href="#Buffer">separator</a> and use double/single quote marks to . (i.e. <code>:_'<i>text</i>' " "</code> instead of <code>:_'<i>text</i>'<a href="/w/index.php?title=Predloga:%60&action=edit&redlink=1" class="new" title="Predloga:` (stran ne obstaja)">Predloga:`</a> '</code> or <code>:_'<i>text</i>'(' ')</code>)</li> <li>Saving Module:Buffer locally, e.g. <code>local Buffer = <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></code>, though fine, is often unnecessary since all Buffer objects can create new buffers via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.</li></ul> <p><b>For <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></b> </p> <ul><li>Treat <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">:_</code> as though it were a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">..</code> op. Wrapping strings with unnecessary <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">()</code> is akin to <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">( 'string1' ) .. ( 'string2' ) .. ( 'string3' )</code>.</li> <li>To insert an empty string as a placeholder for a <a href="#Buffer">separator</a> without setting <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">raw</code>, pass a table containing only an empty string, like so: <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.</li> <li>Raw appending a non-table is pointless since no other Scribunto type can tostring differently afterwards. However, this developer believes you are smart enough that <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">raw</span> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span></code> is a waste of server resources. (Such checks are why <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> takes twice as much time to append a list of strings as <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> despite their near-identical roles in an Element-Stream-Buffer).</li></ul> <p><b>For <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></b> </p> <ul><li>Something like <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer_str</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="n">A</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="p">{</span><span class="n">C</span><span class="p">,</span> <span class="n">B</span><span class="p">})</span></code> will use variable <code>A</code> as the parent's separator, or <code>B</code> instead if <i>A</i> is nil, or <code>C</code> if both A and B are nil.</li></ul> <p><b>For <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></b> </p> <ul><li>Appending values in multiple locations is one of the primary reasons why the <a href="#nanKeys">nanKeys</a> argument exists. While passing a boolean directly will cause an error, you can do something like...</li></ul> <dl><dd><dl><dd>this: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_all</span><span class="p">({</span><span class="n">condition</span> <span class="ow">and</span> <span class="p">{</span><span class="n">_nil</span><span class="o">=</span><span class="p">{</span><span class="s1">'0'</span><span class="p">,</span> <span class="s1">'replacement'</span><span class="p">},</span><span class="n">Front</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">getParent</span><span class="o">=</span><span class="s1">'from child'</span><span class="p">}}},</span> <span class="kc">true</span><span class="p">)</span></code></dd> <dd>versus: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_nil</span><span class="p">(</span><span class="s1">'0'</span><span class="p">,</span> <span class="n">condition</span> <span class="ow">and</span> <span class="s1">'replacement'</span> <span class="ow">or</span> <span class="kc">false</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="n">condition</span> <span class="ow">and</span> <span class="s1">'Front'</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span><span class="n">getParent</span><span class="p">(</span><span class="n">condition</span> <span class="ow">and</span> <span class="s1">'from child'</span><span class="p">):</span><span class="n">_B</span><span class="p">(</span><span class="n">child</span><span class="p">)</span></code>.</dd></dl></dd></dl> <p><b>For <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a></b> </p> <ul><li>If the table reference passed as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">clear</code> was appended <a href="#raw">raw</a> in multiple positions, this is akin to performing <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> at all positions simultaneously. (May be easier than trying to come up with a <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> pattern)</li> <li>Inserting a <a href="#Buffer:_G">named</a> empty table is raw as a placeholder to be populated later via this function may be easier than calculating <i>pos</i> argument of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.</li></ul> <div class="mw-heading mw-heading3"><h3 id="Examples">Examples</h3></div> <div class="reflist" style="list-style-type: decimal;"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-28"><span class="mw-cite-backlink"><a href="#cite_ref-28">↑</a></span> <span class="reference-text">The following demonstrates how, by combining Buffer:_R and Buffer:_G, the global variable <i>v</i> can be declared, backed-up and replaced, replaced without back-up, restored from back-up, and removed completely: <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">require</span><span class="s1">'Module:Buffer'</span> <span class="p">(</span><span class="nb">_G</span><span class="p">,</span><span class="s1">'v'</span><span class="p">)</span> <span class="c1">-- call module with global functions enabled and declare new buffer as v</span> <span class="p">:</span><span class="n">_</span><span class="s1">'A'</span> <span class="c1">-- append 'A' to the returned buffer</span> <span class="p">:</span><span class="nb">_G</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="c1">-- _G.v = 1, shift old value (the buffer) to metaglobal.__index</span> <span class="p">:</span><span class="n">_R</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span> <span class="mi">2</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="c1">-- _G.v = 2, discard old value (1) without back-up</span> <span class="p">:</span><span class="n">_R</span><span class="s1">'v'</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="c1">-- unset _G.v, which now defaults to metaglobal.__index.v (the buffer)</span> <span class="p">:</span><span class="nb">_G</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span><span class="s2">", "</span> <span class="c1">-- remove back-up and join the buffer with a separator</span> <span class="o">..</span><span class="s1">' and '</span><span class="o">..</span><span class="nb">tostring</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="c1">-- returns 'A, 1, 2, A12 and nil'</span> </pre></div> </td></tr></tbody></table></dd></dl> </span></li> <li id="cite_note-30"><span class="mw-cite-backlink"><a href="#cite_ref-30">↑</a></span> <span class="reference-text">Saving a new_G object globally via a chain call can prevent conflict. The follow example has a hypothetical "Module:X" that may overwrite globals declared by your module or unwittingly discard your new_G when it passes _G to Module:Buffer (passing _G to this module resets new_G to the global table even when the global functions are already enabled): <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">return</span> <span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">(</span><span class="nb">_G</span><span class="p">)</span><span class="c1">--Return before require to show intent to return a Buffer object; chain cannot be broken</span> <span class="p">:</span><span class="n">_R</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">title</span> <span class="ow">and</span> <span class="c1">--store values outside global scope if invoked with title parameter</span> <span class="s1">'new_G'</span><span class="p">)</span> <span class="p">:</span><span class="nb">_G</span><span class="s1">'myBuff'</span> <span class="c1">--save current Buffer in new_G</span> <span class="p">:</span><span class="n">_2</span><span class="s1">'new_G'</span> <span class="c1">--retrieve new_G</span> <span class="p">:</span><span class="nb">_G</span><span class="s1">'my_G'</span> <span class="c1">--save new_G as global my_G</span> <span class="p">:</span><span class="nb">_G</span><span class="p">(</span><span class="s1">'t'</span><span class="p">,</span> <span class="c1">--save title object as my_G.t for later re-use</span> <span class="n">mw</span><span class="p">.</span><span class="n">title</span><span class="p">.</span><span class="n">new</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">title</span> <span class="ow">or</span> <span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">page</span><span class="p">)</span> <span class="p">).</span><span class="n">myBuff</span> <span class="c1">--go to my_G.myBuff (my_G lacks the Buffer:_2 method, but doesn't need it)</span> <span class="p">:</span><span class="n">stream</span><span class="p">(</span><span class="n">my_G</span><span class="p">.</span><span class="n">t</span><span class="p">.</span><span class="n">exists</span> <span class="c1">--just arbitrary code to show how in-line storage may be used without breaking the chain</span> <span class="ow">or</span> <span class="n">warning</span><span class="p">(</span><span class="n">my_G</span><span class="p">.</span><span class="n">t</span><span class="p">),</span> <span class="c1">--local function warning() declared before return</span> <span class="nb">require</span><span class="s1">'Module:X'</span><span class="p">.</span><span class="n">main</span><span class="p">(</span><span class="n">my_G</span><span class="p">.</span><span class="n">t</span><span class="p">),</span> <span class="n">my_G</span><span class="p">.</span><span class="n">t</span><span class="p">.</span><span class="n">isSubpage</span> <span class="ow">and</span> <span class="n">subpage</span><span class="p">(</span><span class="n">my_G</span><span class="p">.</span><span class="n">t</span><span class="p">),</span> <span class="p">...</span> <span class="p">)</span> <span class="p">:</span><span class="n">_R</span><span class="p">(</span><span class="s1">'new_G'</span><span class="p">,</span> <span class="n">my_G</span><span class="p">)</span> <span class="c1">--set my_G as new_G again and have the new_G from Module:X as its metaindex</span> <span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">detail</span> <span class="ow">and</span> <span class="n">my_G</span><span class="p">.</span><span class="n">info</span> <span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">detail</span><span class="p">)</span><span class="c1">--append Buffer object from Module:X's new_G.info if args.details and it exists; append detail param to result</span> <span class="ow">or</span> <span class="n">my_G</span><span class="p">.</span><span class="n">summary</span><span class="p">)</span> <span class="c1">--just append summary from Module:X if not invoked with detail param.</span> <span class="p">:</span><span class="n">_B</span><span class="p">(</span><span class="n">t</span> <span class="ow">and</span> <span class="c1">--use global t as a shorthand for "if not frame.args.title then" (t only declared a global in line 2 if no title given)</span> <span class="n">myBuff</span> <span class="p">:</span><span class="n">stream</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">page</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">details2</span><span class="p">,</span> <span class="n">mw</span><span class="p">.</span><span class="n">html</span><span class="p">.</span><span class="n">create</span><span class="s1">'br'</span><span class="p">,</span> <span class="nb">require</span><span class="s1">'Module:Y'</span><span class="p">.</span><span class="n">main</span><span class="p">(</span><span class="n">frame</span><span class="p">))</span> <span class="ow">or</span> <span class="n">my_G</span><span class="p">.</span><span class="n">myBuff</span> <span class="c1">--place results in a table if invoked with title param (alternative chain call branches within Buffer:_B)</span> <span class="p">:</span><span class="n">_inHTML</span><span class="s1">'table'</span><span class="p">(</span><span class="n">_addArgs</span><span class="p">)</span> <span class="p">:</span><span class="n">_parent</span><span class="p">()</span> <span class="p">)</span> </pre></div> </td></tr></tbody></table></dd></dl> </span></li> <li id="cite_note-31"><span class="mw-cite-backlink"><a href="#cite_ref-31">↑</a></span> <span class="reference-text">The following contrived example demonstrates most features of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>: <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">local</span> <span class="n">H</span><span class="p">,</span> <span class="n">sep</span> <span class="o">=</span> <span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">:</span><span class="n">_inHTML</span><span class="p">(</span><span class="s1">'div'</span><span class="p">,{</span><span class="s1">'Heading '</span><span class="p">,</span><span class="n">_var</span><span class="o">=</span><span class="p">{</span><span class="kc">nil</span><span class="p">,</span><span class="s1">'odd'</span><span class="p">,</span><span class="s1">'even'</span><span class="p">},</span><span class="n">color</span><span class="o">=</span><span class="s1">'blue'</span><span class="p">,[</span><span class="s1">'text-decoration'</span><span class="p">]</span><span class="o">=</span><span class="s1">'underline'</span><span class="p">})</span> <span class="p">:</span><span class="n">_out</span><span class="p">():</span><span class="n">_html</span><span class="p">(</span><span class="kc">true</span><span class="p">):</span><span class="n">_html</span><span class="p">(</span><span class="kc">true</span><span class="p">):</span><span class="n">_html</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="n">sep</span> <span class="o">=</span> <span class="n">H</span><span class="p">:</span><span class="n">_in</span><span class="s1">'This is '</span><span class="p">:</span><span class="n">_var</span><span class="p">():</span><span class="n">_</span><span class="s1">' - '</span><span class="p">:</span><span class="n">_var</span><span class="s1">'A'</span><span class="p">:</span><span class="n">_var</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span><span class="n">_</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span> <span class="kr">return</span> <span class="n">H</span><span class="p">:</span><span class="n">_in</span><span class="p">(</span><span class="n">H</span><span class="p">(</span><span class="n">sep</span><span class="p">)):</span><span class="n">_</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> <span class="p">:</span><span class="n">_</span><span class="s1">'math:'</span><span class="p">:</span><span class="n">_var</span><span class="p">():</span><span class="n">_</span><span class="s1">'+ 5 ='</span><span class="p">:</span><span class="n">_var</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span><span class="mi">5</span><span class="p">):</span><span class="n">_</span><span class="s1">';'</span><span class="p">:</span><span class="n">_var</span><span class="p">():</span><span class="n">_out</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="s1">' '</span><span class="p">):</span><span class="n">_var</span><span class="p">(</span><span class="kc">false</span><span class="p">):</span><span class="n">_</span><span class="s1">' - 1 = '</span><span class="p">:</span><span class="n">_var</span><span class="p">()</span> <span class="cm">--[[ produces:</span> <span class="cm"><div style="color:blue;text-decoration:underline">Heading odd</div>This is odd - A3</span> <span class="cm"><div style="color:blue;text-decoration:underline">Heading even</div>This is even - B2</span> <span class="cm"><div style="color:blue;text-decoration:underline">Heading odd</div>This is odd - C1</span> <span class="cm"><div style="color:blue;text-decoration:underline">Heading even</div> This is even - D0</span> <span class="cm"> math: 0 + 5 = 5 ; 5 - 1 = 4 --]]</span> </pre></div> </td></tr></tbody></table></dd></dl> </span></li> <li id="cite_note-34"><span class="mw-cite-backlink"><a href="#cite_ref-34">↑</a></span> <span class="reference-text">Compare the comment and source: <dl><dd><table> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="cm">--[[--= Result: ===></span> <span class="cm">This is just a quick example to demonstrate a neat concept:</span> <span class="cm"><div>Notice how the same object is strung which allows you to recycle boilerplate text.</span> <span class="cm"><p>3 is 1 added to 2.</p></span> <span class="cm"><span>Though this is not really realistic to be fair...</span> <span class="cm">Edit: not realistic at all</span></span> <span class="cm">I hope such is much to your liking.</div></span> <span class="cm">--]]</span><span class="c1">--= Source: ===></span> <span class="nb">require</span><span class="s1">'Module:Buffer'</span> <span class="s1">'%s is %s to %s.'</span><span class="c1">--A</span> <span class="p">:</span><span class="n">_inHTML</span><span class="s1">'div'</span><span class="p">():</span><span class="n">format</span><span class="p">(</span><span class="s1">'Notice how the same object'</span><span class="p">,</span> <span class="s1">'strung which allows you'</span><span class="p">,</span> <span class="s1">'recycle boilerplate text'</span><span class="p">)</span> <span class="p">:</span><span class="n">tag</span><span class="s1">'p'</span><span class="p">():</span><span class="n">format</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'1 added'</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="p">:</span><span class="n">done</span><span class="p">()</span> <span class="p">:</span><span class="n">tag</span><span class="s1">'span'</span><span class="p">():</span><span class="n">format</span><span class="p">(</span><span class="s1">'Though this'</span><span class="p">,</span> <span class="s1">'not really realistic'</span><span class="p">,</span> <span class="s1">'be fair..'</span><span class="p">)</span> <span class="p">:</span><span class="n">_in</span><span class="p">():</span><span class="n">sub</span><span class="p">(</span><span class="mi">21</span><span class="p">,</span> <span class="mi">29</span><span class="p">)</span> <span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="s1">'</span><span class="se">\n</span><span class="s1">Edit:'</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="p">:</span><span class="n">_</span><span class="s1">'istic at all'</span> <span class="p">:</span><span class="n">_out</span><span class="p">()</span> <span class="p">:</span><span class="n">done</span><span class="p">()</span> <span class="p">:</span><span class="n">_parent</span><span class="p">()</span><span class="c1">--B</span> <span class="p">:</span><span class="n">_out</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span> <span class="p">:</span><span class="n">format</span><span class="p">(</span><span class="s1">'This'</span><span class="p">,</span> <span class="s1">'just a quick example'</span><span class="p">,</span> <span class="s1">'demonstrate a neat trick'</span><span class="p">,</span><span class="c1">--A</span> <span class="s1">'I hope such'</span><span class="p">,</span> <span class="s1">'much'</span><span class="p">,</span> <span class="s1">'your liking'</span><span class="p">)</span><span class="c1">--B</span> <span class="p">:</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'trick.'</span><span class="p">,</span> <span class="s1">'concept:</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></dd></dl> </span></li> <li id="cite_note-35"><span class="mw-cite-backlink"><a href="#cite_ref-35">↑</a></span> <span class="reference-text">Take a moment to look at the following tables <i>X</i> and <i>Y</i>: <dl><dd><table style="width:50%"> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">local</span> <span class="n">X</span> <span class="o">=</span> <span class="p">{</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="mi">5</span> <span class="p">}</span> <span class="kd">local</span> <span class="n">Y</span> <span class="o">=</span> <span class="p">{</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="mi">5</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></dd></dl> <p>These tables are indistinguishable to <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> (ipairs iterates nothing and pairs yields only one key-value pair for either table). </p><p>While this module's __pairs method also gives only one pair for table <i>X</i>, it loops all five explicitly declared indicies for table <i>Y</i>, as shown in the console input below with Module:Buffer as <i>p</i>: </p> <dl><dd><table style="width:50%"> <tbody><tr> <td><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">p</span><span class="p">.</span><span class="n">__pairs</span><span class="p">{</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="mi">5</span> <span class="p">}</span> <span class="kr">do</span> <span class="n">mw</span><span class="p">.</span><span class="n">log</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span> <span class="mi">5</span> <span class="mi">5</span> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">p</span><span class="p">.</span><span class="n">__pairs</span><span class="p">{</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="mi">5</span> <span class="p">}</span> <span class="kr">do</span> <span class="n">mw</span><span class="p">.</span><span class="n">log</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span> <span class="mi">1</span> <span class="kc">nil</span> <span class="mi">2</span> <span class="kc">nil</span> <span class="mi">3</span> <span class="kc">nil</span> <span class="mi">4</span> <span class="kc">nil</span> <span class="mi">5</span> <span class="mi">5</span> </pre></div> </td></tr></tbody></table></dd></dl> </span></li> </ol></div></div> <div class="mw-heading mw-heading3"><h3 id="Notes">Notes</h3></div> <p>Non-literal interpretations of the source code (that is, more opinion than fact) are provided here to offer additional clarity. Overly technical details may be found here as well when including such caveats appears more likely to confuse than help those advanced-but-not-quite-fluent in Lua. </p> <div class="reflist" style="list-style-type: decimal;"> <div class="mw-references-wrap mw-references-columns"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">For your convenience, the self operator <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">:</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">.</code> are interchangeable when used on the Module directly, though the self-op is required for nearly all other interactions with objects created by the Module.</span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">Passing arguments after <i>name</i> is primary used when <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is indirectly called by <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> or <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. For example:<br /> <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="nb">require</span><span class="s1">'Module:Buffer'</span><span class="p">(</span><span class="nb">_G</span><span class="p">,</span><span class="s1">'arg'</span><span class="p">):</span><span class="n">_all</span><span class="p">({</span><span class="s1">'arg'</span><span class="p">,</span><span class="n">arg</span> <span class="ow">and</span> <span class="p">{</span><span class="s1">' was saved:'</span> <span class="p">,</span><span class="n">_in</span><span class="o">=</span><span class="p">{</span><span class="nb">_G</span><span class="p">,</span> <span class="s1">'t'</span><span class="p">,</span> <span class="s1">' awesome'</span><span class="p">}}},</span> <span class="kc">true</span><span class="p">):</span><span class="n">_</span><span class="p">(</span><span class="n">t</span> <span class="ow">and</span> <span class="p">{</span><span class="n">t</span><span class="p">(),</span> <span class="n">t</span><span class="o">..</span><span class="s1">'r'</span><span class="p">,</span> <span class="n">t</span><span class="o">..</span><span class="s1">'st'</span><span class="p">})</span></code><br /> produces: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">arg</span> <span class="n">was</span> <span class="n">saved</span><span class="p">:</span> <span class="n">awesome</span> <span class="n">awesomer</span> <span class="n">awesomest</span></code></span> </li> <li id="cite_note-raw-3"><span class="mw-cite-backlink"><a href="#cite_ref-raw_3-0">↑</a></span> <span class="error mw-ext-cite-error" lang="sl" dir="ltr"><span class="brokenref">Napaka pri navajanju: <span class="brokenref">Neveljavna oznaka <code><ref></code>; sklici, poimenovani <code>raw</code>, ne vsebujejo besedila (glej <a href="/wiki/Pomo%C4%8D:Napake_v_navajanju/Cite_error_references_no_text" title="Pomoč:Napake v navajanju/Cite error references no text">stran pomoči</a>).</span></span></span></li> <li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">Later sections may describe values as being <i>numerical</i> or <i>numeric</i>. Though perfect synonyms in normal usage, these adjectives are not interchangeable here. For the purposes of documenting Module:Buffer, <i>numerical</i> includes both actual number values and string values which <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> does not return nil (and often involves Buffer-style length relativity); <i>numeric</i> describes values of number type only.</span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><a href="#cite_ref-5">↑</a></span> <span class="reference-text">Using <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> prevents future caching on all Buffers, though Buffers which already unmodified Buffers will continue to return their cached version</span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><a href="#cite_ref-6">↑</a></span> <span class="reference-text">In other words, if <i>args</i> is a string or a table without [1] set, it will be passed as the only argument. Further note it is not possible to pass a <code><i>functionName</i> = <i>args</i></code> pair where <i>args</i> is numerical since such would be read as <code><i>value</i> = <i>pos</i></code>. Finally, passing a function type as <i>args</i> will throw an error message.</span> </li> <li id="cite_note-in-dependents-7"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-in-dependents_7-0">7,0</a></sup> <sup><a href="#cite_ref-in-dependents_7-1">7,1</a></sup></span> <span class="reference-text">There is no 'getChild' method. If a child needed after returning to the parent, set it <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> or use <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> prior to returning or it may become irretrievable. (No, <a href="/w/index.php?title=Uporabnik:Codehydro&action=edit&redlink=1" class="new" title="Uporabnik:Codehydro (stran ne obstaja)">Codehydro</a> did not get lazy. Rather, this allows <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> on children with no further purpose.)</span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><a href="#cite_ref-8">↑</a></span> <span class="reference-text">The first arg is not type checked but read as <i>ops</i> only when multiple args are present (or if it is the number 0); i.e., <code>Buffer:_out(2)</code> uses <code>2</code> as a separator. To append to the <i>N</i>th ancestor with no separator, use <code>Buffer:_outs(<i>N</i>, nil)</code>.</span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><a href="#cite_ref-9">↑</a></span> <span class="reference-text">Empty strings would produce the same output as false, however, Lua string literals create objects that take up memory until garbage collected.</span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><a href="#cite_ref-10">↑</a></span> <span class="reference-text">For example, given <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">{</span><span class="kc">nil</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">}</span></code> as <i>copy</i>, <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_cc</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span></code> makes <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">#</span><span class="n">clear</span></code> equal <code>2</code>, whereas <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="o">#</span><span class="n">mw</span><span class="p">.</span><span class="n">clone</span><span class="p">{</span><span class="kc">nil</span><span class="p">,</span> <span class="s1">'string'</span><span class="p">}</span></code> equals <code>0</code> (as of March 2015). This replicates length by filling clear halfway to the length of copy (the minimum needed to 'trick' Lua) and then setting nil every key that would not trigger recalculation. As a result, keys that would resize <i>clear</i> when set nil are left as empty strings. Such should be fairly rare; given tables representing every possible way to position a single nil key for all lengths between 2 and 32 (inclusive), only 8.39 percent of such tables would have its nil copied as an empty string instead.Also note that tables returned from <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Buffer</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span></code> have length declared on creation instead, and thus won't have extra strings attached. The odds can be estimated using <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle y{=}0.5/{\sqrt {x}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>y</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>=</mo> </mrow> <mn>0.5</mn> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mi>x</mi> </msqrt> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle y{=}0.5/{\sqrt {x}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/24a24b5b3735ae63bc97c82da483c5ff534ecd6c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:10.363ex; height:3.009ex;" alt="{\displaystyle y{=}0.5/{\sqrt {x}}}"></span>, where <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle y}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>y</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle y}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/b8a6208ec717213d4317e666f1ae872e00620a0d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:1.155ex; height:2.009ex;" alt="{\displaystyle y}"></span> is the upper limit that an arbitrary nil key from <i>copy</i> of length ranging from 1 to <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>x</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle x}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}"></span> is imaged as an empty string.</span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><a href="#cite_ref-11">↑</a></span> <span class="reference-text">In other words, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> is shorthand for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, however, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> simply appends "match" to the parent. Note that you may still call <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> on a parent via <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>.</span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><a href="#cite_ref-12">↑</a></span> <span class="reference-text">This is no different than calling the Stream-Buffer object directly with each item in the <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>; however, after noting how numbers and variables (too shy to <a href="/w/index.php?title=Skinny_dip&action=edit&redlink=1" class="new" title="Skinny dip (stran ne obstaja)">skinny dip</a> without parenthesis) could look rather odd swimming fully clothed in a stream of naked strings, this was made for those whose aesthetics prefer <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> over <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">Stream</span><span class="o">&</span><span class="n">nbsp</span><span class="p">;</span><span class="o">&</span><span class="n">ndash</span><span class="p">;</span> <span class="n">Buffer</span><span class="s1">'A'</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span><span class="s1">'B'</span><span class="p">(</span><span class="n">arg2</span><span class="p">)</span></code>.</span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><a href="#cite_ref-13">↑</a></span> <span class="reference-text">If you want something like <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">:</span><span class="n">wikitext</span><span class="p">(</span><span class="s1">'string1'</span><span class="p">,</span> <span class="n">varName</span><span class="p">,</span> <span class="s1">'string2'</span><span class="p">)</span></code> such that <i>varName</i> is shorthand for an <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kr">if</span></code> statement that appends <i>varName</i> and 'string2' when the former is not nil, use <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">:</span><span class="n">each</span><span class="p">(</span><span class="s1">'string1'</span><span class="p">,</span> <span class="p">{</span><span class="n">varName</span><span class="p">,</span> <span class="s1">'string2'</span><span class="p">})</span></code> instead.</span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><a href="#cite_ref-14">↑</a></span> <span class="reference-text">That is, Element-Buffer<code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">:</span><span class="n">_inHTML</span><span class="s1">'br'</span></code> may be shorthand for <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">:</span><span class="n">tag</span><span class="s1">'br'</span><span class="p">:</span><span class="n">done</span><span class="p">()()</span></code> when planning to continue using Buffer object functions. This "auto-done and back" for selfClosing tags does not apply to non-element Buffers in order not to encourage the use of Buffer:_inHTML for simple tags as per <a href="#Tips_and_style_recommendations">#Tips and style recommendations</a>.</span> </li> <li id="cite_note-15"><span class="mw-cite-backlink"><a href="#cite_ref-15">↑</a></span> <span class="reference-text"><a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> serves a similar role, but appends Buffer objects rather than HTML objects. Also Buffer-HTML:_parent only appends the string form of its ancestor object(s).</span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><a href="#cite_ref-16">↑</a></span> <span class="reference-text">Buffer(-HTML) objects reference their parent differently from mw.html objects. Passing a normal mw.html object to Buffer:_inHTML as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">args.parent</code> and then calling <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> the object created, followed by <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> on the adopted parent, may return the "child." This is a feature rather than a bug.</span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><a href="#cite_ref-17">↑</a></span> <span class="reference-text">—the internal table which holds elements appended via <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, and <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><a href="#cite_ref-18">↑</a></span> <span class="reference-text">Passing arguments for <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> via the <i>args</i> parameter of <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> during the creation of a new Buffer-HTML object is the only way to use most Buffer object functions on the new HTML object without converting its <code>.nodes</code> into an Element-Buffer.</span> </li> <li id="cite_note-19"><span class="mw-cite-backlink"><a href="#cite_ref-19">↑</a></span> <span class="reference-text">That is, Buffer:getHTML may be used to return to the child node, though the trade off is that you may still need to call mw.html:allDone before using these methods in order to append the full HTML tree via <a href="#Buffer:_html">Buffer:_html</a>.</span> </li> <li id="cite_note-20"><span class="mw-cite-backlink"><a href="#cite_ref-20">↑</a></span> <span class="reference-text">While Buffer-HTML objects may use <a href="#global_functions">#global functions</a>, there is no separate Buffer-HTML version. In other words, the self-action of a global function on an Element-Buffer is <u>not</u> redirected.</span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><a href="#cite_ref-21">↑</a></span> <span class="reference-text"><a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> is doubly wrapped for Element-Buffers, with the other wrapper setting a Buffer parent reference as described at <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>. Furthermore, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> and <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> do not call their mw.html namesakes at all, as detailed in their respective sections.</span> </li> <li id="cite_note-22"><span class="mw-cite-backlink"><a href="#cite_ref-22">↑</a></span> <span class="reference-text">However, some Buffer methods may not work properly after appending objects via mw.html functions to the pseudo-Buffer.<br /> For example, <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">{</span> <span class="n">tag</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'div'</span><span class="p">,</span> <span class="s1">'List:'</span><span class="p">,</span> <span class="n">foo1</span><span class="p">,</span> <span class="n">foo2</span><span class="p">,</span> <span class="n">foo3</span><span class="p">,</span> <span class="n">_out</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">*'</span> <span class="p">}</span> <span class="p">}</span> <span class="p">}</span></code> could produce a div with each <i>foo</i> as <a href="/w/index.php?title=Bullet_(typography)&action=edit&redlink=1" class="new" title="Bullet (typography) (stran ne obstaja)">bulleted</a> item. But, if <i>foo1</i> were <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="p">{</span> <span class="n">tag</span> <span class="o">=</span> <span class="p">{</span> <span class="s1">'b'</span><span class="p">,</span> <span class="s1">'text'</span> <span class="p">}</span> <span class="p">}</span></code>, then <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> may fail when appending <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> with the non-string/number element. A workaround is to add the pair <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">_</span> <span class="o">=</span> <span class="p">{</span><span class="kc">true</span><span class="p">,</span> <span class="kc">true</span><span class="p">}</span></code> to set <a href="#raw">raw mode</a> on the div's tag.nodes; another is to replace <i>foo1</i> with <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="n">mw</span><span class="p">.</span><span class="n">html</span><span class="p">.</span><span class="n">create</span><span class="s1">'b'</span><span class="p">:</span><span class="n">wikitext</span><span class="s1">'text'</span></code>, which appends in string form.</span> </li> <li id="cite_note-23"><span class="mw-cite-backlink"><a href="#cite_ref-23">↑</a></span> <span class="reference-text">A caveat of this unconventional type checking is that pairing an args.globalFunction with a number value will throw an error (which shouldn't be a problem since numbers make poor names for global variables).</span> </li> <li id="cite_note-24"><span class="mw-cite-backlink"><a href="#cite_ref-24">↑</a></span> <span class="reference-text">i.e., does <i>x</i>, in the following, reference the TD or some other node hidden within an <a href="/w/index.php?title=Ellipsis&action=edit&redlink=1" class="new" title="Ellipsis (stran ne obstaja)">ellipsis</a>?: <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kd">local</span> <span class="n">x</span> <span class="o">=</span> <span class="n">mw</span><span class="p">.</span><span class="n">html</span><span class="p">.</span><span class="n">create</span><span class="p">():</span><span class="n">tag</span> <span class="p">...</span> <span class="p">:</span><span class="n">tag</span><span class="s1">'td'</span> <span class="p">...</span> <span class="p">:</span><span class="n">tag</span><span class="p">(</span><span class="n">arg</span> <span class="ow">and</span> <span class="s1">'div'</span> <span class="ow">or</span> <span class="s1">'p'</span><span class="p">):</span><span class="n">wikitext</span><span class="p">(</span> <span class="p">...</span> <span class="p">):</span><span class="n">tag</span><span class="s1">'br'</span><span class="p">:</span><span class="n">done</span><span class="p">():</span><span class="n">done</span><span class="p">()</span></code></span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><a href="#cite_ref-25">↑</a></span> <span class="reference-text">Global function are not enabled by default for various reasons: <ul><li>Most templates are one-dimensional (i.e. contain few if any nested conditional statements) and thus would not benefit from these methods.</li> <li>Loading them to the Module:Buffer meta index means more items that must be sifted through each time a specific function has to be retrieved.</li> <li>Lua checks the global scope last; thus retrieving values from that scope takes longer than it would if they were stored in the local scope.</li> <li>Excess use may clutter the global scope enough to slow access to basic Lua functions (e.g. <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> or <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>) even after Buffer methods are no longer used.</li></ul> It should be mentioned however that variable retrieval even even in a relatively cluttered global scope is fairly trivial. In fact, early versions of Module:Buffer used globals extensively (and actually had no locals declared before the final return, or rather the entire module was just one long return statement). In contrast, the current version nests many <code class="mw-highlight mw-highlight-lang-lua mw-content-ltr" style="" dir="ltr"><span class="kr">do</span> <span class="p">...</span> <span class="kr">end</span></code> blocks to limit scope size. Yet, <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, a core function which has changed little, is only a modest 10 percent faster than itself in the last unscoped version (not published); then again, perhaps the benefit of scope dieting has been masked by much greater total number of variables required by new features?</span> </li> <li id="cite_note-26"><span class="mw-cite-backlink"><a href="#cite_ref-26">↑</a></span> <span class="reference-text">Actually, the first argument to rawset is a local variable <code><a href="#new_G">new_G</a></code> which generally equals _G but not always, to be detailed in a later section.</span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><a href="#cite_ref-27">↑</a></span> <span class="reference-text">If the meta global has an __index which is a function (as is the case after requiring <a href="/wiki/Modul:No_globals" title="Modul:No globals">Module:No globals</a>), the back-up op aborts without throwing an error.</span> </li> <li id="cite_note-29"><span class="mw-cite-backlink"><a href="#cite_ref-29">↑</a></span> <span class="reference-text">Dubbing this a "global function" is bit of a misnomer since this never retrieves anything from the global table. While designed for in-chain navigation to Buffer objects that were <a href="#Buffer:_G">self-declared as globals</a>, this returns any local reference or literal passed as well (allowing <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a> to execute Buffer methods on non-Buffer objects <code><a href="#args.globalFunction">args._B</a></code>).</span> </li> <li id="cite_note-32"><span class="mw-cite-backlink"><a href="#cite_ref-32">↑</a></span> <span class="reference-text">False cycles tables based on <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a> instead of <a href="/w/index.php?title=Predloga:Luaref&action=edit&redlink=1" class="new" title="Predloga:Luaref (stran ne obstaja)">Predloga:Luaref</a>, which may diverge or error if the table contains nil items.</span> </li> <li id="cite_note-33"><span class="mw-cite-backlink"><a href="#cite_ref-33">↑</a></span> <span class="reference-text">Though this strings the same object returned by <a href="/w/index.php?title=Predloga:Luaself&action=edit&redlink=1" class="new" title="Predloga:Luaself (stran ne obstaja)">Predloga:Luaself</a>, that function is not used to avoid setting a "lastHTML" reference.</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div> <ul><li><a href="/wiki/Modul:Escape" title="Modul:Escape">Module:Escape</a>, a lightweight metamodule for customized string character escaping</li></ul> <p><br /> </p> <div style="clear: both;"></div> </div><style data-mw-deduplicate="TemplateStyles:r6309533">.mw-parser-output .fmbox{clear:both;margin:0.2em 0;width:100%;border:1px solid #a2a9b1;background-color:var(--background-color-interactive-subtle,#f8f9fa);box-sizing:border-box;color:var(--color-base,#202122)}.mw-parser-output .fmbox-warning{border:1px solid #bb7070;background-color:#ffdbdb}.mw-parser-output .fmbox-editnotice{background-color:transparent}.mw-parser-output .fmbox .mbox-text{border:none;padding:0.25em 0.9em;width:100%}.mw-parser-output .fmbox .mbox-image{border:none;padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .fmbox .mbox-imageright{border:none;padding:2px 0.9em 2px 0;text-align:center}.mw-parser-output .fmbox .mbox-invalid-type{text-align:center}@media screen{html.skin-theme-clientpref-night .mw-parser-output .fmbox-warning{background-color:#300}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .fmbox-warning{background-color:#300}}</style><table id="documentation-meta-data" class="plainlinks fmbox fmbox-system" role="presentation" style="background-color: #ecfcf4;"><tbody><tr><td class="mbox-text" style="font-style: italic;">Zgornja <a href="/wiki/Wikipedija:Dokumentacija_predloge" title="Wikipedija:Dokumentacija predloge">dokumentacija</a> je <a href="https://en.wikipedia.org/wiki/Wikipedia:Transclusion" class="extiw" title="en:Wikipedia:Transclusion">vključena</a> iz <a href="/wiki/Modul:Buffer/dok" title="Modul:Buffer/dok">Modul:Buffer/dok</a>. <small style="font-style: normal">(<a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/dok&action=edit">uredi</a> | <a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/dok&action=history">zgodovina</a>)</small> <br />Urejevalci lahko preizkušate ta modul v peskovniku <small style="font-style: normal">(<a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/peskovnik&action=edit&preload=Predloga:Dokumentacija/preload-module-peskovnik">ustvari</a> | <a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/peskovnik&action=edit&preload=Modul%3ABuffer&summary=Create+sandbox+version+of+%5B%5BModul%3ABuffer%5D%5D">mirror</a>)</small> in testnihprimerih <small style="font-style: normal">(<a class="external text" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer/testniprimeri&action=edit&preload=Predloga:Dokumentacija/preload-module-testniprimeri">ustvari</a>)</small>. <br />Prosimo, da dodate kategorije v <a href="/wiki/Modul:Buffer/dok" title="Modul:Buffer/dok">/dok</a> podstran. <a href="/wiki/Posebno:PrefixIndex/Modul:Buffer/" title="Posebno:PrefixIndex/Modul:Buffer/">Podstrani te predloge</a>.</td></tr></tbody></table><div class="mw-highlight mw-highlight-lang-lua mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos" data-line="1"></span></a><span class="cm">--[[=============================</span> </span><span id="L-2"><a href="#L-2"><span class="linenos" data-line="2"></span></a><span class="cm">This Module was written by Alexander Zhikun He, also known as, User:Codehydro on the English Wikipedia</span> </span><span id="L-3"><a href="#L-3"><span class="linenos" data-line="3"></span></a> </span><span id="L-4"><a href="#L-4"><span class="linenos" data-line="4"></span></a><span class="cm">All methods were developed independently and any resemblance to other string buffer libraries would be coincidental.</span> </span><span id="L-5"><a href="#L-5"><span class="linenos" data-line="5"></span></a><span class="cm">Furthermore, many methods will not work when compiled by standard Lua libraries as they depend on behaviors unique to</span> </span><span id="L-6"><a href="#L-6"><span class="linenos" data-line="6"></span></a><span class="cm">the MediaMiki Scribunto mod, which, for example, has a getmetatable() method that always returns nil on non-tables.</span> </span><span id="L-7"><a href="#L-7"><span class="linenos" data-line="7"></span></a><span class="cm">https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual</span> </span><span id="L-8"><a href="#L-8"><span class="linenos" data-line="8"></span></a> </span><span id="L-9"><a href="#L-9"><span class="linenos" data-line="9"></span></a><span class="cm">Source code comments may be thin at some points because they are intended to be supplemented by the documentation page:</span> </span><span id="L-10"><a href="#L-10"><span class="linenos" data-line="10"></span></a><span class="cm">https://en.wikipedia.org/wiki/Module:Buffer/doc</span> </span><span id="L-11"><a href="#L-11"><span class="linenos" data-line="11"></span></a> </span><span id="L-12"><a href="#L-12"><span class="linenos" data-line="12"></span></a><span class="cm">Licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License</span> </span><span id="L-13"><a href="#L-13"><span class="linenos" data-line="13"></span></a><span class="cm">https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License</span> </span><span id="L-14"><a href="#L-14"><span class="linenos" data-line="14"></span></a> </span><span id="L-15"><a href="#L-15"><span class="linenos" data-line="15"></span></a><span class="cm">https://en.wikipedia.org/wiki/Module:Buffer</span> </span><span id="L-16"><a href="#L-16"><span class="linenos" data-line="16"></span></a><span class="cm">https://en.wikipedia.org/wiki/User:Codehydro</span> </span><span id="L-17"><a href="#L-17"><span class="linenos" data-line="17"></span></a><span class="cm">=============================--]]</span> </span><span id="L-18"><a href="#L-18"><span class="linenos" data-line="18"></span></a><span class="kd">local</span> <span class="kr">function</span> <span class="nf">Valid</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="c1">--type validation</span> </span><span id="L-19"><a href="#L-19"><span class="linenos" data-line="19"></span></a> <span class="kr">if</span> <span class="n">v</span> <span class="ow">and</span> <span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="kr">then</span><span class="c1">--reject nil/boolean; faster than 2 type() comparisons</span> </span><span id="L-20"><a href="#L-20"><span class="linenos" data-line="20"></span></a> <span class="kd">local</span> <span class="n">str</span> <span class="o">=</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="c1">--functions not filtered since unlikely passed by accident (Scribunto does not have userdata/thread types)</span> </span><span id="L-21"><a href="#L-21"><span class="linenos" data-line="21"></span></a> <span class="kr">if</span> <span class="n">str</span><span class="o">~=</span><span class="n">v</span> <span class="ow">and</span> <span class="n">str</span><span class="o">==</span><span class="s1">'table'</span> <span class="kr">then</span> <span class="kr">return</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--tostring(string-type) returns same ref; same refs compare faster than type()</span> </span><span id="L-22"><a href="#L-22"><span class="linenos" data-line="22"></span></a> <span class="kr">if</span> <span class="n">str</span><span class="o">~=</span><span class="s1">''</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">str</span> <span class="kr">end</span><span class="c1">--numbers are coerced to string per table.concat op; appending in string form saves ops on repeat concat</span> </span><span id="L-23"><a href="#L-23"><span class="linenos" data-line="23"></span></a> <span class="kr">end</span> </span><span id="L-24"><a href="#L-24"><span class="linenos" data-line="24"></span></a><span class="kr">end</span> </span><span id="L-25"><a href="#L-25"><span class="linenos" data-line="25"></span></a><span class="kd">local</span> <span class="n">noOp</span><span class="p">,</span> <span class="n">MBpairs</span> <span class="o">=</span> <span class="kr">function</span><span class="p">()</span><span class="kr">end</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">iMap</span><span class="p">,</span> <span class="n">vMap</span><span class="p">,</span> <span class="n">oMap</span><span class="p">,</span> <span class="n">pIter</span><span class="p">,</span> <span class="n">pOther</span><span class="p">,</span> <span class="n">pFast</span><span class="p">,</span> <span class="n">Next</span><span class="c1">--Map</span> </span><span id="L-26"><a href="#L-26"><span class="linenos" data-line="26"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">init</span><span class="p">()</span><span class="c1">--init = noOp after first run</span> </span><span id="L-27"><a href="#L-27"><span class="linenos" data-line="27"></span></a> <span class="kr">function</span> <span class="nf">Next</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">next</span><span class="p">,</span> <span class="n">t</span> <span class="kr">end</span><span class="c1">--slightly faster to do this than to use select()</span> </span><span id="L-28"><a href="#L-28"><span class="linenos" data-line="28"></span></a> <span class="kr">function</span> <span class="nf">pIter</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="n">k</span> <span class="o">=</span> <span class="p">(</span><span class="n">iMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">or</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="ow">and</span> <span class="n">iMap</span><span class="p">[</span><span class="n">t</span><span class="p">])[</span><span class="ow">not</span> <span class="n">k</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="n">k</span><span class="p">]]</span> <span class="kr">return</span> <span class="n">k</span><span class="p">,</span> <span class="n">t</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">end</span><span class="c1">--don't use rawget; accepting unmapped tables does not measurably affect performance.</span> </span><span id="L-29"><a href="#L-29"><span class="linenos" data-line="29"></span></a> <span class="kr">function</span> <span class="nf">pOther</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="n">k</span> <span class="o">=</span> <span class="p">(</span><span class="n">oMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">or</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="ow">and</span> <span class="n">oMap</span><span class="p">[</span><span class="n">t</span><span class="p">])[</span><span class="kc">nil</span><span class="o">==</span><span class="n">k</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="n">k</span><span class="p">]]</span> <span class="kr">return</span> <span class="n">k</span><span class="p">,</span> <span class="n">t</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">end</span><span class="c1">--comparison to nil because false is a valid key</span> </span><span id="L-30"><a href="#L-30"><span class="linenos" data-line="30"></span></a> <span class="kr">function</span> <span class="nf">pFast</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="n">k</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">k</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">k</span> <span class="o"><</span> <span class="p">(</span><span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">or</span> <span class="o">#</span><span class="n">t</span><span class="p">)</span> <span class="ow">and</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span> <span class="ow">or</span> <span class="kc">nil</span> <span class="kr">return</span> <span class="n">k</span><span class="p">,</span> <span class="n">t</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">end</span><span class="c1">--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached</span> </span><span id="L-31"><a href="#L-31"><span class="linenos" data-line="31"></span></a> <span class="c1">--k and k < (vMap[t] or #t) and k + 1 or not k and 1 or nil return k, t[k] end--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached</span> </span><span id="L-32"><a href="#L-32"><span class="linenos" data-line="32"></span></a> <span class="kd">local</span> <span class="n">mk</span> <span class="o">=</span> <span class="p">{</span><span class="n">__mode</span> <span class="o">=</span> <span class="s1">'k'</span><span class="p">}</span><span class="c1">--use mode 'k'; found that mode 'kv' sometimes garbage collects maps mid-loop (may not error because iterators auto re-map, but that's expensive)</span> </span><span id="L-33"><a href="#L-33"><span class="linenos" data-line="33"></span></a> <span class="n">init</span><span class="p">,</span> <span class="n">iMap</span><span class="p">,</span> <span class="n">vMap</span><span class="p">,</span> <span class="n">oMap</span> <span class="o">=</span> <span class="n">noOp</span><span class="p">,</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mk</span><span class="p">),</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mk</span><span class="p">),</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mk</span><span class="p">)</span><span class="c1">--iMap is numeric keys, oMap is non-numeric keys, and vMap points to next key</span> </span><span id="L-34"><a href="#L-34"><span class="linenos" data-line="34"></span></a> <span class="kr">end</span> </span><span id="L-35"><a href="#L-35"><span class="linenos" data-line="35"></span></a> <span class="kr">function</span> <span class="nf">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span><span class="c1">--pairs always iterates in order</span> </span><span id="L-36"><a href="#L-36"><span class="linenos" data-line="36"></span></a> <span class="kd">local</span> <span class="n">iter</span><span class="p">,</span> <span class="n">ex</span> <span class="o">=</span> <span class="p">...</span> </span><span id="L-37"><a href="#L-37"><span class="linenos" data-line="37"></span></a> <span class="n">iter</span> <span class="o">=</span> <span class="n">iter</span><span class="o">==</span><span class="n">init</span><span class="p">()</span><span class="c1">--nil</span> </span><span id="L-38"><a href="#L-38"><span class="linenos" data-line="38"></span></a> <span class="kr">if</span> <span class="n">iter</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">oMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ex</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">and</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">~=</span><span class="kc">nil</span> <span class="ow">and</span> <span class="nb">next</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="o">#</span><span class="n">t</span><span class="p">)</span><span class="o">==</span><span class="kc">nil</span> <span class="kr">then</span><span class="c1">--while possible to miss keys, more thorough check would negate the benefit of pFast</span> </span><span id="L-39"><a href="#L-39"><span class="linenos" data-line="39"></span></a> <span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">=</span> <span class="o">#</span><span class="n">t</span> <span class="kr">return</span> <span class="n">pFast</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="kc">nil</span> </span><span id="L-40"><a href="#L-40"><span class="linenos" data-line="40"></span></a> <span class="kr">elseif</span> <span class="p">...</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">or</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">~=</span><span class="mi">1</span> <span class="kr">then</span> </span><span id="L-41"><a href="#L-41"><span class="linenos" data-line="41"></span></a> <span class="kd">local</span> <span class="n">ti</span><span class="p">,</span> <span class="n">tn</span><span class="p">,</span> <span class="n">to</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="p">{},</span> <span class="p">{},</span> <span class="p">{},</span> <span class="o">#</span><span class="n">t</span><span class="c1">--reduces table lookups</span> </span><span id="L-42"><a href="#L-42"><span class="linenos" data-line="42"></span></a> <span class="n">iMap</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">vMap</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">oMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">=</span> <span class="n">ti</span><span class="p">,</span> <span class="n">tn</span><span class="p">,</span> <span class="n">to</span> </span><span id="L-43"><a href="#L-43"><span class="linenos" data-line="43"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">n</span> <span class="kr">do</span> <span class="n">ti</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">tn</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">k</span><span class="p">,</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span> <span class="kr">end</span><span class="c1">--stage one avoids number type checking op in stage two for most numeric keys</span> </span><span id="L-44"><a href="#L-44"><span class="linenos" data-line="44"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="kr">in</span> <span class="p">(</span><span class="n">ex</span> <span class="ow">or</span> <span class="n">Next</span><span class="p">)(</span><span class="n">t</span><span class="p">)</span> <span class="kr">do</span> </span><span id="L-45"><a href="#L-45"><span class="linenos" data-line="45"></span></a> <span class="kr">if</span> <span class="ow">not</span> <span class="n">tn</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">then</span> <span class="nb">table.insert</span><span class="p">(</span><span class="nb">tonumber</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">~=</span><span class="n">k</span> <span class="ow">and</span> <span class="n">to</span> <span class="ow">or</span> <span class="n">ti</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-46"><a href="#L-46"><span class="linenos" data-line="46"></span></a> <span class="kr">end</span> </span><span id="L-47"><a href="#L-47"><span class="linenos" data-line="47"></span></a> <span class="kr">if</span> <span class="o">#</span><span class="n">ti</span><span class="o">~=</span><span class="n">n</span> <span class="kr">then</span> </span><span id="L-48"><a href="#L-48"><span class="linenos" data-line="48"></span></a> <span class="nb">table.sort</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> </span><span id="L-49"><a href="#L-49"><span class="linenos" data-line="49"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="o">#</span><span class="n">ti</span> <span class="kr">do</span> <span class="n">tn</span><span class="p">[</span><span class="n">ti</span><span class="p">[</span><span class="n">k</span><span class="p">]]</span> <span class="o">=</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span> <span class="kr">end</span><span class="c1">--somewhat wasteful, but trying to avoid overwriting can be even more expensive</span> </span><span id="L-50"><a href="#L-50"><span class="linenos" data-line="50"></span></a> <span class="kr">end</span> </span><span id="L-51"><a href="#L-51"><span class="linenos" data-line="51"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="o">#</span><span class="n">to</span> <span class="kr">do</span> <span class="n">tn</span><span class="p">[</span><span class="n">to</span><span class="p">[</span><span class="n">k</span><span class="p">]]</span> <span class="o">=</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span> <span class="kr">end</span> </span><span id="L-52"><a href="#L-52"><span class="linenos" data-line="52"></span></a> <span class="kr">end</span> </span><span id="L-53"><a href="#L-53"><span class="linenos" data-line="53"></span></a> <span class="kr">return</span> <span class="n">iter</span> <span class="ow">and</span> <span class="n">pIter</span> <span class="ow">or</span> <span class="n">oMap</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">pOther</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">,</span> <span class="n">t</span><span class="c1">--noOp for mapless</span> </span><span id="L-54"><a href="#L-54"><span class="linenos" data-line="54"></span></a> <span class="kr">end</span> </span><span id="L-55"><a href="#L-55"><span class="linenos" data-line="55"></span></a><span class="kr">end</span> </span><span id="L-56"><a href="#L-56"><span class="linenos" data-line="56"></span></a><span class="kd">local</span> <span class="n">parent</span><span class="p">,</span> <span class="n">rawkey</span><span class="p">,</span> <span class="n">spec</span> <span class="kr">do</span><span class="c1">--new scope for variables not reused outside (reduces number of var names that need to checked outside of scope)</span> </span><span id="L-57"><a href="#L-57"><span class="linenos" data-line="57"></span></a> <span class="kd">local</span> <span class="n">mkv</span> <span class="o">=</span> <span class="p">{</span><span class="n">__mode</span><span class="o">=</span><span class="s1">'kv'</span><span class="p">,</span> <span class="n">__call</span><span class="o">=</span><span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="n">k</span><span class="p">,</span><span class="n">v</span><span class="p">)</span><span class="n">t</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">=</span><span class="n">v</span> <span class="kr">return</span> <span class="n">k</span> <span class="kr">end</span><span class="p">}</span><span class="c1">--shared meta for Buffer parent property, raw mode, and specialized functions</span> </span><span id="L-58"><a href="#L-58"><span class="linenos" data-line="58"></span></a> <span class="n">parent</span><span class="p">,</span> <span class="n">rawkey</span><span class="p">,</span> <span class="n">spec</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mkv</span><span class="p">),</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mkv</span><span class="p">),</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">mkv</span><span class="p">)</span><span class="c1">--shared meta less memory</span> </span><span id="L-59"><a href="#L-59"><span class="linenos" data-line="59"></span></a><span class="kr">end</span> </span><span id="L-60"><a href="#L-60"><span class="linenos" data-line="60"></span></a> </span><span id="L-61"><a href="#L-61"><span class="linenos" data-line="61"></span></a><span class="kd">local</span> <span class="n">MB</span><span class="p">,</span> <span class="n">MBi</span><span class="p">,</span> <span class="n">MBmix</span><span class="p">,</span> <span class="n">buffHTML</span><span class="p">,</span> <span class="n">gfuncs</span><span class="p">,</span> <span class="n">noCache</span><span class="p">,</span> <span class="n">Element</span> <span class="kr">do</span><span class="c1">--minimize number of locals per scope to reduce time spent sifting through irrelevant variable names</span> </span><span id="L-62"><a href="#L-62"><span class="linenos" data-line="62"></span></a> <span class="kd">local</span> <span class="n">_stream</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">stream</span><span class="c1">--keep stream near top of scope</span> </span><span id="L-63"><a href="#L-63"><span class="linenos" data-line="63"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">init</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="c1">--init = noOp after first run</span> </span><span id="L-64"><a href="#L-64"><span class="linenos" data-line="64"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">each</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-65"><a href="#L-65"><span class="linenos" data-line="65"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">do</span> </span><span id="L-66"><a href="#L-66"><span class="linenos" data-line="66"></span></a> <span class="n">k</span> <span class="o">=</span> <span class="n">Valid</span><span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="p">...))</span><span class="c1">--slightly faster than table.insert(self, (Valid(select(k, ...))))</span> </span><span id="L-67"><a href="#L-67"><span class="linenos" data-line="67"></span></a> <span class="kr">if</span> <span class="n">k</span> <span class="kr">then</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-68"><a href="#L-68"><span class="linenos" data-line="68"></span></a> <span class="kr">end</span> </span><span id="L-69"><a href="#L-69"><span class="linenos" data-line="69"></span></a> <span class="kr">return</span> <span class="n">self</span> </span><span id="L-70"><a href="#L-70"><span class="linenos" data-line="70"></span></a> <span class="kr">end</span> </span><span id="L-71"><a href="#L-71"><span class="linenos" data-line="71"></span></a> <span class="n">init</span><span class="p">,</span> <span class="n">stream</span><span class="p">,</span> <span class="n">_stream</span> <span class="o">=</span> <span class="n">noOp</span><span class="p">,</span> <span class="p">{</span> </span><span id="L-72"><a href="#L-72"><span class="linenos" data-line="72"></span></a> <span class="n">__call</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="n">v</span> <span class="o">=</span> <span class="n">v</span> <span class="ow">and</span> <span class="n">Valid</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">return</span> <span class="n">v</span> <span class="ow">and</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="ow">or</span> <span class="n">t</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--last_concat cleared before entering stream mode</span> </span><span id="L-73"><a href="#L-73"><span class="linenos" data-line="73"></span></a> <span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="kr">return</span> <span class="n">i</span><span class="o">==</span><span class="s1">'each'</span> <span class="ow">and</span> <span class="n">each</span> <span class="ow">or</span> <span class="n">MB</span><span class="p">.</span><span class="n">__index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">MB</span><span class="p">)[</span><span class="n">i</span><span class="p">]</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--no table look up minimizes resources to retrieve the only stream function</span> </span><span id="L-74"><a href="#L-74"><span class="linenos" data-line="74"></span></a> <span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">MB</span><span class="p">)()</span> <span class="kr">end</span> </span><span id="L-75"><a href="#L-75"><span class="linenos" data-line="75"></span></a> <span class="p">}</span> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="n">MB</span> <span class="kr">do</span> <span class="n">stream</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">stream</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="n">v</span> <span class="kr">end</span> </span><span id="L-76"><a href="#L-76"><span class="linenos" data-line="76"></span></a> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">stream</span><span class="p">,</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">MB</span><span class="p">))</span> </span><span id="L-77"><a href="#L-77"><span class="linenos" data-line="77"></span></a> <span class="kr">end</span> </span><span id="L-78"><a href="#L-78"><span class="linenos" data-line="78"></span></a> <span class="kr">function</span> <span class="nf">_stream</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="n">self</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="n">init</span><span class="p">()</span> <span class="kr">return</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">stream</span><span class="p">):</span><span class="n">each</span><span class="p">(...)</span> <span class="kr">end</span> </span><span id="L-79"><a href="#L-79"><span class="linenos" data-line="79"></span></a> <span class="kr">end</span> </span><span id="L-80"><a href="#L-80"><span class="linenos" data-line="80"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">isMBfunc</span><span class="p">(</span><span class="n">Buffer</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="p">...)</span><span class="c1">--helper for :getParent()-like methods (including getBuffer which does not return a parent)</span> </span><span id="L-81"><a href="#L-81"><span class="linenos" data-line="81"></span></a> <span class="kr">return</span> <span class="n">s</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="ow">and</span><span class="c1">--eventually should figure out to make this work for :getHTML which is very similar</span> </span><span id="L-82"><a href="#L-82"><span class="linenos" data-line="82"></span></a> <span class="p">(</span><span class="ow">not</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">s</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">s</span><span class="p">):</span><span class="n">match</span><span class="s1">'^_.*'</span> <span class="ow">and</span> <span class="n">MB</span><span class="p">.</span><span class="n">__index</span><span class="p">(</span><span class="n">Buffer</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span> <span class="ow">and</span> <span class="n">MB</span><span class="p">.</span><span class="n">__index</span><span class="p">(</span><span class="n">Buffer</span><span class="p">,</span> <span class="n">s</span><span class="p">)(</span><span class="n">Buffer</span><span class="p">)</span> <span class="ow">or</span> <span class="n">MBmix</span><span class="p">(</span><span class="n">Buffer</span><span class="p">,</span> <span class="n">s</span><span class="p">))</span><span class="c1">--unprefixed function names append as a string</span> </span><span id="L-83"><a href="#L-83"><span class="linenos" data-line="83"></span></a> <span class="ow">or</span> <span class="nb">assert</span><span class="p">(</span><span class="n">MB</span><span class="p">.</span><span class="n">__index</span><span class="p">(</span><span class="n">Buffer</span><span class="p">,</span> <span class="n">s</span><span class="p">),</span> <span class="p">(</span><span class="s1">'" %s " does not match any available Module:Buffer function'</span><span class="p">):</span><span class="n">format</span><span class="p">(</span><span class="n">s</span><span class="p">))(</span><span class="n">Buffer</span><span class="p">,</span> <span class="p">...)</span><span class="c1">--getParent is a one-way trip so one-time assert not expensive</span> </span><span id="L-84"><a href="#L-84"><span class="linenos" data-line="84"></span></a> <span class="p">)</span> <span class="ow">or</span> <span class="n">Buffer</span> </span><span id="L-85"><a href="#L-85"><span class="linenos" data-line="85"></span></a> <span class="kr">end</span> </span><span id="L-86"><a href="#L-86"><span class="linenos" data-line="86"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">MBselect</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="p">...)</span><span class="c1">--helper for :_out and :_str</span> </span><span id="L-87"><a href="#L-87"><span class="linenos" data-line="87"></span></a> <span class="kd">local</span> <span class="n">n</span><span class="p">,</span> <span class="n">seps</span> <span class="o">=</span> <span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="p">{</span><span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...)}</span> </span><span id="L-88"><a href="#L-88"><span class="linenos" data-line="88"></span></a> <span class="kr">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">seps</span><span class="p">[</span><span class="n">n</span><span class="p">])</span><span class="o">==</span><span class="s1">'table'</span> <span class="kr">then</span> </span><span id="L-89"><a href="#L-89"><span class="linenos" data-line="89"></span></a> <span class="kr">if</span> <span class="n">buffHTML</span> <span class="ow">and</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">seps</span><span class="p">[</span><span class="n">n</span><span class="p">],</span> <span class="n">buffHTML</span><span class="p">)</span> <span class="kr">then</span> <span class="kr">return</span> <span class="p">...</span> <span class="kr">end</span> </span><span id="L-90"><a href="#L-90"><span class="linenos" data-line="90"></span></a> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">seps</span><span class="p">,</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">seps</span><span class="p">[</span><span class="n">n</span><span class="p">],</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="kr">end</span><span class="p">})})[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="kc">nil</span> </span><span id="L-91"><a href="#L-91"><span class="linenos" data-line="91"></span></a> <span class="kr">end</span> </span><span id="L-92"><a href="#L-92"><span class="linenos" data-line="92"></span></a> <span class="kr">return</span> <span class="p">...,</span> <span class="n">seps</span> </span><span id="L-93"><a href="#L-93"><span class="linenos" data-line="93"></span></a> <span class="kr">end</span> </span><span id="L-94"><a href="#L-94"><span class="linenos" data-line="94"></span></a> <span class="kd">local</span> <span class="n">_inHTML</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">lastBuffer</span><span class="p">,</span> <span class="n">lastHTML</span> </span><span id="L-95"><a href="#L-95"><span class="linenos" data-line="95"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">init</span><span class="p">(...)</span><span class="c1">--init replaced and new version called on return</span> </span><span id="L-96"><a href="#L-96"><span class="linenos" data-line="96"></span></a> <span class="kd">local</span> <span class="n">create</span><span class="p">,</span> <span class="n">mwFunc</span> <span class="o">=</span> <span class="n">mw</span><span class="p">.</span><span class="n">html</span><span class="p">.</span><span class="n">create</span> <span class="kr">do</span> </span><span id="L-97"><a href="#L-97"><span class="linenos" data-line="97"></span></a> <span class="kd">local</span> <span class="n">mwHTMLmeta</span> <span class="o">=</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">create</span><span class="p">())</span> </span><span id="L-98"><a href="#L-98"><span class="linenos" data-line="98"></span></a> <span class="n">buffHTML</span><span class="p">,</span> <span class="n">mwFunc</span><span class="p">,</span> <span class="n">_inHTML</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">mw</span><span class="p">.</span><span class="n">clone</span><span class="p">(</span><span class="n">mwHTMLmeta</span><span class="p">),</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">MB</span><span class="p">)),</span> <span class="n">mwHTMLmeta</span><span class="p">.</span><span class="n">__index</span><span class="c1">--buffHTML declared near top of module; remove _inHTML from outer scope</span> </span><span id="L-99"><a href="#L-99"><span class="linenos" data-line="99"></span></a> <span class="kr">function</span> <span class="nf">init</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-100"><a href="#L-100"><span class="linenos" data-line="100"></span></a> <span class="kd">local</span> <span class="n">name</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">tag</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(...</span> <span class="ow">and</span> <span class="nb">type</span><span class="p">(...)</span><span class="o">==</span><span class="s1">'table'</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-101"><a href="#L-101"><span class="linenos" data-line="101"></span></a> <span class="n">tag</span> <span class="o">=</span> <span class="n">create</span><span class="p">(</span><span class="n">Valid</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> </span><span id="L-102"><a href="#L-102"><span class="linenos" data-line="102"></span></a> <span class="kr">if</span> <span class="n">nodes</span> <span class="kr">then</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">tag</span><span class="p">.</span><span class="n">parent</span> <span class="ow">and</span> <span class="n">tag</span> <span class="ow">or</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">tag</span><span class="p">,</span> <span class="s1">'parent'</span><span class="p">,</span> <span class="n">parent</span><span class="p">[</span><span class="n">nodes</span><span class="p">]))</span> <span class="kr">end</span> </span><span id="L-103"><a href="#L-103"><span class="linenos" data-line="103"></span></a> <span class="kr">if</span> <span class="n">args</span> <span class="kr">then</span> </span><span id="L-104"><a href="#L-104"><span class="linenos" data-line="104"></span></a> <span class="kd">local</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">selfClosing</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">parent</span> </span><span id="L-105"><a href="#L-105"><span class="linenos" data-line="105"></span></a> <span class="n">args</span><span class="p">.</span><span class="n">selfClosing</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="kc">nil</span> </span><span id="L-106"><a href="#L-106"><span class="linenos" data-line="106"></span></a> <span class="kr">if</span> <span class="nb">next</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Element</span><span class="p">.</span><span class="n">_add</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">tag</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="n">tag</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-107"><a href="#L-107"><span class="linenos" data-line="107"></span></a> <span class="n">args</span><span class="p">.</span><span class="n">selfClosing</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="c1">--in case args is reused</span> </span><span id="L-108"><a href="#L-108"><span class="linenos" data-line="108"></span></a> <span class="kr">end</span> </span><span id="L-109"><a href="#L-109"><span class="linenos" data-line="109"></span></a> <span class="kr">return</span> <span class="n">tag</span> </span><span id="L-110"><a href="#L-110"><span class="linenos" data-line="110"></span></a> <span class="kr">end</span> </span><span id="L-111"><a href="#L-111"><span class="linenos" data-line="111"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="p">{[</span><span class="n">mw</span><span class="p">]</span> <span class="o">=</span> <span class="n">mwHTMLmeta</span><span class="p">,</span> </span><span id="L-112"><a href="#L-112"><span class="linenos" data-line="112"></span></a> <span class="n">__call</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">return</span> <span class="n">MBmix</span><span class="p">(</span><span class="n">spec</span><span class="p">[</span><span class="n">h</span><span class="p">.</span><span class="n">nodes</span><span class="p">]</span> <span class="ow">and</span> <span class="n">h</span><span class="p">.</span><span class="n">nodes</span> <span class="ow">or</span> <span class="n">spec</span><span class="p">(</span><span class="nb">setmetatable</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">h</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="n">h</span><span class="p">),</span> <span class="n">MB</span><span class="p">),</span> <span class="n">Element</span><span class="p">),</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-113"><a href="#L-113"><span class="linenos" data-line="113"></span></a> <span class="n">__concat</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span><span class="c1">--false means take from MB</span> </span><span id="L-114"><a href="#L-114"><span class="linenos" data-line="114"></span></a> <span class="n">__eq</span> <span class="o">=</span> <span class="kc">false</span> </span><span id="L-115"><a href="#L-115"><span class="linenos" data-line="115"></span></a> <span class="p">}</span> <span class="kr">do</span> <span class="n">buffHTML</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> <span class="ow">or</span> <span class="n">MB</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">end</span> </span><span id="L-116"><a href="#L-116"><span class="linenos" data-line="116"></span></a> <span class="kr">end</span> </span><span id="L-117"><a href="#L-117"><span class="linenos" data-line="117"></span></a> <span class="kd">local</span> <span class="n">nonSelf</span><span class="p">,</span> <span class="n">BHi</span> <span class="o">=</span> <span class="p">{</span><span class="n">tag</span><span class="o">=</span><span class="kc">true</span><span class="p">,</span><span class="n">done</span><span class="o">=</span><span class="kc">true</span><span class="p">,</span><span class="n">allDone</span><span class="o">=</span><span class="kc">true</span><span class="p">},</span> <span class="n">buffHTML</span><span class="p">.</span><span class="n">__index</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">g</span> </span><span id="L-118"><a href="#L-118"><span class="linenos" data-line="118"></span></a> <span class="n">g</span> <span class="o">=</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> </span><span id="L-119"><a href="#L-119"><span class="linenos" data-line="119"></span></a> <span class="kr">if</span> <span class="n">gfuncs</span> <span class="ow">and</span> <span class="n">gfuncs</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">then</span> <span class="n">g</span><span class="p">.</span><span class="n">__index</span><span class="p">,</span> <span class="n">gfuncs</span> <span class="o">=</span> <span class="n">gfuncs</span> <span class="kr">return</span> <span class="n">g</span><span class="p">.</span><span class="n">__index</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">end</span> </span><span id="L-120"><a href="#L-120"><span class="linenos" data-line="120"></span></a> <span class="kr">end</span><span class="p">}</span> </span><span id="L-121"><a href="#L-121"><span class="linenos" data-line="121"></span></a> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">nonSelf</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span> </span><span id="L-122"><a href="#L-122"><span class="linenos" data-line="122"></span></a> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">BHi</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span> </span><span id="L-123"><a href="#L-123"><span class="linenos" data-line="123"></span></a> <span class="kr">end</span> </span><span id="L-124"><a href="#L-124"><span class="linenos" data-line="124"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="n">nonSelf</span> <span class="kr">do</span><span class="c1">--any HTML objects returned by these funcs will be granted Module:Buffer enhancements</span> </span><span id="L-125"><a href="#L-125"><span class="linenos" data-line="125"></span></a> <span class="kd">local</span> <span class="n">func</span> <span class="o">=</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> </span><span id="L-126"><a href="#L-126"><span class="linenos" data-line="126"></span></a> <span class="n">BHi</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> <span class="kd">local</span> <span class="n">HTML</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">HTML</span><span class="p">]</span> <span class="ow">and</span> <span class="n">HTML</span> <span class="ow">or</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">buffHTML</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-127"><a href="#L-127"><span class="linenos" data-line="127"></span></a> <span class="kr">end</span> </span><span id="L-128"><a href="#L-128"><span class="linenos" data-line="128"></span></a> <span class="kr">do</span> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> </span><span id="L-129"><a href="#L-129"><span class="linenos" data-line="129"></span></a> <span class="kd">local</span> <span class="n">nodes</span><span class="p">,</span> <span class="n">join</span> <span class="o">=</span> <span class="n">HTML</span><span class="p">.</span><span class="n">nodes</span> </span><span id="L-130"><a href="#L-130"><span class="linenos" data-line="130"></span></a> <span class="kr">if</span> <span class="n">noCache</span> <span class="ow">and</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">sep</span><span class="p">]</span> <span class="ow">or</span> <span class="n">Valid</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> <span class="kr">then</span> <span class="n">join</span><span class="p">,</span> <span class="n">HTML</span><span class="p">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="nb">tostring</span><span class="p">(</span><span class="nb">rawset</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="s1">'nodes'</span><span class="p">,</span> <span class="p">{</span><span class="n">MB</span><span class="p">.</span><span class="n">__call</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">sep</span><span class="p">)})),</span> <span class="n">nodes</span> <span class="kr">end</span> </span><span id="L-131"><a href="#L-131"><span class="linenos" data-line="131"></span></a> <span class="kr">return</span> <span class="n">join</span> <span class="ow">or</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">HTML</span><span class="p">)</span> </span><span id="L-132"><a href="#L-132"><span class="linenos" data-line="132"></span></a> <span class="kr">end</span> </span><span id="L-133"><a href="#L-133"><span class="linenos" data-line="133"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="p">{</span> </span><span id="L-134"><a href="#L-134"><span class="linenos" data-line="134"></span></a> <span class="n">getParent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> <span class="n">lastHTML</span> <span class="o">=</span> <span class="n">HTML</span> <span class="kr">return</span> <span class="n">MBi</span><span class="p">.</span><span class="n">getParent</span><span class="p">(</span><span class="n">HTML</span><span class="p">:</span><span class="n">allDone</span><span class="p">(),</span> <span class="p">...)</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--return to Buffer that created the HTML tree</span> </span><span id="L-135"><a href="#L-135"><span class="linenos" data-line="135"></span></a> <span class="n">getBuffer</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> <span class="n">lastHTML</span> <span class="o">=</span> <span class="n">HTML</span> <span class="kr">return</span> <span class="n">isMBfunc</span><span class="p">(</span><span class="n">lastBuffer</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--return to last used</span> </span><span id="L-136"><a href="#L-136"><span class="linenos" data-line="136"></span></a> <span class="n">killParent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> <span class="n">MBi</span><span class="p">.</span><span class="n">killParent</span><span class="p">(</span><span class="n">HTML</span><span class="p">:</span><span class="n">allDone</span><span class="p">(),</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">HTML</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-137"><a href="#L-137"><span class="linenos" data-line="137"></span></a> <span class="n">_out</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-138"><a href="#L-138"><span class="linenos" data-line="138"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">==</span><span class="mi">0</span> <span class="kr">then</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_out</span><span class="p">(</span><span class="n">HTML</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">HTML</span> <span class="kr">end</span> </span><span id="L-139"><a href="#L-139"><span class="linenos" data-line="139"></span></a> <span class="n">lastHTML</span><span class="p">,</span> <span class="n">HTML</span> <span class="o">=</span> <span class="n">HTML</span><span class="p">,</span> <span class="n">HTML</span><span class="p">:</span><span class="n">allDone</span><span class="p">()</span> </span><span id="L-140"><a href="#L-140"><span class="linenos" data-line="140"></span></a> <span class="kd">local</span> <span class="n">n</span><span class="p">,</span> <span class="n">ops</span><span class="p">,</span> <span class="n">seps</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-141"><a href="#L-141"><span class="linenos" data-line="141"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span> </span><span id="L-142"><a href="#L-142"><span class="linenos" data-line="142"></span></a> <span class="kd">local</span> <span class="n">ops</span><span class="p">,</span> <span class="n">seps</span> <span class="o">=</span> <span class="n">MBselect</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-143"><a href="#L-143"><span class="linenos" data-line="143"></span></a> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">HTML</span><span class="p">]:</span><span class="n">_in</span><span class="p">(</span><span class="n">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">seps</span><span class="p">,</span> <span class="mi">0</span><span class="p">))):</span><span class="n">_out</span><span class="p">(</span><span class="n">ops</span><span class="p">,</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">seps</span><span class="p">,</span> <span class="n">buffHTML</span><span class="p">,</span> <span class="kc">true</span><span class="p">))</span> </span><span id="L-144"><a href="#L-144"><span class="linenos" data-line="144"></span></a> <span class="kr">end</span> </span><span id="L-145"><a href="#L-145"><span class="linenos" data-line="145"></span></a> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">HTML</span><span class="p">]:</span><span class="n">_</span><span class="p">(</span><span class="n">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...))</span> </span><span id="L-146"><a href="#L-146"><span class="linenos" data-line="146"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-147"><a href="#L-147"><span class="linenos" data-line="147"></span></a> <span class="n">_str</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span><span class="c1">--does not set lastHTML</span> </span><span id="L-148"><a href="#L-148"><span class="linenos" data-line="148"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">==</span><span class="mi">0</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...))</span> <span class="kr">end</span><span class="c1">--passing 0 strings without calling allDone()</span> </span><span id="L-149"><a href="#L-149"><span class="linenos" data-line="149"></span></a> <span class="kd">local</span> <span class="n">HTML</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="n">HTML</span><span class="p">:</span><span class="n">allDone</span><span class="p">(),</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-150"><a href="#L-150"><span class="linenos" data-line="150"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span> </span><span id="L-151"><a href="#L-151"><span class="linenos" data-line="151"></span></a> <span class="kd">local</span> <span class="n">ops</span><span class="p">,</span> <span class="n">seps</span> <span class="o">=</span> <span class="n">MBselect</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-152"><a href="#L-152"><span class="linenos" data-line="152"></span></a> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">HTML</span><span class="p">]:</span><span class="n">_in</span><span class="p">(</span><span class="n">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">seps</span><span class="p">,</span> <span class="mi">1</span><span class="p">))):</span><span class="n">_str</span><span class="p">(</span><span class="n">ops</span><span class="p">,</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">seps</span><span class="p">,</span> <span class="n">buffHTML</span><span class="p">,</span> <span class="kc">true</span><span class="p">))</span> </span><span id="L-153"><a href="#L-153"><span class="linenos" data-line="153"></span></a> <span class="kr">end</span> </span><span id="L-154"><a href="#L-154"><span class="linenos" data-line="154"></span></a> <span class="kr">return</span> <span class="n">joinNode</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-155"><a href="#L-155"><span class="linenos" data-line="155"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-156"><a href="#L-156"><span class="linenos" data-line="156"></span></a> <span class="n">_parent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="p">...)</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">HTML</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="n">parent</span><span class="p">[</span><span class="n">HTML</span><span class="p">:</span><span class="n">allDone</span><span class="p">()]:</span><span class="n">_str</span><span class="p">(...))</span> <span class="kr">return</span> <span class="n">HTML</span> <span class="kr">end</span> </span><span id="L-157"><a href="#L-157"><span class="linenos" data-line="157"></span></a> <span class="p">}</span> <span class="kr">do</span> <span class="n">BHi</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> <span class="kr">end</span> </span><span id="L-158"><a href="#L-158"><span class="linenos" data-line="158"></span></a> <span class="kr">end</span> </span><span id="L-159"><a href="#L-159"><span class="linenos" data-line="159"></span></a> <span class="kr">do</span> <span class="kd">local</span> <span class="n">htmlArg</span><span class="p">,</span> <span class="n">skip</span><span class="p">,</span> <span class="n">outFuncs</span> <span class="o">=</span> <span class="p">{</span><span class="n">parent</span><span class="o">=</span><span class="kc">true</span><span class="p">,</span><span class="n">selfClosing</span><span class="o">=</span><span class="kc">true</span><span class="p">,</span><span class="n">tagName</span><span class="o">=</span><span class="kc">true</span><span class="p">},</span> <span class="p">{}</span> </span><span id="L-160"><a href="#L-160"><span class="linenos" data-line="160"></span></a> <span class="kr">do</span> <span class="kd">local</span> <span class="n">out</span> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">func</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">out</span><span class="p">(</span><span class="n">parent</span><span class="p">[</span><span class="n">nodes</span><span class="p">],</span> <span class="p">...)</span> <span class="kr">end</span> </span><span id="L-161"><a href="#L-161"><span class="linenos" data-line="161"></span></a> <span class="n">outFuncs</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">({</span> </span><span id="L-162"><a href="#L-162"><span class="linenos" data-line="162"></span></a> <span class="n">tag</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">(</span><span class="nb">setmetatable</span><span class="p">(</span><span class="n">init</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="p">...),</span> <span class="n">buffHTML</span><span class="p">),</span> <span class="n">parent</span><span class="p">[</span><span class="n">nodes</span><span class="p">])</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-163"><a href="#L-163"><span class="linenos" data-line="163"></span></a> <span class="n">done</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">ops</span><span class="p">)</span> </span><span id="L-164"><a href="#L-164"><span class="linenos" data-line="164"></span></a> <span class="n">b</span> <span class="o">=</span> <span class="n">parent</span><span class="p">[</span><span class="n">b</span><span class="p">]</span> </span><span id="L-165"><a href="#L-165"><span class="linenos" data-line="165"></span></a> <span class="kr">while</span> <span class="n">b</span><span class="p">.</span><span class="n">parent</span> <span class="ow">and</span> <span class="n">ops</span><span class="o">~=</span><span class="mi">0</span> <span class="kr">do</span> <span class="n">b</span><span class="p">,</span> <span class="n">ops</span> <span class="o">=</span> <span class="n">b</span><span class="p">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">ops</span> <span class="ow">and</span> <span class="n">ops</span> <span class="o">-</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">0</span> <span class="kr">end</span> </span><span id="L-166"><a href="#L-166"><span class="linenos" data-line="166"></span></a> <span class="kr">return</span> <span class="n">b</span> </span><span id="L-167"><a href="#L-167"><span class="linenos" data-line="167"></span></a> <span class="kr">end</span> </span><span id="L-168"><a href="#L-168"><span class="linenos" data-line="168"></span></a> <span class="p">},</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> </span><span id="L-169"><a href="#L-169"><span class="linenos" data-line="169"></span></a> <span class="kr">if</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">BHi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="kr">then</span> <span class="n">out</span> <span class="o">=</span> <span class="n">BHi</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">return</span> <span class="n">func</span> <span class="kr">end</span><span class="c1">--rawget to exclude globals</span> </span><span id="L-170"><a href="#L-170"><span class="linenos" data-line="170"></span></a> <span class="kr">end</span><span class="p">})</span> </span><span id="L-171"><a href="#L-171"><span class="linenos" data-line="171"></span></a> <span class="kr">end</span> </span><span id="L-172"><a href="#L-172"><span class="linenos" data-line="172"></span></a> <span class="n">Element</span> <span class="o">=</span> <span class="p">{</span> </span><span id="L-173"><a href="#L-173"><span class="linenos" data-line="173"></span></a> <span class="n">_add</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> </span><span id="L-174"><a href="#L-174"><span class="linenos" data-line="174"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">t</span><span class="p">,</span> <span class="n">skip</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="kr">do</span> <span class="p">(</span><span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="n">MBmix</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">)(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-175"><a href="#L-175"><span class="linenos" data-line="175"></span></a> <span class="kd">local</span> <span class="n">HTML</span> <span class="o">=</span> <span class="n">parent</span><span class="p">[</span><span class="n">nodes</span><span class="p">]</span> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="kc">false</span><span class="p">)</span> <span class="kr">do</span> </span><span id="L-176"><a href="#L-176"><span class="linenos" data-line="176"></span></a> <span class="kr">if</span> <span class="n">htmlArg</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">then</span> <span class="n">HTML</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> </span><span id="L-177"><a href="#L-177"><span class="linenos" data-line="177"></span></a> <span class="kr">elseif</span> <span class="n">v</span> <span class="ow">and</span> <span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="kr">then</span> </span><span id="L-178"><a href="#L-178"><span class="linenos" data-line="178"></span></a> <span class="kr">if</span> <span class="n">nonSelf</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">then</span> </span><span id="L-179"><a href="#L-179"><span class="linenos" data-line="179"></span></a> <span class="kr">if</span> <span class="n">k</span><span class="o">==</span><span class="s1">'tag'</span> <span class="kr">then</span> </span><span id="L-180"><a href="#L-180"><span class="linenos" data-line="180"></span></a> <span class="kr">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span> <span class="kr">then</span> </span><span id="L-181"><a href="#L-181"><span class="linenos" data-line="181"></span></a> <span class="n">skip</span><span class="p">[</span><span class="n">v</span><span class="p">],</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">create</span><span class="p">(</span><span class="n">Valid</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">])),</span> <span class="s1">'parent'</span><span class="p">,</span> <span class="n">HTML</span><span class="p">)</span> </span><span id="L-182"><a href="#L-182"><span class="linenos" data-line="182"></span></a> <span class="n">Element</span><span class="p">.</span><span class="n">_add</span><span class="p">(</span><span class="n">spec</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">k</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">k</span><span class="p">)),</span> <span class="n">Element</span><span class="p">),</span> <span class="n">v</span><span class="p">)</span> </span><span id="L-183"><a href="#L-183"><span class="linenos" data-line="183"></span></a> <span class="kr">if</span> <span class="n">k</span><span class="p">.</span><span class="n">selfClosing</span> <span class="kr">then</span> <span class="n">k</span><span class="p">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="kc">nil</span> <span class="kr">else</span> <span class="n">spec</span><span class="p">[</span><span class="n">k</span><span class="p">.</span><span class="n">nodes</span><span class="p">],</span> <span class="n">parent</span><span class="p">[</span><span class="n">k</span><span class="p">.</span><span class="n">nodes</span><span class="p">]</span> <span class="o">=</span> <span class="kc">nil</span> <span class="kr">end</span><span class="c1">--free memory/reduce clutter; parent ref will auto-unset when k.nodes is nil</span> </span><span id="L-184"><a href="#L-184"><span class="linenos" data-line="184"></span></a> <span class="kr">if</span> <span class="ow">not</span> <span class="n">k</span><span class="p">.</span><span class="n">tagName</span> <span class="kr">then</span> <span class="n">k</span><span class="p">.</span><span class="n">styles</span><span class="p">,</span> <span class="n">k</span><span class="p">.</span><span class="n">attributes</span> <span class="o">=</span> <span class="kc">nil</span> <span class="kr">end</span> </span><span id="L-185"><a href="#L-185"><span class="linenos" data-line="185"></span></a> <span class="kr">else</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">create</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> <span class="kr">end</span> </span><span id="L-186"><a href="#L-186"><span class="linenos" data-line="186"></span></a> <span class="kr">elseif</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">then</span> </span><span id="L-187"><a href="#L-187"><span class="linenos" data-line="187"></span></a> <span class="kr">if</span> <span class="n">k</span><span class="o">==</span><span class="s1">'done'</span> <span class="ow">and</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">~=</span><span class="n">v</span> <span class="ow">and</span> <span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="o">==</span><span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="kr">then</span> <span class="n">skip</span><span class="p">[</span><span class="n">v</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="kr">end</span> </span><span id="L-188"><a href="#L-188"><span class="linenos" data-line="188"></span></a> <span class="n">MBmix</span><span class="p">(</span><span class="n">outFuncs</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">nodes</span><span class="p">,</span> <span class="n">skip</span><span class="p">[</span><span class="n">v</span><span class="p">]</span> <span class="ow">and</span> <span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]).</span><span class="n">nodes</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> </span><span id="L-189"><a href="#L-189"><span class="linenos" data-line="189"></span></a> <span class="kr">elseif</span> <span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">or</span> <span class="n">v</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="kr">then</span> </span><span id="L-190"><a href="#L-190"><span class="linenos" data-line="190"></span></a> <span class="n">k</span> <span class="o">=</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">nodes</span><span class="p">,</span> <span class="n">unpack</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">skip</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">k</span><span class="o">==</span><span class="s1">'_B'</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">)[</span><span class="n">v</span><span class="p">]))</span> </span><span id="L-191"><a href="#L-191"><span class="linenos" data-line="191"></span></a> <span class="n">Element</span><span class="p">.</span><span class="n">_add</span><span class="p">(</span><span class="nb">getmetatable</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="s1">'nodes'</span><span class="p">)</span> <span class="ow">or</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span><span class="c1">--if k is not a table, then v should not contain any extra keys or this may error.</span> </span><span id="L-192"><a href="#L-192"><span class="linenos" data-line="192"></span></a> <span class="kr">else</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">nodes</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--k probably == '_G' or '_R'</span> </span><span id="L-193"><a href="#L-193"><span class="linenos" data-line="193"></span></a> <span class="kr">elseif</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="kr">then</span> </span><span id="L-194"><a href="#L-194"><span class="linenos" data-line="194"></span></a> <span class="kr">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">~=</span><span class="s1">'table'</span> <span class="ow">or</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s1">'nodes'</span><span class="p">)</span> <span class="kr">then</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">HTML</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> </span><span id="L-195"><a href="#L-195"><span class="linenos" data-line="195"></span></a> <span class="kr">else</span> </span><span id="L-196"><a href="#L-196"><span class="linenos" data-line="196"></span></a> <span class="kd">local</span> <span class="n">css</span> <span class="o">=</span> <span class="n">k</span><span class="o">==</span><span class="s1">'css'</span> </span><span id="L-197"><a href="#L-197"><span class="linenos" data-line="197"></span></a> <span class="kr">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="kr">do</span> <span class="p">(</span><span class="n">y</span> <span class="ow">and</span> <span class="n">y</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">)(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">css</span> <span class="ow">and</span> <span class="n">x</span><span class="p">:</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'_'</span><span class="p">,</span> <span class="s1">'-'</span><span class="p">)</span> <span class="ow">or</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--iterate non-numbers first</span> </span><span id="L-198"><a href="#L-198"><span class="linenos" data-line="198"></span></a> <span class="kr">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">y</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span> <span class="kr">do</span> <span class="p">(</span><span class="n">y</span> <span class="ow">and</span> <span class="n">y</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="n">mwFunc</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">)(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--don't bother with gsub since text must be quoted anyhow</span> </span><span id="L-199"><a href="#L-199"><span class="linenos" data-line="199"></span></a> <span class="kr">end</span> </span><span id="L-200"><a href="#L-200"><span class="linenos" data-line="200"></span></a> <span class="kr">elseif</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">Element</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">MBi</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="kr">then</span> </span><span id="L-201"><a href="#L-201"><span class="linenos" data-line="201"></span></a> <span class="kr">if</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">==</span><span class="n">v</span> <span class="ow">or</span> <span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">or</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">then</span> <span class="p">(</span><span class="n">Element</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">])(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span><span class="c1">--v is probably string-able object, or a table to be handled by :_all</span> </span><span id="L-202"><a href="#L-202"><span class="linenos" data-line="202"></span></a> <span class="kr">else</span> <span class="p">(</span><span class="n">Element</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">])(</span><span class="n">nodes</span><span class="p">,</span> <span class="n">unpack</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">table</span><span class="p">.</span><span class="n">maxn</span><span class="p">(</span><span class="n">v</span><span class="p">)))</span> <span class="kr">end</span><span class="c1">--v is definately a table</span> </span><span id="L-203"><a href="#L-203"><span class="linenos" data-line="203"></span></a> <span class="kr">else</span> <span class="n">mwFunc</span><span class="p">.</span><span class="n">css</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">k</span><span class="p">:</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'_'</span><span class="p">,</span> <span class="s1">'-'</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> <span class="kr">end</span><span class="c1">--oddly enough, :_add clocked its fastest runtime after adding auto-gsub as a feature</span> </span><span id="L-204"><a href="#L-204"><span class="linenos" data-line="204"></span></a> <span class="n">skip</span><span class="p">[</span><span class="n">v</span><span class="p">]</span> <span class="o">=</span> <span class="kc">nil</span> </span><span id="L-205"><a href="#L-205"><span class="linenos" data-line="205"></span></a> <span class="kr">end</span> </span><span id="L-206"><a href="#L-206"><span class="linenos" data-line="206"></span></a> <span class="kr">end</span> </span><span id="L-207"><a href="#L-207"><span class="linenos" data-line="207"></span></a> <span class="kr">return</span> <span class="n">nodes</span> </span><span id="L-208"><a href="#L-208"><span class="linenos" data-line="208"></span></a> <span class="kr">end</span> </span><span id="L-209"><a href="#L-209"><span class="linenos" data-line="209"></span></a> <span class="p">}</span> </span><span id="L-210"><a href="#L-210"><span class="linenos" data-line="210"></span></a> <span class="kd">local</span> <span class="n">tempMeta</span> <span class="o">=</span> <span class="p">{</span><span class="n">mode</span><span class="o">=</span><span class="s1">'v'</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="p">{</span><span class="n">styles</span><span class="o">=</span><span class="kc">true</span><span class="p">,</span><span class="n">attributes</span><span class="o">=</span><span class="kc">true</span><span class="p">}}</span> </span><span id="L-211"><a href="#L-211"><span class="linenos" data-line="211"></span></a> <span class="kr">function</span> <span class="nc">tempMeta</span><span class="p">.</span><span class="nf">__index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="kr">return</span> <span class="n">tempMeta</span><span class="p">.</span><span class="n">copy</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">(</span><span class="kc">false</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">t</span><span class="p">.</span><span class="n">orig</span><span class="p">[</span><span class="n">i</span><span class="p">]))[</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="n">t</span><span class="p">.</span><span class="n">orig</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">end</span> </span><span id="L-212"><a href="#L-212"><span class="linenos" data-line="212"></span></a> <span class="n">rawkey</span><span class="p">[</span><span class="nb">setmetatable</span><span class="p">(</span><span class="n">Element</span><span class="p">,</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="n">outFuncs</span><span class="p">,</span> <span class="n">__concat</span><span class="o">=</span><span class="kr">function</span><span class="p">(</span><span class="n">Element</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">setmetatable</span><span class="p">({</span><span class="n">nodes</span><span class="o">=</span><span class="n">spec</span><span class="p">({},</span> <span class="n">Element</span><span class="p">),</span><span class="n">orig</span><span class="o">=</span><span class="n">parent</span><span class="p">[</span><span class="n">v</span><span class="p">]},</span> <span class="n">tempMeta</span><span class="p">)</span> <span class="kr">end</span><span class="p">})]</span> <span class="o">=</span> <span class="nb">math.huge</span> </span><span id="L-213"><a href="#L-213"><span class="linenos" data-line="213"></span></a> <span class="kr">end</span> </span><span id="L-214"><a href="#L-214"><span class="linenos" data-line="214"></span></a> <span class="kr">function</span> <span class="nc">MBi</span><span class="p">:</span><span class="nf">getHTML</span><span class="p">(...)</span> </span><span id="L-215"><a href="#L-215"><span class="linenos" data-line="215"></span></a> <span class="n">lastBuffer</span> <span class="o">=</span> <span class="n">self</span> </span><span id="L-216"><a href="#L-216"><span class="linenos" data-line="216"></span></a> <span class="kr">if</span> <span class="p">...</span> <span class="kr">then</span> </span><span id="L-217"><a href="#L-217"><span class="linenos" data-line="217"></span></a> <span class="kr">if</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">1</span> <span class="kr">then</span> <span class="kr">return</span> <span class="ow">not</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">s</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">tostring</span><span class="p">(...):</span><span class="n">match</span><span class="s1">'^_'</span> <span class="ow">and</span> <span class="n">BHi</span><span class="p">[...]</span> <span class="ow">and</span> <span class="n">BHi</span><span class="p">[...](</span><span class="n">lastHTML</span><span class="p">)</span> <span class="ow">or</span> <span class="n">lastHTML</span><span class="p">(...)</span> </span><span id="L-218"><a href="#L-218"><span class="linenos" data-line="218"></span></a> <span class="kr">else</span> <span class="kr">return</span> <span class="nb">assert</span><span class="p">(</span><span class="n">BHi</span><span class="p">[...],</span> <span class="p">(</span><span class="s1">'" %s " does not match any mw.html or Buffer-mw.html function'</span><span class="p">):</span><span class="n">format</span><span class="p">(</span><span class="nb">tostring</span><span class="p">(...)))(</span><span class="n">lastHTML</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...))</span> <span class="kr">end</span> </span><span id="L-219"><a href="#L-219"><span class="linenos" data-line="219"></span></a> <span class="kr">end</span> </span><span id="L-220"><a href="#L-220"><span class="linenos" data-line="220"></span></a> <span class="kr">return</span> <span class="n">lastHTML</span> </span><span id="L-221"><a href="#L-221"><span class="linenos" data-line="221"></span></a> <span class="kr">end</span> </span><span id="L-222"><a href="#L-222"><span class="linenos" data-line="222"></span></a> <span class="kr">function</span> <span class="nc">MBi</span><span class="p">:</span><span class="nf">_html</span><span class="p">(...)</span> <span class="kr">return</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">lastHTML</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="n">spec</span><span class="p">[</span><span class="n">self</span><span class="p">]</span><span class="o">==</span><span class="n">Element</span> <span class="ow">and</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">,</span> <span class="kc">true</span><span class="p">,</span> <span class="p">...))</span> <span class="kr">end</span> </span><span id="L-223"><a href="#L-223"><span class="linenos" data-line="223"></span></a> <span class="kr">return</span> <span class="n">init</span><span class="p">(...)</span> </span><span id="L-224"><a href="#L-224"><span class="linenos" data-line="224"></span></a> <span class="kr">end</span> </span><span id="L-225"><a href="#L-225"><span class="linenos" data-line="225"></span></a> <span class="kr">function</span> <span class="nf">_inHTML</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-226"><a href="#L-226"><span class="linenos" data-line="226"></span></a> <span class="kd">local</span> <span class="n">HTML</span> <span class="o">=</span> <span class="n">init</span><span class="p">(</span><span class="kc">nil</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-227"><a href="#L-227"><span class="linenos" data-line="227"></span></a> <span class="kr">if</span> <span class="n">HTML</span><span class="p">.</span><span class="n">selfClosing</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">self</span><span class="p">]</span><span class="o">==</span><span class="n">Element</span> <span class="kr">then</span> <span class="n">self</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">HTML</span><span class="p">)</span> <span class="kr">return</span> <span class="n">self</span> <span class="kr">end</span> </span><span id="L-228"><a href="#L-228"><span class="linenos" data-line="228"></span></a> <span class="n">lastBuffer</span><span class="p">,</span> <span class="n">lastHTML</span> <span class="o">=</span> <span class="n">self</span><span class="p">,</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">HTML</span><span class="p">,</span> <span class="n">self</span><span class="p">),</span> <span class="n">buffHTML</span><span class="p">)</span><span class="c1">--set after 'args' table processed by :_add</span> </span><span id="L-229"><a href="#L-229"><span class="linenos" data-line="229"></span></a> <span class="kr">return</span> <span class="n">HTML</span> </span><span id="L-230"><a href="#L-230"><span class="linenos" data-line="230"></span></a> <span class="kr">end</span> </span><span id="L-231"><a href="#L-231"><span class="linenos" data-line="231"></span></a> <span class="kr">end</span> </span><span id="L-232"><a href="#L-232"><span class="linenos" data-line="232"></span></a> <span class="kd">local</span> <span class="n">_var</span><span class="p">,</span> <span class="n">unbuild</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">prev</span><span class="p">,</span> <span class="n">rebuild</span> </span><span id="L-233"><a href="#L-233"><span class="linenos" data-line="233"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">init</span><span class="p">(...)</span><span class="c1">--init replaced before return</span> </span><span id="L-234"><a href="#L-234"><span class="linenos" data-line="234"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">pick</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">return</span> <span class="n">b</span> <span class="ow">and</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="ow">or</span> <span class="n">v</span> <span class="kr">end</span> </span><span id="L-235"><a href="#L-235"><span class="linenos" data-line="235"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">c</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">a</span> <span class="ow">or</span> <span class="n">a</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">a</span><span class="p">.</span><span class="n">c</span> <span class="ow">or</span> <span class="n">num</span> <span class="ow">and</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">or</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span><span class="n">byte</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span> <span class="kr">end</span> </span><span id="L-236"><a href="#L-236"><span class="linenos" data-line="236"></span></a> <span class="kd">local</span> <span class="n">same</span><span class="p">,</span> <span class="n">build</span><span class="p">,</span> <span class="n">alt</span> <span class="o">=</span> <span class="p">{</span><span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">return</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">pick</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">.</span><span class="n">string</span> <span class="ow">and</span> <span class="nb">string.char</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">or</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">.</span><span class="n">table</span> <span class="ow">and</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="ow">or</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="kr">end</span><span class="p">},</span> <span class="p">{</span> </span><span id="L-237"><a href="#L-237"><span class="linenos" data-line="237"></span></a> <span class="n">__index</span> <span class="o">=</span> <span class="p">{</span><span class="n">c</span> <span class="o">=</span> <span class="mi">1</span><span class="p">},</span> </span><span id="L-238"><a href="#L-238"><span class="linenos" data-line="238"></span></a> <span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">return</span> <span class="n">t</span><span class="p">:</span><span class="n">_build</span><span class="p">()</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-239"><a href="#L-239"><span class="linenos" data-line="239"></span></a> <span class="n">table</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kd">local</span> <span class="n">i</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">or</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">==#</span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">next</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="kr">return</span> <span class="n">pick</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">a</span> <span class="ow">or</span> <span class="n">a</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">i</span><span class="p">)[</span><span class="mi">1</span><span class="p">][</span><span class="n">i</span><span class="p">])</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--change rate (a.c) ignored since users control the table's contents</span> </span><span id="L-240"><a href="#L-240"><span class="linenos" data-line="240"></span></a> <span class="n">number</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">return</span> <span class="n">pick</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="kc">true</span><span class="p">))</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-241"><a href="#L-241"><span class="linenos" data-line="241"></span></a> <span class="n">string</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">return</span> <span class="n">pick</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="nb">string.char</span><span class="p">(</span><span class="n">c</span><span class="p">(</span><span class="n">a</span><span class="p">)))</span> <span class="kr">end</span> </span><span id="L-242"><a href="#L-242"><span class="linenos" data-line="242"></span></a> <span class="p">},</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="kr">return</span> <span class="n">a</span><span class="p">.</span><span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">end</span><span class="p">,</span> <span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">return</span> <span class="p">(</span><span class="nb">rawget</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">and</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">==</span><span class="nb">tostring</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">and</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span><span class="n">byte</span><span class="p">())</span> <span class="ow">or</span> <span class="n">a</span><span class="p">).</span><span class="n">a</span><span class="p">.</span><span class="n">_build</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">end</span><span class="p">}</span> </span><span id="L-243"><a href="#L-243"><span class="linenos" data-line="243"></span></a> <span class="kd">local</span> <span class="kr">function</span> <span class="nf">shift</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> </span><span id="L-244"><a href="#L-244"><span class="linenos" data-line="244"></span></a> <span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">c</span> <span class="ow">or</span> <span class="n">t</span><span class="p">:</span><span class="n">_build</span><span class="p">()</span> <span class="ow">and</span> <span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">t</span><span class="p">.</span><span class="n">c</span> <span class="o">+</span> <span class="n">c</span> </span><span id="L-245"><a href="#L-245"><span class="linenos" data-line="245"></span></a> <span class="kr">if</span> <span class="n">t</span><span class="p">.</span><span class="n">table</span> <span class="kr">then</span> <span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">%</span> <span class="o">#</span><span class="n">t</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span> <span class="kr">end</span> </span><span id="L-246"><a href="#L-246"><span class="linenos" data-line="246"></span></a> <span class="kr">end</span> </span><span id="L-247"><a href="#L-247"><span class="linenos" data-line="247"></span></a> <span class="kr">function</span> <span class="nf">rebuild</span><span class="p">(...)</span> </span><span id="L-248"><a href="#L-248"><span class="linenos" data-line="248"></span></a> <span class="kd">local</span> <span class="n">v</span><span class="p">,</span> <span class="n">c</span> <span class="o">=</span> <span class="p">...</span> </span><span id="L-249"><a href="#L-249"><span class="linenos" data-line="249"></span></a> <span class="kr">if</span> <span class="n">v</span> <span class="ow">or</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="kr">then</span> </span><span id="L-250"><a href="#L-250"><span class="linenos" data-line="250"></span></a> <span class="kr">if</span> <span class="n">v</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">prev</span> <span class="kr">end</span> </span><span id="L-251"><a href="#L-251"><span class="linenos" data-line="251"></span></a> <span class="kd">local</span> <span class="n">meta</span><span class="p">,</span> <span class="n">c</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="n">v</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">3</span><span class="p">,</span> <span class="n">alt</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">same</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span><span id="L-252"><a href="#L-252"><span class="linenos" data-line="252"></span></a> <span class="kr">return</span> <span class="nb">setmetatable</span><span class="p">({</span><span class="n">a</span> <span class="o">=</span> <span class="n">prev</span><span class="p">,</span> <span class="n">_build</span> <span class="o">=</span> <span class="n">meta</span><span class="p">.</span><span class="n">__tostring</span><span class="p">,</span> <span class="n">c</span> <span class="o">=</span> <span class="n">c</span><span class="p">},</span> <span class="n">meta</span><span class="p">)</span> </span><span id="L-253"><a href="#L-253"><span class="linenos" data-line="253"></span></a> <span class="kr">elseif</span> <span class="n">v</span><span class="o">==</span><span class="kc">nil</span> <span class="kr">then</span><span class="c1">--no-op</span> </span><span id="L-254"><a href="#L-254"><span class="linenos" data-line="254"></span></a> <span class="kr">elseif</span> <span class="n">c</span> <span class="kr">then</span> <span class="n">shift</span><span class="p">(</span><span class="n">prev</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span><span class="c1">--v == false</span> </span><span id="L-255"><a href="#L-255"><span class="linenos" data-line="255"></span></a> <span class="kr">else</span> <span class="n">prev</span><span class="p">:</span><span class="n">_build</span><span class="p">()</span> <span class="kr">end</span> </span><span id="L-256"><a href="#L-256"><span class="linenos" data-line="256"></span></a> <span class="kr">end</span> </span><span id="L-257"><a href="#L-257"><span class="linenos" data-line="257"></span></a> <span class="n">init</span><span class="p">,</span> <span class="n">noCache</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> <span class="n">prev</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">({</span><span class="n">v</span><span class="p">,</span> <span class="n">c</span> <span class="o">=</span> <span class="n">c</span><span class="p">,</span> <span class="n">_build</span> <span class="o">=</span> <span class="n">build</span><span class="p">[</span><span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)]</span> <span class="ow">or</span> <span class="n">v</span><span class="p">,</span> <span class="p">[</span><span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">alt</span> <span class="o">=</span> <span class="p">{}},</span> <span class="n">build</span><span class="p">)</span> <span class="kr">return</span> <span class="n">prev</span> <span class="kr">end</span><span class="p">,</span> <span class="kc">true</span> </span><span id="L-258"><a href="#L-258"><span class="linenos" data-line="258"></span></a> <span class="kr">return</span> <span class="n">init</span><span class="p">(...)</span> </span><span id="L-259"><a href="#L-259"><span class="linenos" data-line="259"></span></a> <span class="kr">end</span> </span><span id="L-260"><a href="#L-260"><span class="linenos" data-line="260"></span></a> <span class="kr">function</span> <span class="nf">unbuild</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> </span><span id="L-261"><a href="#L-261"><span class="linenos" data-line="261"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">sep</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span> <span class="kr">do</span> </span><span id="L-262"><a href="#L-262"><span class="linenos" data-line="262"></span></a> <span class="n">k</span> <span class="o">=</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">if</span> <span class="n">k</span> <span class="ow">and</span> <span class="p">(</span><span class="n">k</span><span class="o">==</span><span class="n">build</span> <span class="ow">or</span> <span class="n">k</span><span class="o">==</span><span class="n">alt</span><span class="p">)</span> <span class="kr">then</span> <span class="n">shift</span><span class="p">(</span><span class="n">v</span><span class="p">.</span><span class="n">a</span> <span class="ow">or</span> <span class="n">v</span><span class="p">,</span> <span class="o">-</span><span class="n">v</span><span class="p">.</span><span class="n">c</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-263"><a href="#L-263"><span class="linenos" data-line="263"></span></a> <span class="kr">end</span> </span><span id="L-264"><a href="#L-264"><span class="linenos" data-line="264"></span></a> <span class="kr">end</span> </span><span id="L-265"><a href="#L-265"><span class="linenos" data-line="265"></span></a> <span class="kr">function</span> <span class="nf">_var</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-266"><a href="#L-266"><span class="linenos" data-line="266"></span></a> <span class="kd">local</span> <span class="n">obj</span> <span class="kr">if</span> <span class="p">...</span> <span class="ow">and</span> <span class="p">...</span><span class="o">~=</span><span class="kc">true</span> <span class="kr">then</span> <span class="n">obj</span> <span class="o">=</span> <span class="n">init</span><span class="p">(...)</span> </span><span id="L-267"><a href="#L-267"><span class="linenos" data-line="267"></span></a> <span class="kr">elseif</span> <span class="n">prev</span> <span class="kr">then</span> </span><span id="L-268"><a href="#L-268"><span class="linenos" data-line="268"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">~=</span><span class="kc">false</span> <span class="kr">then</span> <span class="n">obj</span> <span class="o">=</span> <span class="n">rebuild</span><span class="p">(...)</span> </span><span id="L-269"><a href="#L-269"><span class="linenos" data-line="269"></span></a> <span class="kr">else</span> <span class="n">rebuild</span><span class="p">(...)</span> <span class="kr">end</span> </span><span id="L-270"><a href="#L-270"><span class="linenos" data-line="270"></span></a> <span class="kr">end</span> </span><span id="L-271"><a href="#L-271"><span class="linenos" data-line="271"></span></a> <span class="kr">return</span> <span class="n">obj</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="ow">or</span> <span class="n">self</span> </span><span id="L-272"><a href="#L-272"><span class="linenos" data-line="272"></span></a> <span class="kr">end</span> </span><span id="L-273"><a href="#L-273"><span class="linenos" data-line="273"></span></a> <span class="kr">end</span> </span><span id="L-274"><a href="#L-274"><span class="linenos" data-line="274"></span></a> <span class="kd">local</span> <span class="n">lib</span><span class="p">;</span> <span class="n">MBi</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">({</span><span class="n">stream</span> <span class="o">=</span> <span class="n">_stream</span><span class="p">,</span> </span><span id="L-275"><a href="#L-275"><span class="linenos" data-line="275"></span></a> <span class="n">_inHTML</span> <span class="o">=</span> <span class="n">_inHTML</span><span class="p">,</span> </span><span id="L-276"><a href="#L-276"><span class="linenos" data-line="276"></span></a> <span class="n">_var</span> <span class="o">=</span> <span class="n">_var</span><span class="p">,</span> </span><span id="L-277"><a href="#L-277"><span class="linenos" data-line="277"></span></a> <span class="n">_</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-278"><a href="#L-278"><span class="linenos" data-line="278"></span></a> <span class="kd">local</span> <span class="n">at</span><span class="p">,</span> <span class="n">raw</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="p">...</span><span class="o">==</span><span class="kc">true</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-279"><a href="#L-279"><span class="linenos" data-line="279"></span></a> <span class="kr">if</span> <span class="n">raw</span> <span class="kr">then</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="nb">math.huge</span> <span class="kr">else</span> <span class="n">v</span> <span class="o">=</span> <span class="n">Valid</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-280"><a href="#L-280"><span class="linenos" data-line="280"></span></a> <span class="kr">if</span> <span class="n">v</span> <span class="ow">or</span> <span class="n">raw</span> <span class="kr">then</span> </span><span id="L-281"><a href="#L-281"><span class="linenos" data-line="281"></span></a> <span class="kr">if</span> <span class="n">at</span> <span class="ow">or</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="kr">then</span> <span class="n">raw</span> <span class="o">=</span> <span class="o">#</span><span class="n">self</span> <span class="kr">end</span><span class="c1">--if length increases by more than one after table.insert, then set rawkey[self] = math.huge; rawkey[self] may be equal to a previous 'at'</span> </span><span id="L-282"><a href="#L-282"><span class="linenos" data-line="282"></span></a> <span class="n">at</span><span class="p">,</span> <span class="n">self</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="n">at</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">tonumber</span><span class="p">(</span><span class="n">at</span><span class="p">)</span><span class="o">~=</span><span class="n">at</span> <span class="ow">and</span> <span class="n">raw</span> <span class="o">+</span> <span class="n">at</span> <span class="ow">or</span> <span class="n">at</span><span class="p">)</span> </span><span id="L-283"><a href="#L-283"><span class="linenos" data-line="283"></span></a> <span class="nb">table.insert</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="n">at</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">,</span> <span class="n">at</span><span class="p">,</span> <span class="n">v</span><span class="p">))</span> </span><span id="L-284"><a href="#L-284"><span class="linenos" data-line="284"></span></a> <span class="kr">if</span> <span class="n">at</span> <span class="ow">and</span> <span class="n">at</span> <span class="o"><</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">raw</span> <span class="ow">and</span> <span class="o">#</span><span class="n">self</span> <span class="o">-</span> <span class="n">raw</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="nb">math.huge</span> <span class="kr">elseif</span> <span class="n">at</span> <span class="ow">and</span> <span class="o">#</span><span class="n">self</span><span class="o">==</span><span class="n">raw</span> <span class="kr">then</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">math.max</span><span class="p">(</span><span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">],</span> <span class="n">at</span><span class="p">)</span> <span class="ow">or</span> <span class="n">at</span> <span class="kr">end</span> </span><span id="L-285"><a href="#L-285"><span class="linenos" data-line="285"></span></a> <span class="kr">end</span><span class="c1">--above line looks bizarre because one table.insert op may make length jump from 0 to 8: local wtf={[2]=2,[4]=4,[8]=8}mw.log(#wtf,table.insert(wtf,1),#wtf)</span> </span><span id="L-286"><a href="#L-286"><span class="linenos" data-line="286"></span></a> <span class="kr">return</span> <span class="n">self</span> </span><span id="L-287"><a href="#L-287"><span class="linenos" data-line="287"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-288"><a href="#L-288"><span class="linenos" data-line="288"></span></a> <span class="n">_nil</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">at</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-289"><a href="#L-289"><span class="linenos" data-line="289"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="p">...</span><span class="o">~=</span><span class="kc">false</span> <span class="kr">then</span><span class="c1">--faster than type(...) ~= 'boolean'</span> </span><span id="L-290"><a href="#L-290"><span class="linenos" data-line="290"></span></a> <span class="kr">if</span> <span class="ow">not</span> <span class="n">at</span> <span class="ow">or</span> <span class="n">at</span><span class="o">==</span><span class="s1">'0'</span> <span class="kr">then</span> </span><span id="L-291"><a href="#L-291"><span class="linenos" data-line="291"></span></a> <span class="n">self</span><span class="p">[</span><span class="o">#</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="p">...</span> <span class="kr">if</span> <span class="p">...</span> <span class="kr">then</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="nb">math.huge</span> <span class="kr">end</span> </span><span id="L-292"><a href="#L-292"><span class="linenos" data-line="292"></span></a> <span class="kr">else</span> </span><span id="L-293"><a href="#L-293"><span class="linenos" data-line="293"></span></a> <span class="kd">local</span> <span class="n">n</span><span class="p">,</span> <span class="n">v</span> <span class="o">=</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">at</span><span class="p">),</span> <span class="p">...</span> </span><span id="L-294"><a href="#L-294"><span class="linenos" data-line="294"></span></a> <span class="kr">if</span> <span class="n">n</span><span class="o">~=</span><span class="n">at</span> <span class="kr">then</span> </span><span id="L-295"><a href="#L-295"><span class="linenos" data-line="295"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="kr">then</span> <span class="n">n</span> <span class="o">=</span> <span class="o">#</span><span class="n">self</span> <span class="o">+</span> <span class="n">at</span> </span><span id="L-296"><a href="#L-296"><span class="linenos" data-line="296"></span></a> <span class="kr">elseif</span> <span class="n">at</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="kr">then</span> <span class="n">v</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="n">at</span><span class="p">,</span> <span class="o">#</span><span class="n">self</span> <span class="kr">end</span> </span><span id="L-297"><a href="#L-297"><span class="linenos" data-line="297"></span></a> <span class="kr">end</span> </span><span id="L-298"><a href="#L-298"><span class="linenos" data-line="298"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="kr">then</span> </span><span id="L-299"><a href="#L-299"><span class="linenos" data-line="299"></span></a> <span class="kr">if</span> <span class="n">v</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">and</span> <span class="n">n</span> <span class="o">></span> <span class="mi">0</span> <span class="kr">then</span> <span class="nb">table.remove</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span> </span><span id="L-300"><a href="#L-300"><span class="linenos" data-line="300"></span></a> <span class="kr">else</span> <span class="n">self</span><span class="p">[</span><span class="nb">math.floor</span><span class="p">(</span><span class="n">n</span><span class="p">)],</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span><span class="p">,</span> <span class="nb">math.huge</span> <span class="kr">end</span><span class="c1">--floor position for consistency with Table library</span> </span><span id="L-301"><a href="#L-301"><span class="linenos" data-line="301"></span></a> <span class="kr">end</span> </span><span id="L-302"><a href="#L-302"><span class="linenos" data-line="302"></span></a> <span class="kr">end</span> </span><span id="L-303"><a href="#L-303"><span class="linenos" data-line="303"></span></a> <span class="n">self</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="kc">nil</span> </span><span id="L-304"><a href="#L-304"><span class="linenos" data-line="304"></span></a> <span class="kr">end</span> </span><span id="L-305"><a href="#L-305"><span class="linenos" data-line="305"></span></a> <span class="kr">return</span> <span class="n">self</span> </span><span id="L-306"><a href="#L-306"><span class="linenos" data-line="306"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-307"><a href="#L-307"><span class="linenos" data-line="307"></span></a> <span class="n">_all</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">valKey</span><span class="p">)</span> </span><span id="L-308"><a href="#L-308"><span class="linenos" data-line="308"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">do</span> <span class="n">MBmix</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">valKey</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-309"><a href="#L-309"><span class="linenos" data-line="309"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">valKey</span> <span class="ow">and</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="kc">false</span><span class="p">)</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">,</span> <span class="n">t</span> <span class="kr">do</span> </span><span id="L-310"><a href="#L-310"><span class="linenos" data-line="310"></span></a> <span class="kr">if</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">then</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span><span class="c1">--self not always a buffer</span> </span><span id="L-311"><a href="#L-311"><span class="linenos" data-line="311"></span></a> <span class="kr">elseif</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">MBi</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> <span class="ow">and</span> <span class="n">v</span> <span class="ow">and</span> <span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="kr">then</span> </span><span id="L-312"><a href="#L-312"><span class="linenos" data-line="312"></span></a> <span class="kr">if</span> <span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">or</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">then</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">self</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> </span><span id="L-313"><a href="#L-313"><span class="linenos" data-line="313"></span></a> <span class="kr">else</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">self</span><span class="p">,</span> <span class="n">unpack</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">table</span><span class="p">.</span><span class="n">maxn</span><span class="p">(</span><span class="n">v</span><span class="p">)))</span> <span class="kr">end</span> </span><span id="L-314"><a href="#L-314"><span class="linenos" data-line="314"></span></a> <span class="kr">end</span> </span><span id="L-315"><a href="#L-315"><span class="linenos" data-line="315"></span></a> <span class="kr">end</span> </span><span id="L-316"><a href="#L-316"><span class="linenos" data-line="316"></span></a> <span class="kr">return</span> <span class="n">self</span> </span><span id="L-317"><a href="#L-317"><span class="linenos" data-line="317"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-318"><a href="#L-318"><span class="linenos" data-line="318"></span></a> <span class="n">_str</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-319"><a href="#L-319"><span class="linenos" data-line="319"></span></a> <span class="kd">local</span> <span class="n">n</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-320"><a href="#L-320"><span class="linenos" data-line="320"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span> </span><span id="L-321"><a href="#L-321"><span class="linenos" data-line="321"></span></a> <span class="kd">local</span> <span class="n">k</span><span class="p">,</span> <span class="n">ops</span><span class="p">,</span> <span class="n">seps</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> <span class="n">MBselect</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-322"><a href="#L-322"><span class="linenos" data-line="322"></span></a> <span class="n">r</span> <span class="o">=</span> <span class="n">MB</span><span class="p">(</span><span class="n">t</span><span class="p">(</span><span class="n">seps</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> </span><span id="L-323"><a href="#L-323"><span class="linenos" data-line="323"></span></a> <span class="kr">while</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ops</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">r</span><span class="p">:</span><span class="n">_</span><span class="p">(</span><span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">](</span><span class="n">seps</span><span class="p">[</span><span class="n">k</span><span class="p">]),</span> <span class="mi">1</span><span class="p">)</span> <span class="kr">do</span> <span class="n">t</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">ops</span> <span class="o">=</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ops</span> <span class="o">-</span> <span class="mi">1</span> <span class="kr">end</span> </span><span id="L-324"><a href="#L-324"><span class="linenos" data-line="324"></span></a> <span class="kr">return</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="n">seps</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">or</span> <span class="kc">nil</span><span class="p">)</span> </span><span id="L-325"><a href="#L-325"><span class="linenos" data-line="325"></span></a> <span class="kr">end</span> </span><span id="L-326"><a href="#L-326"><span class="linenos" data-line="326"></span></a> <span class="kr">return</span> <span class="n">MB</span><span class="p">.</span><span class="n">__call</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-327"><a href="#L-327"><span class="linenos" data-line="327"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-328"><a href="#L-328"><span class="linenos" data-line="328"></span></a> <span class="n">_in</span> <span class="o">=</span> <span class="kr">function</span> <span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">(</span><span class="n">MB</span><span class="p">(...),</span> <span class="n">self</span><span class="p">)</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-329"><a href="#L-329"><span class="linenos" data-line="329"></span></a> <span class="n">_out</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-330"><a href="#L-330"><span class="linenos" data-line="330"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">==</span><span class="mi">0</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">MB</span><span class="p">.</span><span class="n">__call</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...))),</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">t</span><span class="p">)))</span> <span class="kr">end</span><span class="c1">--love how :_cc needed nothing new to implement this *self pat on back*</span> </span><span id="L-331"><a href="#L-331"><span class="linenos" data-line="331"></span></a> <span class="kd">local</span> <span class="n">n</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-332"><a href="#L-332"><span class="linenos" data-line="332"></span></a> <span class="kr">if</span> <span class="n">n</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span> </span><span id="L-333"><a href="#L-333"><span class="linenos" data-line="333"></span></a> <span class="kd">local</span> <span class="n">k</span><span class="p">,</span> <span class="n">ops</span><span class="p">,</span> <span class="n">seps</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">MBselect</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-334"><a href="#L-334"><span class="linenos" data-line="334"></span></a> <span class="kr">while</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ops</span> <span class="o">></span> <span class="mi">0</span> <span class="kr">do</span> <span class="n">t</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">ops</span> <span class="o">=</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">]:</span><span class="n">_</span><span class="p">(</span><span class="n">t</span><span class="p">(</span><span class="n">seps</span><span class="p">[</span><span class="n">k</span><span class="p">])),</span> <span class="n">k</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ops</span> <span class="o">-</span> <span class="mi">1</span> <span class="kr">end</span> </span><span id="L-335"><a href="#L-335"><span class="linenos" data-line="335"></span></a> <span class="kr">elseif</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">t</span><span class="p">]:</span><span class="n">_</span><span class="p">(</span><span class="n">t</span><span class="p">(...))</span> <span class="kr">end</span> </span><span id="L-336"><a href="#L-336"><span class="linenos" data-line="336"></span></a> <span class="kr">return</span> <span class="n">t</span> </span><span id="L-337"><a href="#L-337"><span class="linenos" data-line="337"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-338"><a href="#L-338"><span class="linenos" data-line="338"></span></a> <span class="n">_cc</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">clear</span><span class="p">,</span> <span class="n">copy</span><span class="p">,</span> <span class="n">meta</span><span class="p">)</span> </span><span id="L-339"><a href="#L-339"><span class="linenos" data-line="339"></span></a> <span class="kr">if</span> <span class="n">clear</span> <span class="kr">then</span> </span><span id="L-340"><a href="#L-340"><span class="linenos" data-line="340"></span></a> <span class="kr">if</span> <span class="nb">rawequal</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">self</span><span class="p">,</span> <span class="n">spec</span><span class="p">[</span><span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">spec</span><span class="p">[</span><span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">],</span> <span class="n">MB</span><span class="p">)</span><span class="c1">--rawequal to avoid re-string via __eq in case both are different Buffer objects</span> </span><span id="L-341"><a href="#L-341"><span class="linenos" data-line="341"></span></a> <span class="kr">elseif</span> <span class="n">copy</span><span class="o">==</span><span class="kc">true</span> <span class="kr">then</span> <span class="n">copy</span> <span class="o">=</span> <span class="n">self</span> <span class="kr">end</span> </span><span id="L-342"><a href="#L-342"><span class="linenos" data-line="342"></span></a> <span class="kr">if</span> <span class="n">clear</span><span class="o">~=</span><span class="mi">0</span> <span class="kr">then</span> </span><span id="L-343"><a href="#L-343"><span class="linenos" data-line="343"></span></a> <span class="nb">assert</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">clear</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span><span class="p">,</span> <span class="nb">debug.traceback</span><span class="p">(</span><span class="s1">'Buffer:_cc can only "clear" tables. Did you forget to call with a colon?'</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span><span class="c1">--errors can be hard to trace without this</span> </span><span id="L-344"><a href="#L-344"><span class="linenos" data-line="344"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="kr">in</span> <span class="n">self</span> <span class="ow">and</span> <span class="nb">next</span> <span class="ow">or</span> <span class="n">noOp</span><span class="p">,</span> <span class="n">clear</span> <span class="kr">do</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-345"><a href="#L-345"><span class="linenos" data-line="345"></span></a> <span class="kr">else</span> <span class="kr">return</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">(</span><span class="kc">false</span><span class="p">,</span> <span class="p">{</span><span class="n">unpack</span><span class="p">(</span><span class="n">copy</span><span class="p">)},</span> <span class="n">copy</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--copy length w/o empty strings; recursion to avoid self = false causing garbage collection (non-weak child may exist)</span> </span><span id="L-346"><a href="#L-346"><span class="linenos" data-line="346"></span></a> <span class="kr">if</span> <span class="n">self</span><span class="o">==</span><span class="kc">false</span> <span class="ow">or</span> <span class="n">copy</span> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">copy</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span> <span class="kr">then</span><span class="c1">--self==false means copy is a table (saves a type op for recursive calls)</span> </span><span id="L-347"><a href="#L-347"><span class="linenos" data-line="347"></span></a> <span class="n">meta</span> <span class="o">=</span> <span class="n">meta</span> <span class="ow">or</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">copy</span><span class="p">)</span> </span><span id="L-348"><a href="#L-348"><span class="linenos" data-line="348"></span></a> <span class="kr">if</span> <span class="n">self</span> <span class="ow">and</span> <span class="o">#</span><span class="n">copy</span> <span class="o">></span> <span class="mi">1</span> <span class="kr">then</span><span class="c1">--preserves length with empty strings; developed from studying http://www.lua.org/source/5.1/ltable.c.html </span> </span><span id="L-349"><a href="#L-349"><span class="linenos" data-line="349"></span></a> <span class="kd">local</span> <span class="n">n</span><span class="p">,</span> <span class="n">null</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="o">=</span> <span class="o">#</span><span class="n">copy</span><span class="p">,</span> <span class="p">{},</span> <span class="nb">math.ldexp</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">math.frexp</span><span class="p">(</span><span class="o">#</span><span class="n">copy</span><span class="p">))</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> </span><span id="L-350"><a href="#L-350"><span class="linenos" data-line="350"></span></a> <span class="n">e</span><span class="p">,</span> <span class="n">spec</span><span class="p">[</span><span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">],</span> <span class="n">parent</span><span class="p">[</span><span class="n">null</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">null</span><span class="p">,</span> <span class="n">clear</span> </span><span id="L-351"><a href="#L-351"><span class="linenos" data-line="351"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">e</span> <span class="kr">do</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="kc">false</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-352"><a href="#L-352"><span class="linenos" data-line="352"></span></a> <span class="kr">while</span> <span class="n">i</span><span class="o"><=</span><span class="n">n</span> <span class="kr">do</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span> <span class="n">i</span><span class="p">,</span> <span class="n">null</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="nb">math.ldexp</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">math.frexp</span><span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="n">i</span><span class="p">))</span> <span class="o">-</span> <span class="mi">2</span><span class="p">),</span> <span class="s1">''</span> <span class="kr">end</span> </span><span id="L-353"><a href="#L-353"><span class="linenos" data-line="353"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">e</span> <span class="kr">do</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-354"><a href="#L-354"><span class="linenos" data-line="354"></span></a> <span class="kr">end</span> </span><span id="L-355"><a href="#L-355"><span class="linenos" data-line="355"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="n">copy</span> <span class="kr">do</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_cc</span><span class="p">(</span><span class="kc">false</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="ow">or</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-356"><a href="#L-356"><span class="linenos" data-line="356"></span></a> <span class="kr">elseif</span> <span class="n">copy</span> <span class="kr">then</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="n">Valid</span><span class="p">(</span><span class="n">copy</span><span class="p">)))</span> <span class="kr">end</span> </span><span id="L-357"><a href="#L-357"><span class="linenos" data-line="357"></span></a> <span class="n">rawkey</span><span class="p">[</span><span class="nb">setmetatable</span><span class="p">(</span><span class="n">clear</span><span class="p">,</span> <span class="n">meta</span><span class="p">)],</span> <span class="n">parent</span><span class="p">[</span><span class="n">clear</span><span class="p">]</span> <span class="o">=</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">copy</span><span class="p">],</span> <span class="n">parent</span><span class="p">[</span><span class="n">copy</span><span class="p">]</span> </span><span id="L-358"><a href="#L-358"><span class="linenos" data-line="358"></span></a> <span class="kr">end</span> </span><span id="L-359"><a href="#L-359"><span class="linenos" data-line="359"></span></a> <span class="kr">return</span> <span class="n">self</span> <span class="ow">and</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="s1">'last_concat'</span><span class="p">,</span> <span class="kc">nil</span><span class="p">)</span> <span class="ow">or</span> <span class="n">clear</span> </span><span id="L-360"><a href="#L-360"><span class="linenos" data-line="360"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-361"><a href="#L-361"><span class="linenos" data-line="361"></span></a> <span class="n">_parent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">[</span><span class="n">self</span><span class="p">]:</span><span class="n">_str</span><span class="p">(...))</span> <span class="ow">or</span> <span class="n">self</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-362"><a href="#L-362"><span class="linenos" data-line="362"></span></a> <span class="n">getParent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">isMBfunc</span><span class="p">(</span><span class="n">parent</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="ow">or</span> <span class="n">parent</span><span class="p">[</span><span class="n">parent</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">MB</span><span class="p">))],</span> <span class="p">...)</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-363"><a href="#L-363"><span class="linenos" data-line="363"></span></a> <span class="n">killParent</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">parent</span><span class="p">[</span><span class="n">self</span><span class="p">]</span> <span class="ow">and</span> <span class="n">isMBfunc</span><span class="p">(</span><span class="n">parent</span><span class="p">[</span><span class="n">self</span><span class="p">],</span> <span class="p">...)</span> <span class="ow">and</span> <span class="n">parent</span><span class="p">(</span><span class="n">self</span><span class="p">)</span> <span class="ow">or</span> <span class="n">self</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-364"><a href="#L-364"><span class="linenos" data-line="364"></span></a> <span class="n">_build</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">self</span><span class="p">())</span> <span class="kr">end</span><span class="p">,</span><span class="c1">--for compatibility with mw.html:node()</span> </span><span id="L-365"><a href="#L-365"><span class="linenos" data-line="365"></span></a> <span class="n">last_concat</span> <span class="o">=</span> <span class="kc">false</span><span class="c1">--prevent library check</span> </span><span id="L-366"><a href="#L-366"><span class="linenos" data-line="366"></span></a> <span class="p">},</span> <span class="p">{</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span><span class="c1">--import string, mw.text, and mw.ustring libraries on an as-needed basis</span> </span><span id="L-367"><a href="#L-367"><span class="linenos" data-line="367"></span></a> <span class="kd">local</span> <span class="n">func</span> <span class="o">=</span> <span class="n">string</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="n">mw</span><span class="p">.</span><span class="n">text</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="n">mw</span><span class="p">.</span><span class="n">ustring</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="nb">type</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">==</span><span class="s1">'string'</span> <span class="ow">and</span> <span class="n">mw</span><span class="p">.</span><span class="n">ustring</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">match</span><span class="s1">'^u(.+)'</span><span class="p">]</span> <span class="kr">if</span> <span class="n">func</span> <span class="kr">then</span> </span><span id="L-368"><a href="#L-368"><span class="linenos" data-line="368"></span></a> <span class="n">lib</span> <span class="o">=</span> <span class="n">lib</span> <span class="ow">or</span> <span class="kr">function</span> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-369"><a href="#L-369"><span class="linenos" data-line="369"></span></a> <span class="kr">if</span> <span class="n">parent</span><span class="p">[</span><span class="n">s</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">next</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="o">==</span><span class="kc">nil</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">s</span><span class="p">:</span><span class="n">_</span><span class="p">((</span><span class="n">f</span><span class="p">(</span><span class="nb">tostring</span><span class="p">(</span><span class="n">parent</span><span class="p">[</span><span class="n">Element</span> <span class="ow">and</span> <span class="p">(</span><span class="n">spec</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">==</span><span class="n">Element</span> <span class="ow">and</span> <span class="n">s</span><span class="p">:</span><span class="n">allDone</span><span class="p">()</span> <span class="ow">or</span> <span class="n">spec</span><span class="p">[</span><span class="n">parent</span><span class="p">[</span><span class="n">s</span><span class="p">]]</span><span class="o">==</span><span class="n">Element</span> <span class="ow">and</span> <span class="n">parent</span><span class="p">[</span><span class="n">s</span><span class="p">])</span> <span class="ow">or</span> <span class="n">s</span><span class="p">]),</span> <span class="p">...)))</span> <span class="kr">end</span> </span><span id="L-370"><a href="#L-370"><span class="linenos" data-line="370"></span></a> <span class="kr">return</span> <span class="n">f</span><span class="p">(</span><span class="nb">tostring</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="p">...)</span><span class="c1">--not using ternary/logical operators here to allow multiple return values</span> </span><span id="L-371"><a href="#L-371"><span class="linenos" data-line="371"></span></a> <span class="kr">end</span> </span><span id="L-372"><a href="#L-372"><span class="linenos" data-line="372"></span></a> <span class="kr">return</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span><span class="n">match</span><span class="s1">'^u?gsub'</span> <span class="ow">and</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="p">...)</span><span class="kr">return</span> <span class="n">lib</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">r</span> <span class="ow">or</span> <span class="s1">''</span><span class="p">,</span> <span class="p">...)</span><span class="kr">end</span><span class="c1">--Why are ugsub/gsub special? because empty strings are against my religion!</span> </span><span id="L-373"><a href="#L-373"><span class="linenos" data-line="373"></span></a> <span class="ow">or</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span><span class="kr">return</span> <span class="n">lib</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="p">...)</span><span class="kr">end</span><span class="p">)[</span><span class="n">i</span><span class="p">]</span> </span><span id="L-374"><a href="#L-374"><span class="linenos" data-line="374"></span></a> <span class="kr">end</span> </span><span id="L-375"><a href="#L-375"><span class="linenos" data-line="375"></span></a> <span class="kr">end</span><span class="p">})</span> </span><span id="L-376"><a href="#L-376"><span class="linenos" data-line="376"></span></a><span class="kr">end</span> </span><span id="L-377"><a href="#L-377"><span class="linenos" data-line="377"></span></a> </span><span id="L-378"><a href="#L-378"><span class="linenos" data-line="378"></span></a><span class="kr">function</span> <span class="nf">MBmix</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="n">v</span> <span class="ow">and</span> <span class="p">((</span><span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">~=</span><span class="s1">'table'</span> <span class="ow">or</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">].</span><span class="n">_add</span> <span class="ow">or</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_all</span><span class="p">)(</span><span class="n">t</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="p">...))</span> <span class="ow">or</span> <span class="n">t</span> <span class="kr">end</span><span class="c1">--:_all always passes two args</span> </span><span id="L-379"><a href="#L-379"><span class="linenos" data-line="379"></span></a> </span><span id="L-380"><a href="#L-380"><span class="linenos" data-line="380"></span></a><span class="kd">local</span> <span class="nb">_G</span><span class="p">,</span> <span class="n">new_G</span> <span class="o">=</span> <span class="nb">_G</span><span class="c1">--localize _G for console testing (console _G ~= module _G)</span> </span><span id="L-381"><a href="#L-381"><span class="linenos" data-line="381"></span></a><span class="kr">return</span> <span class="nb">setmetatable</span><span class="p">({</span><span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="kr">return</span> <span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="n">MBi</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="kr">end</span><span class="p">,</span> </span><span id="L-382"><a href="#L-382"><span class="linenos" data-line="382"></span></a> <span class="n">__call</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-383"><a href="#L-383"><span class="linenos" data-line="383"></span></a> <span class="kd">local</span> <span class="n">rawsep</span><span class="p">,</span> <span class="n">sep</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">raw</span> <span class="o">=</span> <span class="n">noCache</span> <span class="ow">and</span> <span class="n">rawkey</span><span class="p">[...]</span> <span class="ow">and</span> <span class="p">...,</span> <span class="p">...</span> </span><span id="L-384"><a href="#L-384"><span class="linenos" data-line="384"></span></a> <span class="kr">if</span> <span class="n">i</span> <span class="ow">or</span> <span class="n">j</span> <span class="ow">or</span> <span class="n">rawsep</span> <span class="ow">or</span> <span class="n">Valid</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> <span class="kr">then</span> </span><span id="L-385"><a href="#L-385"><span class="linenos" data-line="385"></span></a> <span class="n">raw</span><span class="p">,</span> <span class="n">sep</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">]]</span> <span class="ow">or</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">rawsep</span> <span class="ow">or</span> <span class="n">Valid</span><span class="p">(</span><span class="n">sep</span><span class="p">),</span> <span class="n">i</span> <span class="ow">and</span> <span class="p">(</span><span class="n">i</span><span class="o">~=</span><span class="nb">tonumber</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">+</span> <span class="o">#</span><span class="n">t</span> <span class="ow">or</span> <span class="n">i</span><span class="p">),</span> <span class="n">j</span> <span class="ow">and</span> <span class="p">(</span><span class="n">j</span><span class="o">~=</span><span class="nb">tonumber</span><span class="p">(</span><span class="n">j</span><span class="p">)</span> <span class="ow">and</span> <span class="n">j</span> <span class="o">+</span> <span class="o">#</span><span class="n">t</span> <span class="ow">or</span> <span class="n">j</span><span class="p">)</span> </span><span id="L-386"><a href="#L-386"><span class="linenos" data-line="386"></span></a> <span class="kr">if</span> <span class="n">rawsep</span> <span class="ow">or</span> <span class="n">raw</span> <span class="ow">and</span> <span class="p">(</span><span class="n">raw</span><span class="o">>=</span><span class="p">(</span><span class="n">j</span> <span class="ow">or</span> <span class="o">#</span><span class="n">t</span><span class="p">)</span> <span class="ow">or</span> <span class="n">i</span> <span class="o"><</span> <span class="mi">1</span><span class="p">)</span> <span class="kr">then</span> </span><span id="L-387"><a href="#L-387"><span class="linenos" data-line="387"></span></a> <span class="n">raw</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="p">{},</span> <span class="n">i</span> <span class="ow">and</span> <span class="nb">math.floor</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="n">j</span> <span class="ow">and</span> <span class="nb">math.floor</span><span class="p">(</span><span class="n">j</span><span class="p">)</span><span class="c1">--floor for consistency with table.concat(t, sep, i, j), which ignores decimals</span> </span><span id="L-388"><a href="#L-388"><span class="linenos" data-line="388"></span></a> <span class="n">raw</span><span class="p">.</span><span class="n">lc</span><span class="p">,</span> <span class="n">t</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="n">t</span><span class="p">.</span><span class="n">last_concat</span><span class="c1">--temporarily unset last_concat to prevent disqualification from mapless iteration</span> </span><span id="L-389"><a href="#L-389"><span class="linenos" data-line="389"></span></a> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="n">MBpairs</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="kr">do</span> </span><span id="L-390"><a href="#L-390"><span class="linenos" data-line="390"></span></a> <span class="kr">if</span> <span class="n">raw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">i</span> <span class="ow">or</span> <span class="n">k</span><span class="o">>=</span><span class="n">i</span> <span class="kr">then</span> <span class="kr">if</span> <span class="n">j</span> <span class="ow">and</span> <span class="n">k</span> <span class="o">></span> <span class="n">j</span> <span class="kr">then</span> <span class="kr">break</span> <span class="kr">end</span> </span><span id="L-391"><a href="#L-391"><span class="linenos" data-line="391"></span></a> <span class="kr">if</span> <span class="n">raw</span><span class="p">.</span><span class="n">s</span> <span class="kr">then</span> <span class="n">raw</span><span class="p">.</span><span class="n">s</span> <span class="o">=</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">raw</span><span class="p">,</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">sep</span><span class="p">))</span> <span class="kr">end</span><span class="c1">--if sep contains v and v is a Buffer-variable, sep must be strung before v</span> </span><span id="L-392"><a href="#L-392"><span class="linenos" data-line="392"></span></a> <span class="n">k</span> <span class="o">=</span> <span class="n">Valid</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="kr">if</span> <span class="n">k</span> <span class="kr">then</span> </span><span id="L-393"><a href="#L-393"><span class="linenos" data-line="393"></span></a> <span class="n">raw</span><span class="p">.</span><span class="n">s</span> <span class="o">=</span> <span class="n">rawsep</span> <span class="ow">or</span> <span class="n">sep</span> <span class="ow">and</span> <span class="n">raw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">and</span> <span class="nb">table.insert</span><span class="p">(</span><span class="n">raw</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> </span><span id="L-394"><a href="#L-394"><span class="linenos" data-line="394"></span></a> <span class="nb">table.insert</span><span class="p">(</span><span class="n">raw</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> </span><span id="L-395"><a href="#L-395"><span class="linenos" data-line="395"></span></a> <span class="kr">end</span> </span><span id="L-396"><a href="#L-396"><span class="linenos" data-line="396"></span></a> <span class="kr">end</span> </span><span id="L-397"><a href="#L-397"><span class="linenos" data-line="397"></span></a> <span class="kr">end</span> </span><span id="L-398"><a href="#L-398"><span class="linenos" data-line="398"></span></a> <span class="kr">if</span> <span class="n">rawsep</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">raw</span><span class="p">.</span><span class="n">s</span> <span class="kr">then</span> <span class="n">raw</span><span class="p">[</span><span class="o">#</span><span class="n">raw</span><span class="p">]</span> <span class="o">=</span> <span class="n">unbuild</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--unbuild rawsep if final index in t was invalid</span> </span><span id="L-399"><a href="#L-399"><span class="linenos" data-line="399"></span></a> <span class="n">t</span><span class="p">.</span><span class="n">last_concat</span> <span class="o">=</span> <span class="n">raw</span><span class="p">.</span><span class="n">lc</span> <span class="kr">return</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">raw</span><span class="p">)</span> </span><span id="L-400"><a href="#L-400"><span class="linenos" data-line="400"></span></a> <span class="kr">end</span> </span><span id="L-401"><a href="#L-401"><span class="linenos" data-line="401"></span></a> <span class="kr">return</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">sep</span><span class="p">,</span> <span class="n">i</span> <span class="ow">and</span> <span class="nb">math.max</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">j</span> <span class="ow">and</span> <span class="nb">math.min</span><span class="p">(</span><span class="n">j</span><span class="p">,</span> <span class="o">#</span><span class="n">t</span><span class="p">))</span> </span><span id="L-402"><a href="#L-402"><span class="linenos" data-line="402"></span></a> <span class="kr">end</span> </span><span id="L-403"><a href="#L-403"><span class="linenos" data-line="403"></span></a> <span class="kr">return</span> <span class="n">MB</span><span class="p">.</span><span class="n">__tostring</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> </span><span id="L-404"><a href="#L-404"><span class="linenos" data-line="404"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-405"><a href="#L-405"><span class="linenos" data-line="405"></span></a> <span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> </span><span id="L-406"><a href="#L-406"><span class="linenos" data-line="406"></span></a> <span class="kr">if</span> <span class="n">t</span><span class="p">.</span><span class="n">last_concat</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">t</span><span class="p">.</span><span class="n">last_concat</span> <span class="kr">end</span> </span><span id="L-407"><a href="#L-407"><span class="linenos" data-line="407"></span></a> <span class="kd">local</span> <span class="n">r</span> <span class="o">=</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">spec</span><span class="p">[</span><span class="n">t</span><span class="p">]]</span> <span class="ow">or</span> <span class="n">rawkey</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> </span><span id="L-408"><a href="#L-408"><span class="linenos" data-line="408"></span></a> <span class="n">r</span> <span class="o">=</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">r</span> <span class="ow">and</span> <span class="n">r</span><span class="o">>=#</span><span class="n">t</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_all</span><span class="p">({},</span> <span class="n">t</span><span class="p">)</span> <span class="ow">or</span> <span class="n">t</span><span class="p">)</span> </span><span id="L-409"><a href="#L-409"><span class="linenos" data-line="409"></span></a> <span class="kr">return</span> <span class="p">(</span><span class="n">noCache</span> <span class="ow">or</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="s1">'last_concat'</span><span class="p">,</span> <span class="n">r</span><span class="p">))</span> <span class="ow">and</span> <span class="n">r</span> </span><span id="L-410"><a href="#L-410"><span class="linenos" data-line="410"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-411"><a href="#L-411"><span class="linenos" data-line="411"></span></a> <span class="n">__concat</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> </span><span id="L-412"><a href="#L-412"><span class="linenos" data-line="412"></span></a> <span class="kr">if</span> <span class="n">buffHTML</span> <span class="kr">then</span> </span><span id="L-413"><a href="#L-413"><span class="linenos" data-line="413"></span></a> <span class="kr">for</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span> <span class="kr">do</span> <span class="kd">local</span> <span class="n">v</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span><span class="c1">--faster than for k, v in pairs{a, b} do</span> </span><span id="L-414"><a href="#L-414"><span class="linenos" data-line="414"></span></a> <span class="kr">if</span> <span class="n">v</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">v</span><span class="p">]</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">v</span><span class="p">]</span><span class="o">==</span><span class="n">Element</span> <span class="kr">then</span> </span><span id="L-415"><a href="#L-415"><span class="linenos" data-line="415"></span></a> <span class="kr">if</span> <span class="n">parent</span><span class="p">[</span><span class="n">v</span><span class="p">].</span><span class="n">selfClosing</span> <span class="kr">then</span> </span><span id="L-416"><a href="#L-416"><span class="linenos" data-line="416"></span></a> <span class="kr">if</span> <span class="nb">rawequal</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">then</span> <span class="kr">return</span> <span class="p">(</span><span class="ow">not</span> <span class="n">noCache</span> <span class="ow">or</span> <span class="n">parent</span><span class="p">[</span><span class="n">v</span><span class="p">].</span><span class="n">tagName</span><span class="p">)</span> <span class="ow">and</span> <span class="n">v</span><span class="p">:</span><span class="n">_str</span><span class="p">(</span><span class="mi">0</span><span class="p">):</span><span class="n">rep</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">v</span><span class="p">:</span><span class="n">_str</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">..</span><span class="n">v</span><span class="p">:</span><span class="n">_str</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--rawequal avoids premature tostring of Buffer:_var objects;</span> </span><span id="L-417"><a href="#L-417"><span class="linenos" data-line="417"></span></a> <span class="n">b</span><span class="p">,</span> <span class="n">a</span> <span class="o">=</span> <span class="nb">select</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">parent</span><span class="p">[</span><span class="n">v</span><span class="p">],</span> <span class="n">a</span><span class="p">)</span> </span><span id="L-418"><a href="#L-418"><span class="linenos" data-line="418"></span></a> <span class="kr">else</span> <span class="kd">local</span> <span class="n">temp</span> <span class="o">=</span> <span class="n">Element</span> <span class="o">..</span> <span class="n">v</span> <span class="c1">--helper method; returns a mirror of parent[v]</span> </span><span id="L-419"><a href="#L-419"><span class="linenos" data-line="419"></span></a> <span class="n">MBmix</span><span class="p">(</span><span class="n">MBmix</span><span class="p">(</span><span class="n">parent</span><span class="p">(</span><span class="n">temp</span><span class="p">.</span><span class="n">nodes</span><span class="p">,</span> <span class="n">temp</span><span class="p">),</span> <span class="n">a</span><span class="p">),</span> <span class="n">k</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="n">spec</span><span class="p">[</span><span class="n">b</span><span class="p">]</span><span class="o">==</span><span class="n">Element</span> <span class="ow">and</span> <span class="n">parent</span><span class="p">[</span><span class="n">b</span><span class="p">]</span> <span class="ow">or</span> <span class="n">b</span><span class="p">)</span> </span><span id="L-420"><a href="#L-420"><span class="linenos" data-line="420"></span></a> <span class="kr">return</span> <span class="n">buffHTML</span><span class="p">.</span><span class="n">__tostring</span><span class="p">(</span><span class="nb">setmetatable</span><span class="p">(</span><span class="n">temp</span><span class="p">,</span> <span class="p">{</span><span class="n">__index</span><span class="o">=</span><span class="n">parent</span><span class="p">[</span><span class="n">v</span><span class="p">],</span> <span class="n">__mode</span><span class="o">=</span><span class="s1">'v'</span><span class="p">}))</span><span class="c1">--switch from tempMeta to avoid MBi._cc op of styles/attributes</span> </span><span id="L-421"><a href="#L-421"><span class="linenos" data-line="421"></span></a> <span class="kr">end</span> </span><span id="L-422"><a href="#L-422"><span class="linenos" data-line="422"></span></a> <span class="kr">end</span> </span><span id="L-423"><a href="#L-423"><span class="linenos" data-line="423"></span></a> <span class="kr">end</span> </span><span id="L-424"><a href="#L-424"><span class="linenos" data-line="424"></span></a> <span class="kr">end</span> </span><span id="L-425"><a href="#L-425"><span class="linenos" data-line="425"></span></a> <span class="kr">return</span> <span class="nb">table.concat</span><span class="p">(</span><span class="n">MBmix</span><span class="p">(</span><span class="n">MBmix</span><span class="p">({},</span> <span class="n">a</span><span class="p">),</span> <span class="n">b</span><span class="p">))</span> </span><span id="L-426"><a href="#L-426"><span class="linenos" data-line="426"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-427"><a href="#L-427"><span class="linenos" data-line="427"></span></a> <span class="n">__pairs</span> <span class="o">=</span> <span class="n">MBpairs</span><span class="p">,</span> </span><span id="L-428"><a href="#L-428"><span class="linenos" data-line="428"></span></a> <span class="n">__ipairs</span> <span class="o">=</span> <span class="n">MBpairs</span><span class="p">,</span> </span><span id="L-429"><a href="#L-429"><span class="linenos" data-line="429"></span></a> <span class="n">__eq</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="kr">return</span> <span class="nb">tostring</span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="o">==</span><span class="nb">tostring</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="kr">end</span><span class="c1">--avoid a==b in this module; use rawequal(a,b) when they may be different Buffers (premature tostring waste ops and is bad for Buffer:_var)</span> </span><span id="L-430"><a href="#L-430"><span class="linenos" data-line="430"></span></a><span class="p">},</span> <span class="p">{</span><span class="n">__tostring</span> <span class="o">=</span> <span class="kr">function</span><span class="p">()</span><span class="kr">return</span><span class="s1">''</span><span class="kr">end</span><span class="p">,</span> </span><span id="L-431"><a href="#L-431"><span class="linenos" data-line="431"></span></a> <span class="n">__call</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> <span class="n">MB</span> <span class="o">=</span> <span class="n">MB</span> <span class="ow">or</span> <span class="n">self</span> </span><span id="L-432"><a href="#L-432"><span class="linenos" data-line="432"></span></a> <span class="kr">if</span> <span class="n">new_G</span> <span class="kr">then</span> <span class="kr">if</span> <span class="p">...</span> <span class="ow">and</span> <span class="nb">_G</span> <span class="ow">and</span> <span class="p">...</span><span class="o">==</span><span class="nb">_G</span> <span class="kr">then</span> <span class="n">new_G</span> <span class="o">=</span> <span class="p">...</span> <span class="kr">end</span> </span><span id="L-433"><a href="#L-433"><span class="linenos" data-line="433"></span></a> <span class="kr">elseif</span> <span class="p">...</span> <span class="ow">and</span> <span class="p">(...</span><span class="o">==</span><span class="nb">_G</span> <span class="ow">or</span> <span class="nb">type</span><span class="p">(...)</span><span class="o">==</span><span class="s1">'table'</span> <span class="ow">and</span> <span class="p">(...).</span><span class="nb">_G</span><span class="o">==</span><span class="p">...)</span> <span class="kr">then</span> </span><span id="L-434"><a href="#L-434"><span class="linenos" data-line="434"></span></a> <span class="kd">local</span> <span class="n">Nil</span><span class="p">,</span> <span class="n">mG</span> <span class="o">=</span> <span class="p">{},</span> <span class="p">(...):</span><span class="nb">getmetatable</span><span class="p">()</span> <span class="ow">or</span> <span class="p">(...):</span><span class="nb">setmetatable</span><span class="p">{}:</span><span class="nb">getmetatable</span><span class="p">()</span> </span><span id="L-435"><a href="#L-435"><span class="linenos" data-line="435"></span></a> <span class="n">new_G</span><span class="p">,</span> <span class="nb">_G</span><span class="p">,</span> <span class="n">gfuncs</span> <span class="o">=</span> <span class="p">...,</span> <span class="p">...,</span> <span class="p">{</span><span class="c1">--gfuncs stored for Buffer:_inHTML; new_G is a is a Module:Buffer local declared just before the final return statement.</span> </span><span id="L-436"><a href="#L-436"><span class="linenos" data-line="436"></span></a> <span class="nb">_G</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-437"><a href="#L-437"><span class="linenos" data-line="437"></span></a> <span class="kd">local</span> <span class="n">X</span><span class="p">,</span> <span class="n">save</span> <span class="o">=</span> <span class="nb">rawget</span><span class="p">(</span><span class="n">new_G</span><span class="p">,</span> <span class="n">i</span><span class="p">),</span> <span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">self</span> <span class="ow">or</span> <span class="p">...</span> </span><span id="L-438"><a href="#L-438"><span class="linenos" data-line="438"></span></a> <span class="kr">if</span> <span class="n">i</span> <span class="ow">and</span> <span class="n">i</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span><span class="n">X</span> <span class="ow">and</span> <span class="n">save</span> <span class="ow">and</span> <span class="nb">rawequal</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">save</span><span class="p">))</span> <span class="ow">and</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">new_G</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">save</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">X</span><span class="o">~=</span><span class="kc">nil</span> <span class="ow">or</span> <span class="n">save</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">and</span> <span class="n">new_G</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">~=</span><span class="kc">nil</span><span class="p">)</span> <span class="kr">then</span><span class="c1">--rawequal in case X is another buffer</span> </span><span id="L-439"><a href="#L-439"><span class="linenos" data-line="439"></span></a> <span class="kd">local</span> <span class="n">mG</span> <span class="o">=</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">new_G</span><span class="p">)</span> <span class="ow">or</span> <span class="p">{</span><span class="n">__call</span><span class="o">=</span><span class="n">mG</span><span class="p">.</span><span class="n">__call</span><span class="p">}</span> </span><span id="L-440"><a href="#L-440"><span class="linenos" data-line="440"></span></a> <span class="kr">if</span> <span class="n">mG</span><span class="p">.</span><span class="n">__index</span> <span class="kr">then</span> <span class="nb">pcall</span><span class="p">(</span><span class="nb">rawset</span><span class="p">,</span> <span class="n">mG</span><span class="p">.</span><span class="n">__index</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">X</span><span class="p">)</span> </span><span id="L-441"><a href="#L-441"><span class="linenos" data-line="441"></span></a> <span class="kr">else</span> <span class="n">mG</span><span class="p">.</span><span class="n">__index</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">new_G</span><span class="p">,</span> <span class="n">mG</span><span class="p">)</span> <span class="ow">and</span> <span class="p">{[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">X</span><span class="p">}</span> <span class="kr">end</span> </span><span id="L-442"><a href="#L-442"><span class="linenos" data-line="442"></span></a> <span class="kr">end</span> </span><span id="L-443"><a href="#L-443"><span class="linenos" data-line="443"></span></a> <span class="kr">return</span> <span class="n">self</span><span class="p">,</span> <span class="p">...</span><span class="c1">--avoiding __eq with rawequal(self,save) is overkill since buffers can self-save without being passed as save</span> </span><span id="L-444"><a href="#L-444"><span class="linenos" data-line="444"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-445"><a href="#L-445"><span class="linenos" data-line="445"></span></a> <span class="n">_R</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">m</span><span class="p">)</span> </span><span id="L-446"><a href="#L-446"><span class="linenos" data-line="446"></span></a> <span class="kr">if</span> <span class="n">i</span><span class="o">~=</span><span class="s1">'new_G'</span> <span class="kr">then</span> <span class="kr">if</span> <span class="n">i</span> <span class="ow">and</span> <span class="n">i</span><span class="o">~=</span><span class="kc">true</span> <span class="kr">then</span> <span class="nb">rawset</span><span class="p">(</span><span class="n">new_G</span><span class="p">,</span> <span class="n">i</span> <span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-447"><a href="#L-447"><span class="linenos" data-line="447"></span></a> <span class="kr">elseif</span> <span class="ow">not</span> <span class="n">v</span> <span class="ow">or</span> <span class="n">v</span><span class="o">==</span><span class="kc">true</span> <span class="ow">or</span> <span class="n">v</span><span class="p">.</span><span class="n">_G</span><span class="o">~=</span><span class="nb">_G</span> <span class="kr">then</span> <span class="n">new_G</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="n">v</span> <span class="ow">or</span> <span class="p">{},</span> <span class="p">{</span><span class="n">__call</span> <span class="o">=</span> <span class="n">mG</span><span class="p">.</span><span class="n">__call</span><span class="p">,</span> <span class="n">__index</span> <span class="o">=</span> <span class="n">v</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="n">m</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="p">(</span><span class="n">m</span> <span class="ow">or</span> <span class="n">new_G</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">nil</span><span class="p">})</span> </span><span id="L-448"><a href="#L-448"><span class="linenos" data-line="448"></span></a> <span class="kr">else</span> <span class="n">new_G</span><span class="p">,</span> <span class="p">(</span><span class="ow">not</span> <span class="n">m</span> <span class="ow">and</span> <span class="p">(</span><span class="n">m</span><span class="o">~=</span><span class="kc">nil</span> <span class="ow">or</span> <span class="n">v</span><span class="o">==</span><span class="n">new_G</span><span class="p">)</span> <span class="ow">and</span> <span class="n">Nil</span> <span class="ow">or</span> <span class="nb">getmetatable</span><span class="p">(</span><span class="n">v</span><span class="p">)).</span><span class="n">__index</span> <span class="o">=</span> <span class="n">v</span><span class="p">,</span> <span class="n">m</span><span class="o">~=</span><span class="kc">true</span> <span class="ow">and</span> <span class="p">(</span><span class="n">m</span> <span class="ow">or</span> <span class="n">new_G</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">nil</span> <span class="kr">end</span><span class="c1">--setting Nil.__index is noOp</span> </span><span id="L-449"><a href="#L-449"><span class="linenos" data-line="449"></span></a> <span class="kr">return</span> <span class="n">self</span> </span><span id="L-450"><a href="#L-450"><span class="linenos" data-line="450"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-451"><a href="#L-451"><span class="linenos" data-line="451"></span></a> <span class="n">_2</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="p">...)</span> </span><span id="L-452"><a href="#L-452"><span class="linenos" data-line="452"></span></a> <span class="kr">if</span> <span class="n">new_G</span><span class="p">[...]</span><span class="o">~=</span><span class="kc">nil</span> <span class="kr">then</span> <span class="kr">return</span> <span class="n">new_G</span><span class="p">[...]</span> <span class="kr">end</span><span class="c1">--higher priority so Buffer:_G('new_G', ...) can prevent an overwrite</span> </span><span id="L-453"><a href="#L-453"><span class="linenos" data-line="453"></span></a> <span class="kr">if</span> <span class="p">...</span><span class="o">==</span><span class="s1">'new_G'</span> <span class="kr">then</span> <span class="kr">return</span> <span class="nb">rawset</span><span class="p">((</span><span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">~=</span><span class="mi">1</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_R</span><span class="p">(</span><span class="n">new_G</span><span class="p">,</span> <span class="p">...)</span> <span class="ow">or</span> <span class="n">new_G</span><span class="p">),</span> <span class="s1">'_G'</span><span class="p">,</span> <span class="nb">_G</span><span class="p">)</span> <span class="kr">end</span> </span><span id="L-454"><a href="#L-454"><span class="linenos" data-line="454"></span></a> <span class="kr">return</span> <span class="nb">select</span><span class="p">(</span><span class="nb">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="mi">1</span> <span class="ow">or</span> <span class="mi">2</span><span class="p">,</span> <span class="n">self</span><span class="p">:</span><span class="nb">_G</span><span class="p">(...))</span><span class="c1">--return only one value; 'return select(2, self:_G(...)) or self' doesn't work for returning nil</span> </span><span id="L-455"><a href="#L-455"><span class="linenos" data-line="455"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-456"><a href="#L-456"><span class="linenos" data-line="456"></span></a> <span class="n">_B</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">self</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="kr">return</span> <span class="n">v</span> <span class="ow">or</span> <span class="n">v</span><span class="o">==</span><span class="kc">nil</span> <span class="ow">and</span> <span class="n">Nil</span> <span class="kr">end</span> </span><span id="L-457"><a href="#L-457"><span class="linenos" data-line="457"></span></a> <span class="p">}</span> <span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">next</span><span class="p">,</span> <span class="n">gfuncs</span> <span class="kr">do</span> <span class="n">MBi</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> <span class="kr">end</span> </span><span id="L-458"><a href="#L-458"><span class="linenos" data-line="458"></span></a> <span class="nb">setmetatable</span><span class="p">(</span><span class="n">Nil</span><span class="p">,{</span><span class="n">__concat</span><span class="o">=</span><span class="n">MB</span><span class="p">.</span><span class="n">__concat</span><span class="p">,</span><span class="n">__newindex</span><span class="o">=</span><span class="n">noOp</span><span class="p">,</span><span class="n">__call</span><span class="o">=</span><span class="n">noOp</span><span class="p">,</span><span class="n">__tostring</span><span class="o">=</span><span class="n">noOp</span><span class="p">,</span><span class="n">__metatable</span><span class="o">=</span><span class="n">MB</span><span class="p">,</span><span class="n">__index</span><span class="o">=</span><span class="nb">setmetatable</span><span class="p">({</span><span class="n">_B</span><span class="o">=</span><span class="n">MBi</span><span class="p">.</span><span class="n">_B</span><span class="p">,</span><span class="n">_</span><span class="o">=</span><span class="kr">function</span><span class="p">()</span><span class="kr">return</span> <span class="n">Nil</span> <span class="kr">end</span><span class="p">,</span><span class="n">last_concat</span><span class="o">=</span><span class="s1">''</span><span class="p">},</span> </span><span id="L-459"><a href="#L-459"><span class="linenos" data-line="459"></span></a> <span class="p">{</span><span class="n">__index</span><span class="o">=</span><span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="n">i</span><span class="p">)</span><span class="kr">return</span> <span class="p">(</span><span class="n">MBi</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">or</span> <span class="n">i</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">tonumber</span><span class="p">(</span><span class="n">i</span><span class="p">))</span> <span class="ow">and</span> <span class="n">t</span><span class="p">.</span><span class="n">_</span> <span class="ow">or</span> <span class="kc">nil</span> <span class="kr">end</span><span class="p">})})</span> </span><span id="L-460"><a href="#L-460"><span class="linenos" data-line="460"></span></a> <span class="kr">function</span> <span class="nc">mG</span><span class="p">.</span><span class="nf">__call</span><span class="p">(</span><span class="n">G</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="p">...)</span> <span class="kr">return</span> <span class="p">(</span><span class="n">k</span><span class="p">.</span><span class="n">_G</span> <span class="ow">or</span> <span class="n">G</span><span class="p">.</span><span class="n">type</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">==</span><span class="s1">'table'</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">G</span><span class="p">.</span><span class="n">select</span><span class="p">(</span><span class="s1">'#'</span><span class="p">,</span> <span class="p">...)</span><span class="o">~=</span><span class="mi">1</span> <span class="ow">and</span> <span class="n">G</span><span class="p">.</span><span class="n">rawset</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="p">...)</span> <span class="ow">or</span> <span class="n">G</span><span class="p">:</span><span class="nb">rawset</span><span class="p">(...,</span> <span class="n">k</span><span class="p">)</span> <span class="ow">and</span> <span class="n">k</span><span class="p">)</span> <span class="ow">or</span> <span class="n">G</span><span class="p">:</span><span class="nb">rawset</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="p">(...))</span> <span class="ow">and</span> <span class="p">...</span> <span class="kr">end</span> </span><span id="L-461"><a href="#L-461"><span class="linenos" data-line="461"></span></a> <span class="kr">end</span> </span><span id="L-462"><a href="#L-462"><span class="linenos" data-line="462"></span></a> <span class="kd">local</span> <span class="n">new</span> <span class="o">=</span> <span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">self</span><span class="p">)</span> </span><span id="L-463"><a href="#L-463"><span class="linenos" data-line="463"></span></a> <span class="kr">if</span> <span class="p">...</span> <span class="ow">and</span> <span class="p">(...)</span><span class="o">==</span><span class="n">new_G</span> <span class="kr">then</span> <span class="kr">return</span> <span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...)</span> <span class="ow">and</span> <span class="n">MBmix</span><span class="p">(</span><span class="n">new</span><span class="p">:</span><span class="nb">_G</span><span class="p">((</span><span class="nb">select</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">...))),</span> <span class="nb">select</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">...))</span> <span class="ow">or</span> <span class="n">new</span> <span class="kr">end</span> </span><span id="L-464"><a href="#L-464"><span class="linenos" data-line="464"></span></a> <span class="kr">return</span> <span class="p">...</span> <span class="ow">and</span> <span class="n">MBi</span><span class="p">.</span><span class="n">_</span><span class="p">(</span><span class="n">new</span><span class="p">,</span> <span class="p">...)</span> <span class="ow">or</span> <span class="n">new</span> </span><span id="L-465"><a href="#L-465"><span class="linenos" data-line="465"></span></a> <span class="kr">end</span><span class="p">,</span> </span><span id="L-466"><a href="#L-466"><span class="linenos" data-line="466"></span></a> <span class="n">__index</span> <span class="o">=</span> <span class="kr">function</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> </span><span id="L-467"><a href="#L-467"><span class="linenos" data-line="467"></span></a> <span class="n">MB</span> <span class="o">=</span> <span class="n">MB</span> <span class="ow">or</span> <span class="n">t</span> <span class="kr">return</span> <span class="n">MBi</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">and</span> <span class="kr">function</span><span class="p">(...)</span> <span class="kr">return</span> <span class="n">MBi</span><span class="p">[</span><span class="n">i</span><span class="p">](</span><span class="nb">setmetatable</span><span class="p">({},</span> <span class="n">t</span><span class="p">),</span> <span class="nb">select</span><span class="p">(...</span><span class="o">==</span><span class="n">t</span> <span class="ow">and</span> <span class="mi">2</span> <span class="ow">or</span> <span class="mi">1</span><span class="p">,...))</span> <span class="kr">end</span> </span><span id="L-468"><a href="#L-468"><span class="linenos" data-line="468"></span></a> <span class="kr">end</span> </span><span id="L-469"><a href="#L-469"><span class="linenos" data-line="469"></span></a><span class="p">})</span> </span></pre></div> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐688fc9465‐zgkhd Cached time: 20241125173818 Cache expiry: 2592000 Reduced expiry: false Complications: [show‐toc] CPU time usage: 0.579 seconds Real time usage: 0.966 seconds Preprocessor visited node count: 5620/1000000 Post‐expand include size: 139440/2097152 bytes Template argument size: 15169/2097152 bytes Highest expansion depth: 17/100 Expensive parser function count: 160/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 95168/5000000 bytes Lua time usage: 0.147/10.000 seconds Lua memory usage: 2124351/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 757.239 1 -total 74.46% 563.822 1 Modul:Buffer/dok 32.99% 249.789 144 Predloga:Code 21.51% 162.870 3 Predloga:Module_other 19.71% 149.232 1 Predloga:Zaščitena_predloga 18.66% 141.276 2 Predloga:Reflist 4.13% 31.281 27 Predloga:Anchor 3.47% 26.293 1 Predloga:Dokumentacija/link_box 3.25% 24.596 2 Predloga:Distinguish 2.85% 21.612 1 Predloga:TOC_right --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Pridobljeno iz »<a dir="ltr" href="https://sl.wikipedia.org/w/index.php?title=Modul:Buffer&oldid=5602693">https://sl.wikipedia.org/w/index.php?title=Modul:Buffer&oldid=5602693</a>«</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Posebno:Kategorije" title="Posebno:Kategorije">Kategoriji</a>: <ul><li><a href="/wiki/Kategorija:Moduli_za_splo%C5%A1no_uporabo" title="Kategorija:Moduli za splošno uporabo">Moduli za splošno uporabo</a></li><li><a href="/wiki/Kategorija:Moduli_odvisni_od_za%C5%A1%C4%8Dite_strani" title="Kategorija:Moduli odvisni od zaščite strani">Moduli odvisni od zaščite strani</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Skriti kategoriji: <ul><li><a href="/wiki/Kategorija:Strani_z_napakami_v_sklicevanju" title="Kategorija:Strani z napakami v sklicevanju">Strani z napakami v sklicevanju</a></li><li><a href="/wiki/Kategorija:Popolnoma_za%C5%A1%C4%8Diteni_moduli" title="Kategorija:Popolnoma zaščiteni moduli">Popolnoma zaščiteni moduli</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> Čas zadnje spremembe strani: 12:32, 13. november 2021.</li> <li id="footer-info-copyright">Besedilo se sme prosto uporabljati v skladu z dovoljenjem <a rel="nofollow" class="external text" href="//creativecommons.org/licenses/by-sa/4.0/">Creative Commons Priznanje avtorstva-Deljenje pod enakimi pogoji 4.0</a>; uveljavljajo se lahko dodatni pogoji. Za podrobnosti glej <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use">Pogoje uporabe</a>.<br /> Wikipedia® je tržna znamka neprofitne organizacije <a rel="nofollow" class="external text" href="https://wikimediafoundation.org">Wikimedia Foundation Inc.</a></li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Pravilnik o zasebnosti</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedija:O_Wikipediji">O Wikipediji</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedija:Splo%C5%A1na_zavrnitev_odgovornosti">Zavrnitve odgovornosti</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Kodeks ravnanja</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Razvijalci</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/sl.wikipedia.org">Statistika</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">O piškotkih</a></li> <li id="footer-places-mobileview"><a href="//sl.m.wikipedia.org/w/index.php?title=Modul:Buffer&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobilni prikaz</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-688fc9465-zgkhd","wgBackendResponseTime":1192,"wgPageParseReport":{"limitreport":{"cputime":"0.579","walltime":"0.966","ppvisitednodes":{"value":5620,"limit":1000000},"postexpandincludesize":{"value":139440,"limit":2097152},"templateargumentsize":{"value":15169,"limit":2097152},"expansiondepth":{"value":17,"limit":100},"expensivefunctioncount":{"value":160,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":95168,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 757.239 1 -total"," 74.46% 563.822 1 Modul:Buffer/dok"," 32.99% 249.789 144 Predloga:Code"," 21.51% 162.870 3 Predloga:Module_other"," 19.71% 149.232 1 Predloga:Zaščitena_predloga"," 18.66% 141.276 2 Predloga:Reflist"," 4.13% 31.281 27 Predloga:Anchor"," 3.47% 26.293 1 Predloga:Dokumentacija/link_box"," 3.25% 24.596 2 Predloga:Distinguish"," 2.85% 21.612 1 Predloga:TOC_right"]},"scribunto":{"limitreport-timeusage":{"value":"0.147","limit":"10.000"},"limitreport-memusage":{"value":2124351,"limit":52428800}},"cachereport":{"origin":"mw-web.codfw.main-688fc9465-zgkhd","timestamp":"20241125173818","ttl":2592000,"transientcontent":false}}});});</script> </body> </html>