1243791Sdim//==- HTMLRewrite.h - Translate source code into prettified HTML ---*- C++ -*-// 2243791Sdim// 3243791Sdim// The LLVM Compiler Infrastructure 4243791Sdim// 5243791Sdim// This file is distributed under the University of Illinois Open Source 6243791Sdim// License. See LICENSE.TXT for details. 7243791Sdim// 8243791Sdim//===----------------------------------------------------------------------===// 9243791Sdim// 10243791Sdim// This file defines a set of functions used for translating source code 11243791Sdim// into beautified HTML. 12243791Sdim// 13243791Sdim//===----------------------------------------------------------------------===// 14243791Sdim 15243791Sdim#ifndef LLVM_CLANG_HTMLREWRITER_H 16243791Sdim#define LLVM_CLANG_HTMLREWRITER_H 17243791Sdim 18243791Sdim#include "clang/Basic/SourceLocation.h" 19243791Sdim#include <string> 20243791Sdim 21243791Sdimnamespace clang { 22243791Sdim 23243791Sdimclass Rewriter; 24243791Sdimclass RewriteBuffer; 25243791Sdimclass Preprocessor; 26243791Sdim 27243791Sdimnamespace html { 28243791Sdim 29243791Sdim /// HighlightRange - Highlight a range in the source code with the specified 30243791Sdim /// start/end tags. B/E must be in the same file. This ensures that 31243791Sdim /// start/end tags are placed at the start/end of each line if the range is 32243791Sdim /// multiline. 33243791Sdim void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E, 34243791Sdim const char *StartTag, const char *EndTag); 35243791Sdim 36243791Sdim /// HighlightRange - Highlight a range in the source code with the specified 37243791Sdim /// start/end tags. The Start/end of the range must be in the same file. 38243791Sdim /// This ensures that start/end tags are placed at the start/end of each line 39243791Sdim /// if the range is multiline. 40243791Sdim inline void HighlightRange(Rewriter &R, SourceRange Range, 41243791Sdim const char *StartTag, const char *EndTag) { 42243791Sdim HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag); 43243791Sdim } 44243791Sdim 45243791Sdim /// HighlightRange - This is the same as the above method, but takes 46243791Sdim /// decomposed file locations. 47243791Sdim void HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E, 48243791Sdim const char *BufferStart, 49243791Sdim const char *StartTag, const char *EndTag); 50243791Sdim 51243791Sdim /// EscapeText - HTMLize a specified file so that special characters are 52243791Sdim /// are translated so that they are not interpreted as HTML tags. 53243791Sdim void EscapeText(Rewriter& R, FileID FID, 54243791Sdim bool EscapeSpaces = false, bool ReplaceTabs = false); 55243791Sdim 56243791Sdim /// EscapeText - HTMLized the provided string so that special characters 57243791Sdim /// in 's' are not interpreted as HTML tags. Unlike the version of 58243791Sdim /// EscapeText that rewrites a file, this version by default replaces tabs 59243791Sdim /// with spaces. 60263508Sdim std::string EscapeText(StringRef s, 61243791Sdim bool EscapeSpaces = false, bool ReplaceTabs = false); 62243791Sdim 63243791Sdim void AddLineNumbers(Rewriter& R, FileID FID); 64243791Sdim 65243791Sdim void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID, 66243791Sdim const char *title = NULL); 67243791Sdim 68243791Sdim /// SyntaxHighlight - Relex the specified FileID and annotate the HTML with 69243791Sdim /// information about keywords, comments, etc. 70243791Sdim void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP); 71243791Sdim 72243791Sdim /// HighlightMacros - This uses the macro table state from the end of the 73243791Sdim /// file, to reexpand macros and insert (into the HTML) information about the 74243791Sdim /// macro expansions. This won't be perfectly perfect, but it will be 75243791Sdim /// reasonably close. 76243791Sdim void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP); 77243791Sdim 78243791Sdim} // end html namespace 79243791Sdim} // end clang namespace 80243791Sdim 81243791Sdim#endif 82