Create HTML template for calltips and tooltips.

        This will display title and text as separate sections and add `...`
        if `ellide` is True and the text is too long.
486558
def _format_text(self, title, text, color, ellide=False):
        
        template = '''
            <div style=\'font-family: "{font_family}";
                        font-size: {title_size}pt;
                        color: {color}\'>
                <b>{title}</b>
            </div>
        '''
        if text:
            template += '''
            <hr>
            <div style=\'font-family: "{font_family}";
                        font-size: {text_size}pt;
                        color: {color_text}\'>
                {text}
            </div>
            '''

        # Prepare text
        if isinstance(text, list):
            text = "\n    ".join(text)

        text = text.replace('\n', '<br>')

        # Ellide the text if it is too long
        if ellide and len(text) > self.calltip_size:
            text = text[:self.calltip_size] + " ..."

        # Get current font properties
        font = self.font()
        font_family = font.family()
        title_size = font.pointSize()
        text_size = title_size - 1 if title_size > 9 else title_size

        tiptext = template.format(
            font_family=font_family,
            title_size=title_size,
            text_size=text_size,
            color=color,
            color_text=self._DEFAULT_TEXT_COLOR,
            title=title,
            text=text,
        )

        return tiptext
881140
private String getDetailsAsHTML(String title, Level level, Throwable e) {
        if (e != null) {
            // convert the stacktrace into a more pleasent bit of HTML
            StringBuffer html = new StringBuffer("<html>");
            html.append("<h2>" + escapeXml(title) + "</h2>");
            html.append("<HR size='1' noshade>");
            html.append("<div></div>");
            html.append("<b>Message:</b>");
            html.append("<pre>");
            html.append("    " + escapeXml(e.toString()));
            html.append("</pre>");
            html.append("<b>Level:</b>");
            html.append("<pre>");
            html.append("    " + level);
            html.append("</pre>");
            html.append("<b>Stack Trace:</b>");
            html.append("<pre>");
            for (StackTraceElement el : e.getStackTrace()) {
                html.append("    " + el.toString().replace("<init>", "&lt;init&gt;") + "\n");
            }
            if (e.getCause() != null) {
                html.append("</pre>");
                html.append("<b>Cause:</b>");
                html.append("<pre>");
                html.append(e.getCause().getMessage());
                html.append("</pre><pre>");
                for (StackTraceElement el : e.getCause().getStackTrace()) {
                    html.append("    " + el.toString().replace("<init>", "&lt;init&gt;") + "\n");
                }
            }
            html.append("</pre></html>");
            return html.toString();
        } else {
            return null;
        }
    }
645944
function tip(title, content, actions, type) {
  if (curTip) {
    curTip.close(() => {
      setTimeout(() => {
        AppContainer.remove(topViewDialogKey);
        setTimeout(() => {
          creatTip(title, content, actions);
        }, 0);
      }, 200);
    });
  } else {
    creatTip(title, content, actions, type);
  }
}
1650
function createDomElementFromTemplate(html) {
    //match container markers like <@element/>
    let containerTags = html.match(rContainerGlobal) || [];

    for (let containerTag of containerTags) {
        let [, containerName, attrs = ''] = rContainer.exec(containerTag);
        let template = `<script type="x" ${ATTR}="${containerName}">${attrs.trim()}</script>`;

        html = html.split(containerTag).join(template);
    }

    //match attribute markers like <span @element></span>
    let allTags = html.match(rTags) || [];

    for (let tag of allTags) {
        let result = rAttr.exec(tag);

        if (result) {
            let elName = result[1];
            html = html.split(tag).join(tag.replace(`@${elName}`, `${ATTR}="${elName}"`));
        }
    }

    return $.create(html.trim());
}
552352
function show() {
            var position,
                ttWidth,
                ttHeight,
                ttPosition;

            // Don't show empty tooltips.
            if ( ! scope.tt_content ) {
              return;
            }

            // If there is a pending remove transition, we must cancel it, lest the
            // tooltip be mysteriously removed.
            if ( transitionTimeout ) {
              $timeout.cancel( transitionTimeout );
            }

            // Set the initial positioning.
            tooltip.css({ top: 0, left: 0, display: 'block' });

            // Now we add it to the DOM because need some info about it. But it's not
            // visible yet anyway.
            if ( appendToBody ) {
                $body.append( tooltip );
            } else {
              element.after( tooltip );
            }

            // Get the position of the directive element.
            position = appendToBody ? $position.offset( element ) : $position.position( element );

            // Get the height and width of the tooltip so we can center it.
            ttWidth = tooltip.prop( 'offsetWidth' );
            ttHeight = tooltip.prop( 'offsetHeight' );

            // Calculate the tooltip's top and left coordinates to center it with
            // this directive.
            switch ( scope.tt_placement ) {
              case 'right':
                ttPosition = {
                  top: position.top + position.height / 2 - ttHeight / 2,
                  left: position.left + position.width
                };
                break;
              case 'bottom':
                ttPosition = {
                  top: position.top + position.height,
                  left: position.left + position.width / 2 - ttWidth / 2
                };
                break;
              case 'left':
                ttPosition = {
                  top: position.top + position.height / 2 - ttHeight / 2,
                  left: position.left - ttWidth
                };
                break;
              default:
                ttPosition = {
                  top: position.top - ttHeight,
                  left: position.left + position.width / 2 - ttWidth / 2
                };
                break;
            }

            ttPosition.top += 'px';
            ttPosition.left += 'px';

            // Now set the calculated positioning.
            tooltip.css( ttPosition );

            // And show the tooltip.
            scope.tt_isOpen = true;
          }
985410
def html(self):
        
        # No empty tooltips
        if self.description:
            tooltip = 'tooltip="{}"'.format(self.description)
        else:
            tooltip = ''

        return entry_html(
            title=self.title,
            thumbnail=self.thumbnail,
            link=self.html_link,
            tooltip=tooltip)
577028
function _renderImmediateInfo(contentsDiv, contents, context) {						
			// If it's an annotation then process the annotation(s) to get the actual data
			if (contents instanceof Array) {
				contents = this._getAnnotationContents(contents, context);			
				if (!contents) {
					return false;
				}
			}
			
			if (typeof contents === "string") {
				contentsDiv.textContent = contents;
				return true;
			} else if (this._isNode(contents)) {
				contentsDiv.appendChild(contents);
				return true;
			} else if (contents instanceof mProjectionTextModel.ProjectionTextModel) {
				var view = this._view;
				var options = view.getOptions();
				options.wrapMode = false;
				options.parent = contentsDiv;
				var tooltipTheme = "tooltipTheme"; //$NON-NLS-0$
				var theme = options.themeClass;
				if (theme) {
					theme = theme.replace(tooltipTheme, "");
					if (theme) { theme = " " + theme; } //$NON-NLS-0$
					theme = tooltipTheme + theme;
				} else {
					theme = tooltipTheme;
				}
				options.themeClass = theme;
				var contentsView = this._contentsView = new mTextView.TextView(options);
				//TODO need to find a better way of sharing the styler for multiple views
				var listener = {
					onLineStyle: function(e) {
						view.onLineStyle(e);
					}
				};
				contentsView.addEventListener("LineStyle", listener.onLineStyle);
				contentsView.setModel(contents);
				
				// TODO This is a hack to compute the projection size we will have in the tooltip, we remove the child after computing
				this._tooltipDiv.appendChild(contentsDiv);
				// Use the editor colors with a simple border
				this._tooltipDiv.classList.add("textviewTooltipCodeProjection"); //$NON-NLS-0$
				var size = contentsView.computeSize();
				// Adjust the size for the padding
				contentsDiv.style.width = (size.width+16) + "px"; //$NON-NLS-0$
				contentsDiv.style.height = (size.height+16) + "px"; //$NON-NLS-0$
				contentsView.resize();
				this._tooltipDiv.removeChild(contentsDiv);
				return true;
			}
			return false;
		}
349589
function setSlideContent() {
        var slide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

        var _this = this;

        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

        if (hasClass(slide, 'loaded')) {
            return false;
        }

        if (utils.isFunction(this.settings.beforeSlideLoad)) {
            this.settings.beforeSlideLoad(slide, data);
        }

        var type = data.type;
        var position = data.descPosition;
        var slideMedia = slide.querySelector('.gslide-media');
        var slideTitle = slide.querySelector('.gslide-title');
        var slideText = slide.querySelector('.gslide-desc');
        var slideDesc = slide.querySelector('.gdesc-inner');
        var finalCallback = callback;

        if (utils.isFunction(this.settings.afterSlideLoad)) {
            finalCallback = function finalCallback() {
                if (utils.isFunction(callback)) {
                    callback();
                }
                _this.settings.afterSlideLoad(slide, data);
            };
        }

        if (data.title == '' && data.description == '') {
            if (slideDesc) {
                slideDesc.parentNode.removeChild(slideDesc);
            }
        } else {
            if (slideTitle && data.title !== '') {
                slideTitle.innerHTML = data.title;
            } else {
                slideTitle.parentNode.removeChild(slideTitle);
            }
            if (slideText && data.description !== '') {
                if (isMobile && this.settings.moreLength > 0) {
                    data.smallDescription = slideShortDesc(data.description, this.settings.moreLength, this.settings.moreText);
                    slideText.innerHTML = data.smallDescription;
                    slideDescriptionEvents.apply(this, [slideText, data]);
                } else {
                    slideText.innerHTML = data.description;
                }
            } else {
                slideText.parentNode.removeChild(slideText);
            }
            addClass(slideMedia.parentNode, 'desc-' + position);
            addClass(slideDesc.parentNode, 'description-' + position);
        }

        addClass(slideMedia, 'gslide-' + type);
        addClass(slide, 'loaded');

        if (type === 'video') {
            slideMedia.innerHTML = '<div class="gvideo-wrapper"></div>';
            setSlideVideo.apply(this, [slide, data, finalCallback]);
            return;
        }

        if (type === 'external') {
            var iframe = createIframe({
                url: data.href,
                width: data.width,
                height: data.height,
                callback: finalCallback
            });
            slideMedia.parentNode.style.maxWidth = data.width + 'px';
            slideMedia.appendChild(iframe);
            return;
        }

        if (type === 'inline') {
            setInlineContent.apply(this, [slide, data, finalCallback]);
            return;
        }

        if (type === 'image') {
            var img = new Image();
            img.addEventListener('load', function () {
                if (utils.isFunction(finalCallback)) {
                    finalCallback();
                }
            }, false);
            img.src = data.href;
            slideMedia.appendChild(img);
            return;
        }

        if (utils.isFunction(finalCallback)) finalCallback();
    }
55044
function updateTopicContent(topic){
            let name = topic[nameLabel],
                tooltipRight,
                tooltipLeftText,
                tooltipRightText,
                elementText;

            tooltipLeftText = topic.topicName || name;
            tooltipRightText = getValueText(topic);

            elementText = tooltipBody
              .append('text')
                .classed('tooltip-left-text', true)
                .attr('dy', '1em')
                .attr('x', ttTextX)
                .attr('y', ttTextY)
                .style('fill', tooltipTextColor)
                .text(tooltipLeftText)
                .call(textWrap, tooltipMaxTopicLength, initialTooltipTextXPosition);

            tooltipRight = tooltipBody
              .append('text')
                .classed('tooltip-right-text', true)
                .attr('dy', '1em')
                .attr('x', ttTextX)
                .attr('y', ttTextY)
                .style('fill', tooltipTextColor)
                .text(tooltipRightText);

            // IE11 give us sometimes a height of 0 when hovering on top of the vertical marker
            // This hack fixes it for some cases, but it doesn't work in multiline (they won't wrap)
            // Let's remove this once we stop supporting IE11
            textHeight = elementText.node().getBBox().height ? elementText.node().getBBox().height : textHeight;

            tooltipHeight += textHeight + tooltipTextLinePadding;
            // update the width if it exists because IE renders the elements
            // too slow and cant figure out the width?
            tooltipRightWidth = tooltipRight.node().getBBox().width ? tooltipRight.node().getBBox().width : tooltipRightWidth;
            tooltipRight.attr( 'x', tooltipWidth - tooltipRightWidth - 10 - tooltipWidth / 4 );

            tooltipBody
                .append('circle')
                .classed('tooltip-circle', true)
                .attr('cx', 23 - tooltipWidth / 4)
                .attr('cy', (ttTextY + circleYOffset))
                .attr('r', 5)
                .style('fill', colorMap[name])
                .style('stroke-width', 1);

            ttTextY += textHeight + 7;
        }
1190874
function (html) {
  var $ = cheerio.load(html, {
    decodeEntities: false,
    lowerCaseAttributeNames: false,
    lowerCaseTags: false
  });

  var output = {
    style: $.html('style'),
    script: $.html('script')
  };
  var result;

  $('style').remove();
  $('script').remove();

  result = '<template><section>' + $.html() + '</section></template>\n' +
    output.style + '\n' +
    output.script;

  return result
}
1284530
def make_text_page(self, valumap):
        
        logger.info('Making a text report page using template %r.', self.text_template)
        fh = open(self.text_template)
        template = fh.read()
        fh.close()
        
        parts = []
        for sr in self.subreports:
            report_data = [item.text for item in sr.report_data if item.text]
            if report_data:
                parts.append('\n{1}\n***** {0} *****\n{1}'.format(sr.title, '*' * (len(sr.title)+12)))
                parts.extend(report_data)

        valumap['subreports'] = '\n'.join(parts) # "\n<<NO SUBREPORT RELATED EVENTS>>\n"
        text_page = Template(template).safe_substitute(valumap)
        return TextPart(fmt='text', text=text_page, ext='txt')
184411
def show_calltip(self, signature, doc='', parameter='', parameter_doc='',
                     color=_DEFAULT_TITLE_COLOR, is_python=False):
        
        # Find position of calltip
        point = self._calculate_position()

        # Format text
        tiptext, wrapped_lines = self._format_signature(
            signature,
            doc,
            parameter,
            parameter_doc,
            color,
            is_python,
        )

        self._update_stylesheet(self.calltip_widget)

        # Show calltip
        self.calltip_widget.show_tip(point, tiptext, wrapped_lines)
944058
function(text) {
                // 
                if (isCss) {
                    if (resource.styleSheet) {
                        resource.styleSheet.cssText = text;
                    } else {
                        resource.appendChild(document.createTextNode(text));
                    }
                } else {
                    if (resource.innerText) {
                        resource.innerText = text;
                    } else {
                        resource.appendChild(document.createTextNode(text));
                    }
                }
                if (callback) {
                    callback(resourcePath, hashId);
                }
            }
1185996
function(ctx, title) {
				// set node connector images, links and text
				var checkbox,
					className,
					icon,
					nodeTitle,
					role,
					tabindex,
					tooltip,
					iconTooltip,
					node = ctx.node,
					tree = ctx.tree,
					opts = ctx.options,
					aria = opts.aria,
					level = node.getLevel(),
					ares = [];

				if (title !== undefined) {
					node.title = title;
				}
				if (!node.span || tree._enableUpdate === false) {
					// Silently bail out if node was not rendered yet, assuming
					// node.render() will be called as the node becomes visible
					return;
				}
				// Connector (expanded, expandable or simple)
				role =
					aria && node.hasChildren() !== false
						? " role='button'"
						: "";
				if (level < opts.minExpandLevel) {
					if (!node.lazy) {
						node.expanded = true;
					}
					if (level > 1) {
						ares.push(
							"<span " +
								role +
								" class='fancytree-expander fancytree-expander-fixed'></span>"
						);
					}
					// .. else (i.e. for root level) skip expander/connector alltogether
				} else {
					ares.push(
						"<span " + role + " class='fancytree-expander'></span>"
					);
				}
				// Checkbox mode
				checkbox = FT.evalOption("checkbox", node, node, opts, false);

				if (checkbox && !node.isStatusNode()) {
					role = aria ? " role='checkbox'" : "";
					className = "fancytree-checkbox";
					if (
						checkbox === "radio" ||
						(node.parent && node.parent.radiogroup)
					) {
						className += " fancytree-radio";
					}
					ares.push(
						"<span " + role + " class='" + className + "'></span>"
					);
				}
				// Folder or doctype icon
				if (node.data.iconClass !== undefined) {
					// 2015-11-16
					// Handle / warn about backward compatibility
					if (node.icon) {
						$.error(
							"'iconClass' node option is deprecated since v2.14.0: use 'icon' only instead"
						);
					} else {
						node.warn(
							"'iconClass' node option is deprecated since v2.14.0: use 'icon' instead"
						);
						node.icon = node.data.iconClass;
					}
				}
				// If opts.icon is a callback and returns something other than undefined, use that
				// else if node.icon is a boolean or string, use that
				// else if opts.icon is a boolean or string, use that
				// else show standard icon (which may be different for folders or documents)
				icon = FT.evalOption("icon", node, node, opts, true);
				// if( typeof icon !== "boolean" ) {
				// 	// icon is defined, but not true/false: must be a string
				// 	icon = "" + icon;
				// }
				if (icon !== false) {
					role = aria ? " role='presentation'" : "";

					iconTooltip = FT.evalOption(
						"iconTooltip",
						node,
						node,
						opts,
						null
					);
					iconTooltip = iconTooltip
						? " title='" + _escapeTooltip(iconTooltip) + "'"
						: "";

					if (typeof icon === "string") {
						if (TEST_IMG.test(icon)) {
							// node.icon is an image url. Prepend imagePath
							icon =
								icon.charAt(0) === "/"
									? icon
									: (opts.imagePath || "") + icon;
							ares.push(
								"<img src='" +
									icon +
									"' class='fancytree-icon'" +
									iconTooltip +
									" alt='' />"
							);
						} else {
							ares.push(
								"<span " +
									role +
									" class='fancytree-custom-icon " +
									icon +
									"'" +
									iconTooltip +
									"></span>"
							);
						}
					} else if (icon.text) {
						ares.push(
							"<span " +
								role +
								" class='fancytree-custom-icon " +
								(icon.addClass || "") +
								"'" +
								iconTooltip +
								">" +
								FT.escapeHtml(icon.text) +
								"</span>"
						);
					} else if (icon.html) {
						ares.push(
							"<span " +
								role +
								" class='fancytree-custom-icon " +
								(icon.addClass || "") +
								"'" +
								iconTooltip +
								">" +
								icon.html +
								"</span>"
						);
					} else {
						// standard icon: theme css will take care of this
						ares.push(
							"<span " +
								role +
								" class='fancytree-icon'" +
								iconTooltip +
								"></span>"
						);
					}
				}
				// Node title
				nodeTitle = "";
				if (opts.renderTitle) {
					nodeTitle =
						opts.renderTitle.call(
							tree,
							{ type: "renderTitle" },
							ctx
						) || "";
				}
				if (!nodeTitle) {
					tooltip = FT.evalOption("tooltip", node, node, opts, null);
					if (tooltip === true) {
						tooltip = node.title;
					}
					// if( node.tooltip ) {
					// 	tooltip = node.tooltip;
					// } else if ( opts.tooltip ) {
					// 	tooltip = opts.tooltip === true ? node.title : opts.tooltip.call(tree, node);
					// }
					tooltip = tooltip
						? " title='" + _escapeTooltip(tooltip) + "'"
						: "";
					tabindex = opts.titlesTabbable ? " tabindex='0'" : "";

					nodeTitle =
						"<span class='fancytree-title'" +
						tooltip +
						tabindex +
						">" +
						(opts.escapeTitles
							? FT.escapeHtml(node.title)
							: node.title) +
						"</span>";
				}
				ares.push(nodeTitle);
				// Note: this will trigger focusout, if node had the focus
				//$(node.span).html(ares.join("")); // it will cleanup the jQuery data currently associated with SPAN (if any), but it executes more slowly
				node.span.innerHTML = ares.join("");
				// Update CSS classes
				this.nodeRenderStatus(ctx);
				if (opts.enhanceTitle) {
					ctx.$title = $(">span.fancytree-title", node.span);
					nodeTitle =
						opts.enhanceTitle.call(
							tree,
							{ type: "enhanceTitle" },
							ctx
						) || "";
				}
			}
326183
function () {
		
		// Create Layout
		this._el.content_container			= TL.Dom.create("div", "tl-text-content-container", this._el.container);
		
		// Date
		this._el.date 				= TL.Dom.create("h3", "tl-headline-date", this._el.content_container);
		
		// Headline
		if (this.data.headline != "") {
			var headline_class = "tl-headline";
			if (this.options.title) {
				headline_class = "tl-headline tl-headline-title";
			}
			this._el.headline				= TL.Dom.create("h2", headline_class, this._el.content_container);
			this._el.headline.innerHTML		= this.data.headline;
		}

		// Text
		if (this.data.text != "") {
			var text_content = "";

			text_content += TL.Util.htmlify(this.options.autolink == true ? TL.Util.linkify(this.data.text) : this.data.text);
			trace(this.data.text);
			this._el.content				= TL.Dom.create("div", "tl-text-content", this._el.content_container);
			this._el.content.innerHTML		= text_content;
			trace(text_content);
			trace(this._el.content)
		}

		// Fire event that the slide is loaded
		this.onLoaded();

	}
486798
function alert(message, options) {
            var template = "\n            <script type=\"text/template\">\n                <section class=\"ui-modal\" data-role=\"popup\" data-corners=\"false\">\n                    <div class=\"ui-content\">\n                        <h1 class=\"ui-title {{_titleState}}\">{{title}}</h1>\n                        <p class=\"ui-message\">{{message}}</p>\n                    </div>\n                    <div class=\"ui-modal-footer ui-grid-solo\">\n                        <button id=\"{{idPositive}}\" class=\"ui-btn ui-block-a ui-text-emphasis\" data-auto-close=\"true\">{{labelPositive}}</button>\n                    </div>\n                </section>\n            </script>\n        ";
            var dlgAlert = new UI.Dialog(template, $.extend({}, {
                src: null,
                message: message,
            }, options));
            return dlgAlert.show();
        }
840498
function() {
  HelpDocument.apply(this, arguments);
  this.useCustom = false;
  this.sections = [
    HelpDocument.SYNOPSIS,
    HelpDocument.DESCRIPTION,
    HelpDocument.COMMANDS,
    HelpDocument.OPTIONS,
    HelpDocument.BUGS
  ]
}