line 1 |> line2
This document describes the standard functions distributed with Textrude in the lib
folder.
indent <n>
Sets the default indent level
input
include "lib/cpp.sbn"
cpp.indent 5
cpp.pad
"padded text"
output
padded text
linefeed
Inserts a linefeed
input
include "lib/cpp.sbn"
"line1"
cpp.linefeed
"line2"
output
line1
line2
pad
Inserts a pad at the current indent level
input
include "lib/cpp.sbn"
cpp.indent 5
cpp.pad
"padded text"
output
padded text
block_comment <text>
Creates a brief-style block comment
input
include "lib/cpp.sbn"
cpp.block_comment "this is a summary"
output
/*!
@brief this is a summary
*/
forall <items> <function>
Applies a function to all items. All items are separated by a linefeed and comma except for the last
input
include "lib/cpp.sbn"
["abc","def"]
|> cpp.forall @{$0}@
output
abc,
def
indent <n>
Sets the default indent level
input
include "lib/csharp.sbn"
csharp.indent 5
csharp.pad
"padded text"
output
padded text
linefeed
Inserts a linefeed
input
include "lib/csharp.sbn"
"line1"
csharp.linefeed
"line2"
output
line1
line2
summary_comment <text>
Creates an intellisense summary block
input
include "lib/csharp.sbn"
csharp.summary_comment "this is a summary"
output
/// <summary>
/// this is a summary
/// </summary>
pad
Inserts a pad at the current indent level
input
include "lib/csharp.sbn"
csharp.indent 5
csharp.pad
"padded text"
output
padded text
forall <items> <function>
Applies a function to all items. All items are separated by a linefeed and comma except for the last
input
include "lib/csharp.sbn"
["abc","def"]
|> csharp.forall @{$0}@
output
abc,
def
i
ensures case-insensitive matching"
input
include "lib/line.sbn"
import line
["line1","LINE2"]
|> must_contain "line" i
|> display
output
line1
LINE2
literal <expression>
escapes a regex to make it literal
input
include "lib/line.sbn"
import line
"abc.*" |> literal
output
abc\.\*
line_match <line> <regex> <options>
tests whether the line matches the regex
input
include "lib/line.sbn"
import line
"abcdefg"
|> line_match "abc..fg"
output
true
must_contain <line array> <regex> <options>
returns only lines that contains the supplied regex
input
include "lib/line.sbn"
import line
["abcdefg","abc"]
|> must_contain "abc..fg"
|> display
output
abcdefg
extract <line array> <regex> <options>
extracts only the matching portions of each line
input
include "lib/line.sbn"
import line
["abcdefg","abc123defg"]
|> extract "abc.."
|> display
output
["abcde"]
["abc12"]
is_not_empty <line array>
returns only non-empty lines
input
include "lib/line.sbn"
import line
["abcdefg",""," ","def "]
|> extract "abc.."
|> display
output
["abcde"]
[]
[]
[]
take <line array> <n>
Takes the first n lines in the pipeline
input
include "lib/line.sbn"
import line
["1","2","3","4"]
|> take 2
|> display
output
1
2
skip <line array> <n>
Skips the first n lines in the pipeline
input
include "lib/line.sbn"
import line
["1","2","3","4"]
|> skip 2
|> display
output
3
4
take_until <line array> <regex> <options>
Takes lines until the regex is matched
input
include "lib/line.sbn"
import line
["1","2","STOP","4"]
|> take_until "STOP"
|> display
output
1
2
take_after <line array> <regex> <options>
Skips lines until the regex is matched
input
include "lib/line.sbn"
import line
["1","2","START","4"]
|> take_until "START"
|> display
output
1
2
remove_text <line array> <regex> <options>
Removes text matching the supplied regex from all lines
input
include "lib/line.sbn"
import line
["1abcE","abcxyz","12354","ghabcdere"]
|> remove_text "abc"
|> display
output
1E
xyz
12354
ghdere
chop_left <line array> <n>
Removes the first n characters from each line in the pipeline
input
include "lib/line.sbn"
import line
["12345678","12345678","STOP","4"]
|> chop_left "2"
|> display
output
345678
345678
OP
display <line array>
Displays a pipeline with one element per line
input
include "lib/line.sbn"
import line
["12345678","12345678","STOP","4"]
|> display
output
12345678
12345678
STOP
4
show_count <line array> <message>
Displays the number of items in the pipeline at each point
input
include "lib/line.sbn"
import line
["12345678","12345678","STOP","4"]
|> show_count "at beginning of pipeline"
|> must_contain "12"
|> show_count "after selecting for '12'"
|> display
output
Count: at beginning of pipeline 4
Count: after selecting for '12' 2
12345678
12345678
group_by <line array> <regex>
Groups lines by match against regex
input
include "lib/line.sbn"
import line
grp = ["12345678","12345678","STOP","4"]
|> group_by "^."
debug.dump grp
output
{}
group_do <group> <function>
Applies a function to a group
input
include "lib/line.sbn"
import line
grp = ["12345678","12345678","STOP","4"]
|> group_by "^."
|> group_do @{""+$0 +"->" +($1| array.size)+" values" }@
|> group.flatten
|> display
output
apply <list> <function>
Applies a function to each element in a list. Unlike array.each, this function expects to emit text 'inline' rather than returning an array
input
include "lib/misc.sbn"
[1,2,3] | apply @(do; $0*2;end)
output
246
autogenwarning
Generates a boilerplate warning using C++ block commenting
input
include "lib/warnings.sbn"
autogenwarning
output
/*
WARNING
-------
This file was auto-generated.
Do not modify by hand - your changes will be lost .
Built: 03:15:10 PM on Friday, 12 Jan 2024
Machine: NPM-OFFICE
User: User
*/