diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-10 18:28:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-10 18:28:53 +0200 |
commit | 63aaad529c9ae9358f22fd9563aeabc679f4defd (patch) | |
tree | 67adfffcb14250f083d86b568577a8a2eb7bdf9f /tests/web/xhtml | |
parent | 8e866579cb459c5104c532d5e41d562d45236ea5 (diff) |
Add support for generating XHTML5
Diffstat (limited to 'tests/web/xhtml')
-rw-r--r-- | tests/web/xhtml/buildfile | 8 | ||||
-rw-r--r-- | tests/web/xhtml/driver.cxx | 44 | ||||
-rw-r--r-- | tests/web/xhtml/test.out | 15 |
3 files changed, 67 insertions, 0 deletions
diff --git a/tests/web/xhtml/buildfile b/tests/web/xhtml/buildfile new file mode 100644 index 0000000..308a104 --- /dev/null +++ b/tests/web/xhtml/buildfile @@ -0,0 +1,8 @@ +# file : tests/web/xhtml/buildfile +# copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +import libs = libstudxml%lib{studxml} + +exe{driver}: cxx{driver} $libs +exe{driver}: test.output = test.out diff --git a/tests/web/xhtml/driver.cxx b/tests/web/xhtml/driver.cxx new file mode 100644 index 0000000..23531f7 --- /dev/null +++ b/tests/web/xhtml/driver.cxx @@ -0,0 +1,44 @@ +// file : tests/web/xhtml/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <iostream> + +#include <xml/serializer> + +#include <web/xhtml> + +using namespace std; +using namespace xml; + +int +main () +{ + using namespace web::xhtml; + + serializer s (cout, "output"); + + s << HTML + << HEAD + << TITLE << "Example XHTML5 document" << ~TITLE + << ~HEAD + << BODY + // + // Inline elements (no indentation). + // + << P << "Here be " << B << "Dragons!" << ~B << *BR + << "and a newline" << ~P + // + // Various ways to specify attributes. + // + << P(ID=123, CLASS="cool") << "Text" << ~P + << P << (ID=123) << (CLASS="cool") << "Text" << ~P + << P << ID(123) << CLASS("cool") << "Text" << ~P + << P << ID << 123 << ~ID << CLASS << "cool" << ~CLASS << "Text" << ~P + // + // Empty element with attributes. + // + << P << "Text" << *BR(CLASS="double") << ~P + << ~BODY + << ~HTML; +} diff --git a/tests/web/xhtml/test.out b/tests/web/xhtml/test.out new file mode 100644 index 0000000..ffa6df6 --- /dev/null +++ b/tests/web/xhtml/test.out @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="UTF-8"/> + <title>Example XHTML5 document</title> + </head> + <body> + <p>Here be <b>Dragons!</b><br/>and a newline</p> + <p id="123" class="cool">Text</p> + <p id="123" class="cool">Text</p> + <p id="123" class="cool">Text</p> + <p id="123" class="cool">Text</p> + <p>Text<br class="double"/></p> + </body> +</html> |