1080linebooks / sigil

Automatically exported from code.google.com/p/sigil
GNU General Public License v3.0
0 stars 0 forks source link

Find and replace -- "All html documents" not working #470

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open the attached .epub file
2. Search for "<p xmlns:xml="http://www.w3.org/XML/1998/namespace" class="pn" 
xml:lang="en-us">(.+)</p>"
3. replace with: <h2>\1</h2>
4. select "minimal matching", "regular expression", "all", and "all html files"
5. open Chapter10.xhtml in WYSIWYG mode
6. click "find next" and "replace all".
7. switch to Code View
8. click "find next" and "replace"
9. open Chapter11.xhtml in WYSIWYG mode.
10. click "find next" and "replace".
11. switch to code view
12. click "find next" and "replace".

What is the expected output? 
step 6: All instances in document replaced
step 8: single instance found in chapter 10 and replaced, and next instance 
found
step 10: single instance found in chapter 11 and replaced, and next intance 
found
step 12: single instance found in chapter 11 and replaced

What do you see instead?
Step 6: not found in document
step 8: first instance found and replaced.  second instance not found
step 10: first instance in chapter not found in document
step 12: first instance found and replaced, but next instance not found.

What version of the product are you using?
Sigil 0.2.3

On what operating system?
Windows 7

Please provide any additional information below. If your source file
(SGF/EPUB/HTML/etc) is required to fully understand the problem, please
attach it to this issue. Read the ReportingIssues wiki page before
submitting!

Original issue reported on code.google.com by BridgeBl...@gmail.com on 23 Jun 2010 at 7:51

Attachments:

GoogleCodeExporter commented 9 years ago
Step 6: 

Not found in document.

Searching across HTML files works only in Code View. If you open the Find 
dialog in BV and choose "All HTML Files", you will get a warning. You 
circumvented that warning by opening the dialog in CV, selecting "All HTML 
Files" and then switching back to BV.

It's a loophole I intend to fix. Thanks for spotting it.

Step 8:

The second instance is not found.

This is a *very* specific bug. The problem is that the XHTML file is internally 
stored in a QDomDocument which when converted back into text, reorders the 
attributes (which it shouldn't do). This makes the match fail. See the related 
bugs on Nokia's bugtracker:

http://bugreports.qt.nokia.com/browse/QTBUG-5364
http://bugreports.qt.nokia.com/browse/QTBUG-8158

I'm already fed up with QDom, and plan to replace it with Xerces-C++. That is 
issue 367, and this bug will be fixed when that is implemented.

You can work around this problem by changing your search term to this:
<p[^>]*class="pn"[^>]*>(.+)</p>

Step 10:
You can't search for HTML code in the Book View. You can only search for the 
rendered, shown text. This is by design.

Step 12:
Same as step 8.

I intent to fix the step 6 problem now, and step 8 will be fixed when 
Xerces-C++ replaces QDomDocument.

Original comment by Strahinja.Markovic@gmail.com on 25 Jun 2010 at 1:08

GoogleCodeExporter commented 9 years ago
WRT step 8: Xerces reorders the attributes just like QDom. So you'll have to 
make sure your searches don't depend on the order of the attributes (which 
shouldn't be difficult).

There's nothing I can do. 

Original comment by Strahinja.Markovic@gmail.com on 12 Sep 2010 at 4:11