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
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* 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
|
||||
|
|
|
@ -23,6 +23,22 @@ HtmlTextStream::HtmlTextStream()
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
/*
|
||||
without escaping
|
||||
*/
|
||||
HtmlTextStream & PutChar(char);
|
||||
HtmlTextStream & PutChar(wchar_t);
|
||||
|
||||
HtmlTextStream & PutText(const char *);
|
||||
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_name", env_user_tab_name);
|
||||
ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
|
||||
ezc_functions.Insert("fil_csv_escape", fil_csv_escape);
|
||||
|
||||
|
||||
/*
|
||||
filters
|
||||
|
@ -249,6 +249,8 @@ void Templates::CreateFunctions()
|
|||
ezc_functions.Insert("fil_tosmall", fil_tosmall);
|
||||
ezc_functions.Insert("fil_firstup", fil_firstup);
|
||||
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_first_wordup(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)
|
||||
{
|
||||
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
|
||||
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
|
||||
|
@ -33,16 +33,10 @@
|
|||
|
||||
now you can use TexTextStream in an easy way:
|
||||
TexTextStream page;
|
||||
std::string key = "some <b>string</b>";
|
||||
page << key << R("<h2>html goes here</h2>");
|
||||
std::string key = "some text with $# ^{} tex \\ special characters";
|
||||
page << key << R("\\def\\myfun{...}");
|
||||
|
||||
// !! UPDATE INFO this is TEX text
|
||||
only html tags "<b>" and "</b>" will be correctly escaped
|
||||
|
||||
currently following characters are escaped:
|
||||
< -> <
|
||||
> -> >
|
||||
& ->
|
||||
everything in 'key' is property escaped for using with TeX
|
||||
*/
|
||||
class TexTextStream : public TextStream<std::wstring>
|
||||
{
|
||||
|
@ -70,6 +64,8 @@ public:
|
|||
/*
|
||||
without escaping
|
||||
*/
|
||||
TexTextStream & PutChar(char);
|
||||
TexTextStream & PutChar(wchar_t);
|
||||
|
||||
TexTextStream & PutText(const char *);
|
||||
TexTextStream & PutText(const char *, size_t len);
|
||||
|
|
Loading…
Reference in New Issue