// Purpose: Implementation of wxMarkupParser.
// Author: Vadim Zeitlin
// Created: 2011-02-16
-// RCS-ID: $Id: $
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#pragma hdrstop
#endif
+#if wxUSE_MARKUP
+
#ifndef WX_PRECOMP
-#endif // WX_PRECOMP
+ #include "wx/log.h"
+#endif
#include "wx/private/markupparser.h"
else // Must be a CSS-like size specification
{
int cssSize = 1;
- wxString rest;
if ( value.StartsWith("xx-", &rest) )
cssSize = 3;
else if ( value.StartsWith("x-", &rest) )
current.clear();
}
+ // This variable is used only in the debugging messages
+ // and doesn't need to be defined if they're not compiled
+ // at all (it actually would result in unused variable
+ // messages in this case).
+#if wxUSE_LOG_DEBUG || !defined(HAVE_VARIADIC_MACROS)
// Remember the tag starting position for the error
// messages.
const size_t pos = it - text.begin();
-
+#endif
bool start = true;
if ( ++it != end && *it == '/' )
{
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