Nu now includes built in operators for generating HTML and other XML-style markup.
For usage examples, see the test/test_markup.nu unit tests.
As a simple example, this Nu code:
(puts (&html (&body (&h1 "Hello!") (&p "This is a test") (&p "This is a second paragraph"))))
produces the following output:
<!DOCTYPE html><html><body><h1>Hello!</h1><p>This is a test</p><p>This is a second paragraph</p></body></html>
You'll note that no line breaks or formatting is included. These can easily be added with xmllint:
%nush sample-markup.nu | xmllint --format - <?xml version="1.0"?> <!DOCTYPE html> <html> <body> <h1>Hello!</h1> <p>This is a test</p> <p>This is a second paragraph</p> </body> </html>
Also, the Nu source formatter (in beautify.nu) now produces prettier output.
Download Nu here.
This minor update contains better handling of classes whose init methods return something other than self, notably NSXMLDocument. It also changes loading of modules to use a single shared parser so that assignments made in a loaded file are available in the calling context (as they should have been).
This build was made from the "amalgamated" branch. Soon this branch will become "master". As with 2.0, this version of Nu is exclusively for systems running Mac OS 10.7 or iOS 4.3 and their successors.
Nu is an interpreted object-oriented language. Its syntax comes from Lisp, but Nu is semantically closer to Ruby than Lisp. Nu is implemented in Objective-C and is designed to take full advantange of the Objective-C runtime and the many mature class libraries written in Objective-C. Nu code can fully interoperate with code written in Objective-C; messages can be sent to and from objects with no concern for whether those messages are implemented in Objective-C or Nu.
Nu currently requires Mac OS X 10.7 or iOS 4.3 or later.
Nu 2.0 is now available through a binary installer.
See the downloads page for this update to Nu.
Nu 2.0 is a simpler, smaller version that uses new features in iOS 4.3 and Mac OS 10.7 to eliminate external dependencies and a few internal components.
- NSRegularExpression replaces PCRE.
- imp_implementationWithBlock() is used to generate method implementations. Previously we used libFFI for this on MacOS and a precompiled pool of method handlers on iOS. Now this pool is no longer needed.
- The NuSymbolTable is now just an NSMutableDictionary.
To make it easier to add Nu as a drop-in component of iOS and Mac apps, the source code has been combined into two files, Nu.h and Nu.m. These are currently available in the "amalgamated" branch in the git repository, and will likely be the primary source for Nu going forward.
Nu 2.0 is intended for systems running Mac OS 10.7 or iOS 4.3 and their successors. For conciseness and simplicity, support for all other platforms is dropped.