X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9bb9964e261781d575353864cc027b3ca8ba445e..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/common/markupparser.cpp diff --git a/src/common/markupparser.cpp b/src/common/markupparser.cpp index 535e62bade..d9dcf452c7 100644 --- a/src/common/markupparser.cpp +++ b/src/common/markupparser.cpp @@ -23,8 +23,11 @@ #pragma hdrstop #endif +#if wxUSE_MARKUP + #ifndef WX_PRECOMP -#endif // WX_PRECOMP + #include "wx/log.h" +#endif #include "wx/private/markupparser.h" @@ -425,3 +428,53 @@ wxString wxMarkupParser::Quote(const wxString& text) return quoted; } + +/* static */ +wxString wxMarkupParser::Strip(const wxString& text) +{ + class StripOutput : public wxMarkupParserOutput + { + public: + StripOutput() { } + + const wxString& GetText() const { return m_text; } + + virtual void OnText(const wxString& text) { m_text += text; } + + virtual void OnBoldStart() { } + virtual void OnBoldEnd() { } + + virtual void OnItalicStart() { } + virtual void OnItalicEnd() { } + + virtual void OnUnderlinedStart() { } + virtual void OnUnderlinedEnd() { } + + virtual void OnStrikethroughStart() { } + virtual void OnStrikethroughEnd() { } + + virtual void OnBigStart() { } + virtual void OnBigEnd() { } + + virtual void OnSmallStart() { } + virtual void OnSmallEnd() { } + + virtual void OnTeletypeStart() { } + virtual void OnTeletypeEnd() { } + + virtual void OnSpanStart(const wxMarkupSpanAttributes& WXUNUSED(a)) { } + virtual void OnSpanEnd(const wxMarkupSpanAttributes& WXUNUSED(a)) { } + + private: + wxString m_text; + }; + + StripOutput output; + wxMarkupParser parser(output); + if ( !parser.Parse(text) ) + return wxString(); + + return output.GetText(); +} + +#endif // wxUSE_MARKUP