From 63aaad529c9ae9358f22fd9563aeabc679f4defd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Aug 2015 18:28:53 +0200 Subject: Add support for generating XHTML5 --- tests/buildfile | 2 +- tests/web/buildfile | 7 +++++++ tests/web/xhtml/buildfile | 8 ++++++++ tests/web/xhtml/driver.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/web/xhtml/test.out | 15 +++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/web/buildfile create mode 100644 tests/web/xhtml/buildfile create mode 100644 tests/web/xhtml/driver.cxx create mode 100644 tests/web/xhtml/test.out (limited to 'tests') diff --git a/tests/buildfile b/tests/buildfile index 41a9bcc..ed48d00 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -2,6 +2,6 @@ # copyright : Copyright (c) 2014-2015 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -d = loader/ +d = loader/ web/ .: $d include $d diff --git a/tests/web/buildfile b/tests/web/buildfile new file mode 100644 index 0000000..0077eae --- /dev/null +++ b/tests/web/buildfile @@ -0,0 +1,7 @@ +# file : tests/web/buildfile +# copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +d = xhtml/ +.: $d +include $d 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 + +#include + +#include + +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 @@ + + + + + Example XHTML5 document + + +

Here be Dragons!
and a newline

+

Text

+

Text

+

Text

+

Text

+

Text

+ + -- cgit v1.1