diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-19 01:30:02 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-19 01:30:02 +0000 |
commit | f830997de6ca8aa9526a9f4bb44593c19040ca85 (patch) | |
tree | 72e222942cee969e3b1ea08bbab85a3f1c8073f2 /Driver/HTMLPrint.cpp | |
parent | 1b3188cfc2bfaeb14d40c43c1df62097b79016d1 (diff) |
More cleanups to HTML rewriter API: remove the InsertTag method; was too complicated
and clients can achieve a cleaner design just by inserting tags directly. Reserve
the "html" namespace for meta-level operations (e.g., escaping text, etc.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/HTMLPrint.cpp')
-rw-r--r-- | Driver/HTMLPrint.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Driver/HTMLPrint.cpp b/Driver/HTMLPrint.cpp index 6c8a1d1aad..acb011c216 100644 --- a/Driver/HTMLPrint.cpp +++ b/Driver/HTMLPrint.cpp @@ -50,22 +50,32 @@ HTMLPrinter::~HTMLPrinter() { html::EscapeText(R, FileID); html::AddLineNumbers(R, FileID); - html::InsertOuterTag(R, html::PRE, StartLoc, EndLoc, 0, 0, true); - html::InsertOuterTag(R, html::BODY, StartLoc, EndLoc, NULL, "\n", true); - // Generate CSS. + // Generate header + + { + std::ostringstream os; - std::ostringstream css; - css << "\n <style type=\"text/css\">\n"; - css << " .nums, .lines { vertical-align:top }\n"; - css << " .nums { padding-right:.5em; width:2.5em }\n"; - css << " </style>\n"; + os << "<html>\n<head>\n" + << " <style type=\"text/css\">\n" + << " .nums, .lines { vertical-align:top }\n" + << " .nums { padding-right:.5em; width:2.5em }\n" + << " </style>\n" + << "</head>\n" + << "<body>\n<pre>"; + R.InsertTextBefore(StartLoc, os.str().c_str(), os.str().size()); + } - // Add <head> and <html> tags. + // Generate footer - html::InsertTagBefore(R, html::HEAD, StartLoc, StartLoc, 0,css.str().c_str()); - html::InsertOuterTag(R, html::HTML, StartLoc, EndLoc, 0, "\n"); + { + std::ostringstream os; + + os << "</pre>\n</body></html>\n"; + R.InsertTextAfter(EndLoc, os.str().c_str(), os.str().size()); + } + // Emit the HTML. |