01-23-2018, 11:45 PM | #1 |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
comments deleted from OPF?
I had a line in the OPF of an epub3 that kicked an epubcheck error. Not knowing how to fix it, I wondered if I could just hide it, so I commented it out with HTML comments <!-- ... -->
And it seemed fine and validated. Then I saved the file and the line disappeared without notice. I wanted to keep the line so I could return to puzzling it out. Is there a way to hide lines in the OPF that will not mark them for deletion? |
01-24-2018, 08:45 AM | #2 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
No, by design the opf is kept in a parsed state so that file splitting, merging, new files added, files removed, can done, etc. There is no structure in the opf parser that supports keeping free form comments as they could be placed anywhere.
If you really need to keep something stored in the opf, you could hide it as an additional dc:description metadata field or your own custom metadata. If so, do not forget to xml escape it. |
Advert | |
|
01-24-2018, 10:36 PM | #3 |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
OK; and explains why saving always prettifies the OPF.
But it was disconcerting to have comments, that are apparently legal and valid, be silently deleted and now lost for good. I thought that just saving a file was entirely safe. In other cases, if I go to save a file with invalid code, Sigil either won't let me or warns me that it will "fix" it and there may be "data loss". So if you can't preserve comments, a warning to that effect would be appreciated. |
01-24-2018, 11:24 PM | #4 |
Obsessively Dedicated...
Posts: 3,200
Karma: 34977896
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
@AlanHK -- It seems you can have comments in the *manifest* section, I see them all the time in Gutenberg books. But apparently not in the Metadata section.
Last edited by GrannyGrump; 01-24-2018 at 11:30 PM. |
01-25-2018, 02:36 AM | #5 | |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
Anyway, Sigil deletes comments in the Manifest too. Does it when you open them so unless you crack the epub with another tool, you'll never know. One I just got at random (https://www.gutenberg.org/ebooks/56410) originally had this: Code:
<manifest> <!--Image: 530 x 800 size=113823 --> <item media-type="image/jpeg" href="@public@vhost@g@gutenberg@html@files@56410@56410-h@images@cover.jpg" id="item1"/> Code:
<manifest> <item id="item1" href="Images/%40public%40vhost%40g%40gutenberg%40html%40files%4056410%4056410-h%40images%40cover.jpg" media-type="image/jpeg"/> Last edited by AlanHK; 01-25-2018 at 02:58 AM. |
|
Advert | |
|
01-25-2018, 03:39 AM | #6 |
Obsessively Dedicated...
Posts: 3,200
Karma: 34977896
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
@Alan --- hm, interesting. I just did a quick Gutenberg download, checked for comments, yes there they were. I even copied one into the metadata section.
Settings are PrettyPrint on save. I saved the book, re-opened, and all comments are still there. But this is Sigil version 0.8.6, which is probably why we see different results. |
01-25-2018, 04:04 AM | #7 | |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
It deletes comments anywhere in the opf on opening or saving, regardless. Last edited by AlanHK; 01-25-2018 at 04:06 AM. |
|
01-25-2018, 04:33 AM | #8 |
Connoisseur
Posts: 57
Karma: 600000
Join Date: Jan 2018
Device: Galaxy Tab S2
|
Granny,
i guess if you do not do any changes Sigil will not regenerate the opf file as long as it is not necessary. Would be of interest if you apply a change which affects the opf file like renaming a file or adding a semantic. M |
01-25-2018, 08:17 AM | #9 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
That is true. That said comments are legal in xml but do not provide functionality. Pieces of the opf should not be commented out to hide them for later given the opf must be completely parseable inside Sigil at all times. Simply copy that text to the clipboard and access it via the cliphistory when and if desired. This is the way Sigil has worked since Tidy was removed. The opf is kept as it was designed to be, as machine readable.
|
01-25-2018, 08:18 AM | #10 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
No, it will only delete comments when first parsed inside Sigil
|
01-25-2018, 09:49 AM | #11 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
If it would help ... I could collect comments when the opf is parsed that are located anyplace in the opf and create a new pre-parsed data structure that holds all comments together in one place.
Then when rebuilding the opf on the fly after a change, I could insert all comments in the order they were found but all relocated to be either just before the metadata section or just before the manifest section or something along those lines. In other words create a space in the rebuilt opf for all comments that once existed someplace before parsing and rebuilding. |
02-15-2018, 01:43 PM | #12 | |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
But have a warning/advice stating that comments have been moved; or deleted if that still happens. |
|
02-15-2018, 01:53 PM | #13 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
There will be no warning. The content.opf is meant to always be machine parseable and machine generated inside Sigil.
|
02-15-2018, 02:04 PM | #14 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Agreed. We're not popping warnings for moved or deleted comments in the OPF.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Comments in content.opf with Sigil 0.9.2 | turbulent | Sigil | 4 | 02-15-2016 05:29 PM |
Deleting folders without OPF vs recreating OPF files | wladdy | Library Management | 8 | 03-13-2015 05:50 AM |
Change opf filename from content.opf to title.opf | northstar7 | Sigil | 3 | 09-23-2013 12:44 PM |
TWO OPF files or something like Media Queries in the OPF file for KF8 and MOBI? | DHahn | Kindle Formats | 3 | 04-17-2012 04:06 AM |
Can I cut and paste the Calibre opf into the ePub opf? | wannabee | ePub | 0 | 07-12-2011 02:09 AM |