Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Unindent/doc

From Wikipedia, the free encyclopedia

Unindent resets the indentation level of mulitline strings. It is useful for multiline strings inside functions and large tables. This module serves as a utility function for string parsing.

Lua supports multiline strings in the format [[\n...\n]]. In general, Lua does not outdent indented multiline strings out of the box. Though Lua supports variable indentation in multiline strings, custom logic is necessary to reset the string's indentation. This module adopts a flexible approach based on string scanning.

Unlike Penlight's pl.text.dedent behaviour where every line has the indentation of the first line removed, the line prefixed with the least non-tab whitespace is reset to zero indentation. Thus, the opening line of the string may retain some indentation if there are lines of less indentation terminating the string.

Documentation

Package function

unindent( str ) (function)
Unindent resets the indentation level of mulitline strings.
Parameter: str Multiline string indented consistently. (string)
Returns: Unindented string. (string)

Documentation above is auto generated

Module information card (autogenerated)
NameValue
Variableunindent(str)
CodeModule:Unindent
Release statusstable
DescriptionUnindent resets the indentation level of mulitline strings.
Author 8nml
Using code by@kikito (GitHub)