Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip html tags from completion dialog #218

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};