1 //==- HTMLRewrite.h - Translate source code into prettified HTML ---*- C++ -*-//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a set of functions used for translating source code
11 // into beautified HTML.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
16 #define LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
18 #include "clang/Basic/SourceLocation.h"
29 /// HighlightRange - Highlight a range in the source code with the specified
30 /// start/end tags. B/E must be in the same file. This ensures that
31 /// start/end tags are placed at the start/end of each line if the range is
33 void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
34 const char *StartTag, const char *EndTag);
36 /// HighlightRange - Highlight a range in the source code with the specified
37 /// start/end tags. The Start/end of the range must be in the same file.
38 /// This ensures that start/end tags are placed at the start/end of each line
39 /// if the range is multiline.
40 inline void HighlightRange(Rewriter &R, SourceRange Range,
41 const char *StartTag, const char *EndTag) {
42 HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag);
45 /// HighlightRange - This is the same as the above method, but takes
46 /// decomposed file locations.
47 void HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
48 const char *BufferStart,
49 const char *StartTag, const char *EndTag);
51 /// EscapeText - HTMLize a specified file so that special characters are
52 /// are translated so that they are not interpreted as HTML tags.
53 void EscapeText(Rewriter& R, FileID FID,
54 bool EscapeSpaces = false, bool ReplaceTabs = false);
56 /// EscapeText - HTMLized the provided string so that special characters
57 /// in 's' are not interpreted as HTML tags. Unlike the version of
58 /// EscapeText that rewrites a file, this version by default replaces tabs
60 std::string EscapeText(StringRef s,
61 bool EscapeSpaces = false, bool ReplaceTabs = false);
63 void AddLineNumbers(Rewriter& R, FileID FID);
65 void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID,
68 /// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
69 /// information about keywords, comments, etc.
70 void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP);
72 /// HighlightMacros - This uses the macro table state from the end of the
73 /// file, to reexpand macros and insert (into the HTML) information about the
74 /// macro expansions. This won't be perfectly perfect, but it will be
76 void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP);
78 } // end html namespace
79 } // end clang namespace