01-25-2011, 07:55 AM | #1 |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
Markdown Syntax in Comments
I am seeing cases where the Comments field retrieved by Calibre is in what looks like Markdown Syntax (for a simple example look at "Off the Mangrove Coast" by Louis L'Amour). When Calibre adds this comment it appears that it is being enclosed in a <div> and <p> tag to support rich Text Editing in the GUI comments field. I am trying to produce a web page incorporating this comment field, and the presence of the HTML tags stops markdown processing from operating on the field to give a better formatted comment.
It seems to me I that there are several options available
Of the options I have listed, the most effective to me seems the last one of converting to HTML at the point the Markdown hits Calibre. If that is what others think I will look at raising an appropriate ticket for an enhancement request. I can then look at whether I can work out the Calibre patch to go with the request, but first I thought I would solicit advice on the best way to proceed. |
01-25-2011, 08:18 AM | #2 |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
You might want to go to the metadata download plugin, customize the Amazon plugin and check the box Convert comments downloaded from Amazon to plain text.
|
Advert | |
|
01-25-2011, 08:31 AM | #3 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
The metadata downloading code has been through a lot of flux lately. Markdown was used to cleanse html comments, and then the comments are supposed to be converted back to html. I think there must be a bug where it's not getting converted back to html. But other bugs have been fixed - for a while any text that was also an href was getting deleted, that at least seems to be resolved.
|
01-25-2011, 08:35 AM | #4 |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
|
01-25-2011, 08:36 AM | #5 | |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
Quote:
|
|
Advert | |
|
01-25-2011, 08:41 AM | #6 | |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Quote:
That said - if you have the preference to convert Amazon comments to plain text maybe that's why it's markdown syntax now - if you disable that checkbox and re-download the metadata does it convert the markdown back to html? |
|
01-25-2011, 08:49 AM | #7 |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
If I change the Amazon plugin to not convert to plain text then the immediate problem disappears as I end up with HTML rather than Markdown formatted comments. However, I think there is a bug there as if a comment is meant to be plain text then it should be stored as that - not as plain text with an HTML wrapper that stops Markdown processing from being possible?
|
01-25-2011, 09:01 AM | #8 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Actually maybe the problem is on your web page/script side then - markdown is supposed to allow html tags anywhere in the middle of the text. I took advantage of this pretty heavily with a markdown book I was editing. Is it actually the markdown interpreter bailing out when it sees a tag, or is it whatever function you have passing the comments over to markdown that's the problem?
|
01-25-2011, 09:09 AM | #9 | |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
Quote:
Interestingly enough - I notice the markdown spec says that text inside <SPAN> tags is subject to markdown processing. Last edited by itimpi; 01-25-2011 at 09:14 AM. |
|
01-25-2011, 09:16 AM | #10 | |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Quote:
|
|
01-25-2011, 09:19 AM | #11 | |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Quote:
Span tags don't surprise me - very much an inline element. |
|
01-25-2011, 11:28 AM | #12 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
comments are migrated to html irrespective of their download source. They are stored as html in the database. You're going to have to workaround that in your script. The HTML used is typically very simple, so it should be trivial to have a function that strips it. calibre uses the html2text python library for that, You cna use it in your own script with
calibre-debug -c |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Markdown to ePub : Optimize internal filesizes | Agama | Calibre | 1 | 01-22-2011 09:36 AM |
Slowness converting markdown book from the GUI in 7.38 | ldolse | Calibre | 4 | 01-09-2011 10:21 PM |
->Txt+Markdown | Perkin | Calibre | 2 | 12-11-2010 04:04 AM |
Capture intermediate html from markdown | Agama | Calibre | 3 | 07-30-2010 11:33 AM |
Markdown editor | user_none | Workshop | 0 | 08-30-2009 09:25 PM |