Skip to content

Commit

Permalink
Merge pull request #218 from mrichards42/puzzle-tittle-message-html
Browse files Browse the repository at this point in the history
Strip html tags from completion dialog
  • Loading branch information
mrichards42 authored May 9, 2024
2 parents 085eca5 + eaa5226 commit 3345471
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,7 @@ MyFrame::ShowMetadata()
SetTitle(XWORD_APP_NAME);
else {
// Puzzle titles can contain HTML, so parse out the plain text.
PlainTextHtmlParser parser;
wxString title = * (wxString*) (parser.Parse(puz2wx(m_puz.GetTitle())));
wxString title = PlainTextHtmlParser::StripTags(puz2wx(m_puz.GetTitle()));
SetTitle(title + _T(" - ") XWORD_APP_NAME);
}

Expand Down Expand Up @@ -1095,8 +1094,10 @@ MyFrame::CheckPuzzle()
m_status->SetAlert(_T("The puzzle is filled correctly!"),
wxGetApp().GetConfigManager().Status.completeColor());
// Show completion message for acrostics since it is often the formatted quote.
if (m_puz.GetGrid().IsAcrostic() && m_puz.HasMeta(puzT("completion")))
XWordMessage(this, m_puz.GetMeta(puzT("completion")));
if (m_puz.GetGrid().IsAcrostic() && m_puz.HasMeta(puzT("completion"))) {
wxString message = PlainTextHtmlParser::StripTags(puz2wx(m_puz.GetMeta(puzT("completion"))));
XWordMessage(this, message);
}
break;
case UNCHECKABLE_PUZZLE:
StopTimer();
Expand Down
6 changes: 6 additions & 0 deletions src/html/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class PlainTextHtmlParser : public wxHtmlParser
return (wxObject*) &text;
}

static wxString StripTags (const wxString & input) {
PlainTextHtmlParser parser;
wxString text = * (wxString*) parser.Parse(input);
return text;
}

private:
wxString text;
};

0 comments on commit 3345471

Please sign in to comment.