jeffatstepup / ti-html2as

HTML 2 AttributedString converter for Titanium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTML to Attributed String

Dependencies Dev Dependencies

HTML to Ti.UI.iOS.AttributedString parser for Titanium.

Screencast

screencast

Usage

A packaged CommonJS module can be found via Releases.

The module exports a single function that takes an HTML string and a callback to receive an error or Ti.UI.iOS.AttributedString object.

var html2as = require('nl.fokkezb.html2as');

html2as(
	'<font size="17" face="AmericanTypewriter">Hello <b>Bold</b> <a href="http://tidev.io">World</a></font>',
	function(err, as) {

		if (err) {
			console.error(err);

		} else {

			var label = Titanium.UI.createLabel({
				attributedString: as
			});

			label.addEventListener('link', function(e) {
				alert('Longtap on link to: ' + e.url);
			});

			view.add(label);
		}
	}
);

Example

The example folder includes a Titanium project demonstrating the module. To build the module and then run the example project use the included grunt tasks:

npm install
grunt

Issues

Please report issues and features requests in the repo's issue tracker.

Credits

License

This library, ti-html2as, is free software ("Licensed Software"); you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

About

HTML 2 AttributedString converter for Titanium

License:GNU Lesser General Public License v2.1