THRIFT-2824 Flag to disable html escaping doctext
Client: HTML
Patch: Craig Peterson
This closes #266
commit 0df9592deb6dce477600f923745d6cdb113592ae
Author: Craig Peterson <cpeterson@ancestry.com>
Date: 2014-11-14T19:12:49Z
adding flag to allow unescaped html in doectexts
diff --git a/compiler/cpp/src/generate/t_html_generator.cc b/compiler/cpp/src/generate/t_html_generator.cc
index b8dfa2a..a79ed50 100644
--- a/compiler/cpp/src/generate/t_html_generator.cc
+++ b/compiler/cpp/src/generate/t_html_generator.cc
@@ -64,6 +64,10 @@
iter = parsed_options.find("standalone");
standalone_ = (iter != parsed_options.end());
+ iter = parsed_options.find("noescape");
+ unsafe_ = (iter != parsed_options.end());
+
+
escape_.clear();
escape_['&'] = "&";
escape_['<'] = "<";
@@ -112,6 +116,7 @@
input_type input_type_;
std::map<std::string, int> allowed_markup;
bool standalone_;
+ bool unsafe_;
};
@@ -399,7 +404,11 @@
*/
void t_html_generator::print_doc(t_doc* tdoc) {
if (tdoc->has_doc()) {
- f_out_ << escape_html(tdoc->get_doc()) << "<br/>";
+ if (unsafe_) {
+ f_out_ << tdoc->get_doc() << "<br/>";
+ } else {
+ f_out_ << escape_html(tdoc->get_doc()) << "<br/>";
+ }
}
}
@@ -1079,4 +1088,5 @@
THRIFT_REGISTER_GENERATOR(html, "HTML",
" standalone: Self-contained mode, includes all CSS in the HTML files.\n"
" Generates no style.css file, but HTML files will be larger.\n"
+" noescape: Do not escape html in doc text.\n"
)