විකිපීඩියා:Lua string functions
මෙම පිටුව ඉංග්රීසි ව්යාපෘතියෙන් මෙහි ගෙනවිත් ඇත. අන්තර්ගතය අපගේ ව්යාපෘතිය සමඟ 100% නොගැලපෙනමුත් අපගේ අවශ්යතාවයන් වලට අනුකූලව ගොඩනගා ගැනීම සඳහා මූලික පියවර ලෙස භාවිතා කළ හැකිය. |
මෙය රචනාවකි. මෙහි විකිපීඩියාවේ සංස්කාරකවරයකුගේ හෝ කිහිපදෙනෙකුගේ උපදෙස් සහ අදහස් දැක්වෙයි. මෙම පිටුව විශ්වකෝෂ ලිපියක් හෝ විකිපීඩියාවේ ප්රතිපත්ති හෝ මාර්ගෝපදේශ වලින් එකක් නොවේ. මෙය ප්රජාව විසින් හොඳින් අධ්යයනය කොට පිළිගැනීමට ලක් වූවක් ද නොවේ. සමහර රචනා පුළුල් ප්රතිමානයන් (widespread norms) නිරූපණය කරන අතර; අනෙක්වා සුළුතර මත පමණක් නිරූපණය කරයි. මෙම අදහස් බුද්ධිමත් ලෙසින් සලකා බලන්න. |
This essay lists Lua string functions and describes the use of Lua script to handle text strings in Wikipedia pages.
Module:String
සංස්කරණයThe main set of Lua string-handling functions are stored in Module:String.
Performance considerations
සංස්කරණයThe string-search functions in Lua script can run extremely fast, comparing millions of characters per second. For example, a search of a 40,000-character article text, for 99 separate words (passed as 99 parameters in a template), ran within one second of Lua CPU clock time. That total time involved the pinpointing of the locations of each of those 99 words in the long text, as scattered across the text.
Limitations on strings
සංස්කරණයLua can process text strings in excess of 230,000 characters, which allows the formatted contents of article pages to be used as input to string searches. However, there have been some limitations in string contents, such as hidden strings enclosed in nowiki-tag or pre-tag elements.
There seem to have been "bugs" in Lua chopping text which contains wikitables, either with "{|" tokens or with "<table>" tags. Although Lua has been used to scan entire articles (with expansion of all infoboxes, span-tags, {convert}'s, category links, and navboxes), unless some wikitables are commented-out by "<!--...-->" or noinclude'd, then Lua's view of the article contents has seemed to stop at the first wikitable. That action seems like a bug, where Lua should allow all article-page data into a text string. Also, Lua cannot see inside a nowiki tag (nor inside a "<pre>" tag), which always has length 43 characters, and never reveals any contents between "<nowiki>...</nowiki>" but only text before/after the nowiki tags.
Example of <table>: Seems to work for small tables. Compare the effect of "<table>" with the Lua-based Template:Str_find, in searching the whole string length:
Using the "<table>" tag formerly stopped the string. Also, inserting a wikitable "{|" in column 1 would produce a similar effect (since "{|" generates a "<table>" tag). However it seems correct now in this example.
Example of <nowiki>: Compare the effect of "<nowiki>" with the Lua-based Template:Str_len, in getting the whole string length:
Using the "<nowiki>" tag hides the text but counts as +34 characters. So, for the case Nw2, the length is 4+34+4=42, and Nw3 yielded 4+34+2=40 characters long.
The mw.text.unstrip function at MediaWiki's "Lua reference manual" (which is not yet live) may be of help with the nowiki tags. Also see: T47085).
See also
සංස්කරණය- Template:String-handling templates -- overview of Lua templates in this
- English Wikipedia-specific resources
- Wikipedia:Lua style guide – standards to improve the readability of code through consistency
- Special:PrefixIndex/Module:String – tracking of Lua modules can be done by using Special:PrefixIndex
- Help:Lua debugging – a how-to guide about debugging Lua modules
- Category:Lua-based templates – groups of Lua-based templates
- Module:Sandbox provides a pseudo-namespace for experimenting with Lua modules.
- Wikipedia:Lua requests – requests for Lua-based templates or tasks