.\" This man page is automatically generated using .\" kayadoc2man from the Kaya development tools and the -xmldocs compile .\" option. Editing it directly is not encouraged. .\" It is under the same license as the source .k file that it was .\" generated from. .TH "HTMLDocument.addInlineElementAt" "3kaya" "August 2014" "Kaya" "Kaya module reference" .SH "NAME" HTMLDocument::addInlineElementAt \- Wrap existing text in an inline element .SH "SYNOPSIS" .B ElementTree addInlineElementAt( \fIElementTree block, InlineElement inline, Int startpos, Int endpos\fP .B ")" .SH "ARGUMENTS" .PP .B "block" The element to add to .PP .B "inline" The inline element to add .PP .B "startpos" The start position for the inline element .PP .B "endpos" The end position for the inline element .SH "DESCRIPTION" .PP Encloses existing text within an element within an inline element. The characters from \fBstartpos \fP to \fBendpos \fP inclusive (with a starting index of zero) will be included in the inline element. .IP "" -4 p = addParagraph(parent,"abcdefghijklmnopqrstuvwxyz"); void(addInlineElementAt(p,Emphasis,5,10)); void(addInlineElementAt(p,StrongEmphasis,6,8)); //

abcdefghijklmnopqrstuvwxyz

.PP An .B "HTMLDocument.InvalidNesting"(3kaya) Exception will be thrown if the element being added to cannot contain inline elements, or an impossible nesting situation would be created. An .B "HTMLDocument.InvalidRange"(3kaya) Exception will be thrown if the \fBstartpos \fP or \fBendpos \fP are outside the text contents of the block. .IP "" -4 p = addParagraph(parent,"abcdefghijklmnopqrstuvwxyz"); void(addInlineElementAt(p,Emphasis,5,10)); void(addInlineElementAt(p,StrongEmphasis,6,15)); // exception thrown .PP The \fBfirstOccurs \fP function is useful for highlighting a particular word within a string. .IP "" -4 haystack = getAllText(element); npos = firstOccurs(needle,haystack); if (npos < length(haystack)) { try { added = addInlineElementAt(element,Emphasis,npos,npos+length(needle)+1); } catch(InvalidNesting(details)) { // probably overlapping elements } } .SH "AUTHORS" Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ .SH LICENSE The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation. .SH "RELATED" .PD 0 .PP .B "HTMLDocument.InlineElement"(3kaya) .PP .B "HTMLDocument.appendInlineElement"(3kaya) .PP .B "Strings.firstOccurs_1"(3kaya) .PD 0.4v