basex-lsp/webapp/lsp/text.xqm
2025-09-26 15:18:14 +01:00

16 lines
No EOL
447 B
Text

(:~ handle textDocument
: @author andy bunce
:)
module namespace text = 'text';
declare record text:rec(
lines as xs:string+,
separator? as xs:string:=file:line-separator(),
text? as fn() as xs:string:= %method fn () { string-join(?lines,?separator) },
line? := %method fn($line) {?lines[$line]}
);
declare function text:build($text as xs:string){
let $lines:=tokenize($text, '(\r\n?|\n\r?)')
return text:rec($lines)
};