diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-19 06:14:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-19 06:14:37 +0000 |
commit | ad0a203130dc5d1fb7231b88767174511424fa98 (patch) | |
tree | 7e706b668bdf12cc38d43b54136fbbb1de86c6c8 /lib/Rewrite/HTMLRewrite.cpp | |
parent | 572cf09ae8a78af1c56d40b016ec4cf1837163ac (diff) |
Moved generation of html header/footer with builtin CSS to the rewriter library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/HTMLRewrite.cpp')
-rw-r--r-- | lib/Rewrite/HTMLRewrite.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index 9bd18109bb..9690ecb74a 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/lib/Rewrite/HTMLRewrite.cpp @@ -118,3 +118,47 @@ void html::AddLineNumbers(Rewriter& R, unsigned FileID) { R.InsertCStrAfter(SourceLocation::getFileLoc(FileID, FileEnd - FileBeg), "</div>"); } + +void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) { + + const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID); + const char* FileStart = Buf->getBufferStart(); + const char* FileEnd = Buf->getBufferEnd(); + + SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0); + SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart); + + // Generate header + + { + std::ostringstream os; + + os << "<html>\n<head>\n" + << " <style type=\"text/css\">\n" + << " .codeblock { width:100% }\n" + << " .codeline { font-family: \"Andale Mono\", fixed; font-size:10pt }\n" + << " .codeline { height:1.5em; line-height:1.5em }\n" + << " .nums, .lines { float:left; height:100% }\n" + << " .nums { background-color: #eeeeee }\n" + << " .nums { font-size:smaller }\n" + << " .nums { width:2.5em; padding-right:2ex; text-align:right }\n" + << " .lines { padding-left: 1ex; border-left: 3px solid #ccc }\n" + << " .lines { white-space: pre }\n" + << " </style>\n" + << "</head>\n" + << "<body>"; + + R.InsertStrBefore(StartLoc, os.str()); + } + + // Generate footer + + { + std::ostringstream os; + + os << "</body></html>\n"; + R.InsertStrAfter(EndLoc, os.str()); + } +} + + |