diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h
index 8478c3f392..69dc4faccb 100644
--- a/include/wx/richtext/richtextbuffer.h
+++ b/include/wx/richtext/richtextbuffer.h
@@ -2090,6 +2090,10 @@ protected:
// Save images as inline base64 data in HTML handler
#define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
+// Don't write header and footer (or BODY), so we can include the fragment
+// in a larger document
+#define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
+
/*!
* wxRichTextFileHandler
* Base class for file handlers
diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp
index 965bbd4630..95ed0c1d4c 100644
--- a/src/richtext/richtexthtml.cpp
+++ b/src/richtext/richtexthtml.cpp
@@ -67,9 +67,10 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
wxTextAttrEx currentParaStyle = buffer->GetAttributes();
wxTextAttrEx currentCharStyle = buffer->GetAttributes();
- str << wxT("
\n");
+ if ((GetFlags() & wxRICHTEXT_HANDLER_NO_HEADER_FOOTER) == 0)
+ str << wxT("\n");
- str << wxT("");
+ str << wxT("\n");
str << wxString::Format(wxT(""),
currentParaStyle.GetFont().GetFaceName().c_str(), PtToSize(currentParaStyle.GetFont().GetPointSize()),
@@ -122,7 +123,12 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
node = node->GetNext();
}
- str << wxT(" | \n");
+ str << wxT(" |
");
+
+ if ((GetFlags() & wxRICHTEXT_HANDLER_NO_HEADER_FOOTER) == 0)
+ str << wxT("");
+
+ str << wxT("\n");
return true;
}
@@ -174,7 +180,7 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttrEx& current
}
else if( m_list )
{
- // The item is not bulleted and there is a list what should be closed now.
+ // The item is not bulleted and there is a list that should be closed now.
// So close the list
str << (m_is_ul ? wxT("") : wxT(""));