diff --git a/src/apps/haiku-depot/textview/MarkupParser.cpp b/src/apps/haiku-depot/textview/MarkupParser.cpp index 8102cdf047..ecf8e9d3d2 100644 --- a/src/apps/haiku-depot/textview/MarkupParser.cpp +++ b/src/apps/haiku-depot/textview/MarkupParser.cpp @@ -64,9 +64,20 @@ MarkupParser::SetStyles(const CharacterStyle& characterStyle, TextDocumentRef MarkupParser::CreateDocumentFromMarkup(const BString& text) { - fTextDocument.SetTo(new(std::nothrow) TextDocument(), true); - if (fTextDocument.Get() == NULL) - return fTextDocument; + TextDocumentRef document(new(std::nothrow) TextDocument(), true); + if (document.Get() == NULL) + return document; + + AppendMarkup(document, text); + + return document; +} + + +void +MarkupParser::AppendMarkup(const TextDocumentRef& document, const BString& text) +{ + fTextDocument.SetTo(document); fCurrentCharacterStyle = &fNormalStyle; fCurrentParagraphStyle = &fParagraphStyle; @@ -76,7 +87,7 @@ MarkupParser::CreateDocumentFromMarkup(const BString& text) _ParseText(text); - return fTextDocument; + fTextDocument.Unset(); } diff --git a/src/apps/haiku-depot/textview/MarkupParser.h b/src/apps/haiku-depot/textview/MarkupParser.h index 6a630bc51f..39b3d0401e 100644 --- a/src/apps/haiku-depot/textview/MarkupParser.h +++ b/src/apps/haiku-depot/textview/MarkupParser.h @@ -19,7 +19,14 @@ public: const CharacterStyle& characterStyle, const ParagraphStyle& paragraphStyle); + const CharacterStyle& HeadingCharacterStyle() const + { return fHeadingStyle; } + const ParagraphStyle& HeadingParagraphStyle() const + { return fHeadingParagraphStyle; } + TextDocumentRef CreateDocumentFromMarkup(const BString& text); + void AppendMarkup(const TextDocumentRef& document, + const BString& text); private: void _InitStyles();