[add] text record
This commit is contained in:
parent
f6dbec0b4c
commit
11d165f794
3 changed files with 156 additions and 93 deletions
9
webapp/lsp/text.xq
Normal file
9
webapp/lsp/text.xq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import module namespace text = 'text' at "text.xqm";
|
||||
|
||||
declare variable $long:=file:read-text(file:resolve-path("../../test/sample.docs/pdfbox.xqm",file:base-dir()));
|
||||
declare variable $text:=`ABV
|
||||
ddddd
|
||||
`;
|
||||
|
||||
|
||||
text:build($long)?text()
|
||||
16
webapp/lsp/text.xqm
Normal file
16
webapp/lsp/text.xqm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(:~ 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)
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue