Closed GoogleCodeExporter closed 9 years ago
Changing Misc/SearchOperations SearchOperations::ReplaceHTMLInFile so the if
statement is the following skips saving the bad files and leaves the text. But
we should show a dialog to warn the user that some files were skipped.
if ( search_type == SearchOperations::CodeViewSearch )
{
const QString &text = CleanSource::PrettyPrint(
XhtmlDoc::GetDomDocumentAsString( html_resource->GetDomDocumentForReading() ) );
QString new_text;
int count = 0;
tie( new_text, count ) = PerformGlobalReplace( text, search_regex, replacement );
// Check if the document is well-formed before saving it
QString cleaned_new_text = CleanSource::ToValidXHTML( new_text );
XhtmlDoc::WellFormedError error = XhtmlDoc::WellFormedErrorForSource( cleaned_new_text );
bool well_formed = error.line == -1;
if ( well_formed )
{
XhtmlDoc::LoadTextIntoDocument( cleaned_new_text );
html_resource->SetDomDocument( XhtmlDoc::LoadTextIntoDocument( cleaned_new_text ) );
}
return count;
}
Original comment by meme90...@gmail.com
on 1 Feb 2012 at 7:53
Showing a message about the issue is not feasible. I think it's worse to have
replacements not made vs auto clean loosing data. EIther way the user will not
get what they expect but if a replacement is not made then the user will be
confused and think that Sigil is broken. They will then probably try the
replacement a few more times and get frustrated.
Replace in all files is a blind replacement. The user is at the mercy of what
happens.
The real fix is not to auto clean and have data removed. I plan on making this
change as part of 0.6.
Original comment by john@nachtimwald.com
on 2 Feb 2012 at 12:43
Original comment by daveheil...@gmail.com
on 19 May 2012 at 3:20
Original issue reported on code.google.com by
meme90...@gmail.com
on 1 Feb 2012 at 7:21