added: new ezc filter: fil_new_line_to_br
added: PutChar() methods to HtmlTextFilter and TexTextFilter git-svn-id: svn://ttmath.org/publicrep/winix/trunk@885 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
d8260d8383
commit
14ae19143f
|
@ -2,7 +2,7 @@
|
||||||
* This file is a part of Winix
|
* This file is a part of Winix
|
||||||
* and is not publicly distributed
|
* and is not publicly distributed
|
||||||
*
|
*
|
||||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -136,4 +136,21 @@ void fil_csv_escape(Info & i)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void fil_new_line_to_br(Info & i)
|
||||||
|
{
|
||||||
|
const std::wstring & str = i.in.Str();
|
||||||
|
|
||||||
|
for(size_t a=0 ; a<str.size() ; ++a)
|
||||||
|
{
|
||||||
|
if( str[a] == '\n' )
|
||||||
|
i.out << R("<br>\n");
|
||||||
|
else
|
||||||
|
i.out << R(str[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -23,6 +23,22 @@ HtmlTextStream::HtmlTextStream()
|
||||||
without escaping
|
without escaping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
HtmlTextStream & HtmlTextStream::PutChar(char c)
|
||||||
|
{
|
||||||
|
TextStream<std::wstring>::operator<<(c);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HtmlTextStream & HtmlTextStream::PutChar(wchar_t c)
|
||||||
|
{
|
||||||
|
TextStream<std::wstring>::operator<<(c);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HtmlTextStream & HtmlTextStream::PutText(const char * str)
|
HtmlTextStream & HtmlTextStream::PutText(const char * str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
/*
|
/*
|
||||||
without escaping
|
without escaping
|
||||||
*/
|
*/
|
||||||
|
HtmlTextStream & PutChar(char);
|
||||||
|
HtmlTextStream & PutChar(wchar_t);
|
||||||
|
|
||||||
HtmlTextStream & PutText(const char *);
|
HtmlTextStream & PutText(const char *);
|
||||||
HtmlTextStream & PutText(const char *, size_t len);
|
HtmlTextStream & PutText(const char *, size_t len);
|
||||||
|
|
|
@ -238,7 +238,7 @@ void Templates::CreateFunctions()
|
||||||
ezc_functions.Insert("env_user_tab_id", env_user_tab_id);
|
ezc_functions.Insert("env_user_tab_id", env_user_tab_id);
|
||||||
ezc_functions.Insert("env_user_tab_name", env_user_tab_name);
|
ezc_functions.Insert("env_user_tab_name", env_user_tab_name);
|
||||||
ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
|
ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
|
||||||
ezc_functions.Insert("fil_csv_escape", fil_csv_escape);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
filters
|
filters
|
||||||
|
@ -249,6 +249,8 @@ void Templates::CreateFunctions()
|
||||||
ezc_functions.Insert("fil_tosmall", fil_tosmall);
|
ezc_functions.Insert("fil_tosmall", fil_tosmall);
|
||||||
ezc_functions.Insert("fil_firstup", fil_firstup);
|
ezc_functions.Insert("fil_firstup", fil_firstup);
|
||||||
ezc_functions.Insert("fil_first_wordup", fil_first_wordup);
|
ezc_functions.Insert("fil_first_wordup", fil_first_wordup);
|
||||||
|
ezc_functions.Insert("fil_csv_escape", fil_csv_escape);
|
||||||
|
ezc_functions.Insert("fil_new_line_to_br", fil_new_line_to_br);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -180,6 +180,7 @@ namespace TemplatesFunctions
|
||||||
void fil_firstup(Info & i);
|
void fil_firstup(Info & i);
|
||||||
void fil_first_wordup(Info & i);
|
void fil_first_wordup(Info & i);
|
||||||
void fil_csv_escape(Info & i);
|
void fil_csv_escape(Info & i);
|
||||||
|
void fil_new_line_to_br(Info & i);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,22 @@ TexTextStream::TexTextStream()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
TexTextStream & TexTextStream::PutChar(char c)
|
||||||
|
{
|
||||||
|
TextStream<std::wstring>::operator<<(c);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TexTextStream & TexTextStream::PutChar(wchar_t c)
|
||||||
|
{
|
||||||
|
TextStream<std::wstring>::operator<<(c);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TexTextStream & TexTextStream::PutText(const char * str)
|
TexTextStream & TexTextStream::PutText(const char * str)
|
||||||
{
|
{
|
||||||
TextStream<std::wstring>::operator<<(str);
|
TextStream<std::wstring>::operator<<(str);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TexTextStream is used as a buffer for creating a html page
|
TexTextStream is used as a buffer for creating a TeX input
|
||||||
By default all operators<< escape its string arguments. If you don't want
|
By default all operators<< escape its string arguments. If you don't want
|
||||||
to escape an argument you should use a helper function R() (raw argument)
|
to escape an argument you should use a helper function R() (raw argument)
|
||||||
note: you have to define the function yourself, we do not provide it
|
note: you have to define the function yourself, we do not provide it
|
||||||
|
@ -33,16 +33,10 @@
|
||||||
|
|
||||||
now you can use TexTextStream in an easy way:
|
now you can use TexTextStream in an easy way:
|
||||||
TexTextStream page;
|
TexTextStream page;
|
||||||
std::string key = "some <b>string</b>";
|
std::string key = "some text with $# ^{} tex \\ special characters";
|
||||||
page << key << R("<h2>html goes here</h2>");
|
page << key << R("\\def\\myfun{...}");
|
||||||
|
|
||||||
// !! UPDATE INFO this is TEX text
|
everything in 'key' is property escaped for using with TeX
|
||||||
only html tags "<b>" and "</b>" will be correctly escaped
|
|
||||||
|
|
||||||
currently following characters are escaped:
|
|
||||||
< -> <
|
|
||||||
> -> >
|
|
||||||
& ->
|
|
||||||
*/
|
*/
|
||||||
class TexTextStream : public TextStream<std::wstring>
|
class TexTextStream : public TextStream<std::wstring>
|
||||||
{
|
{
|
||||||
|
@ -70,6 +64,8 @@ public:
|
||||||
/*
|
/*
|
||||||
without escaping
|
without escaping
|
||||||
*/
|
*/
|
||||||
|
TexTextStream & PutChar(char);
|
||||||
|
TexTextStream & PutChar(wchar_t);
|
||||||
|
|
||||||
TexTextStream & PutText(const char *);
|
TexTextStream & PutText(const char *);
|
||||||
TexTextStream & PutText(const char *, size_t len);
|
TexTextStream & PutText(const char *, size_t len);
|
||||||
|
|
Loading…
Reference in New Issue