Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 01-05-2012, 04:15 AM   #1
Snorkledorf
Blue. Not sad...just blue
Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.
 
Snorkledorf's Avatar
 
Posts: 218
Karma: 1267018
Join Date: Oct 2009
Location: Japan
Device: Ridibooks Paper Pro
Markdown: Anchor inconsistency on Kindle & Sony

This is less a calibre problem than just not knowing how to do this correctly.

I've been successfully using Markdown-formatted text to create Mobi files for my Kindle, but converting the same source into ePub for my new Sony T1 is giving me a little trouble. Specifically link anchors. People who know more than me, please help.

If I want to link to the beginning of a header, I've been doing this:

Code:
# Chapter 4
	
Blablabla...
	
<a name="anchorForChapter5"></a>

# Chapter 5

Blablabla...
On the Kindle this works because the Kindle displays the page so that the link is at the screen top, leaving the <h1> tag just below it. I know it's kind of faking it, and there really should be a page break at the <h1>, but on the Kindle it looks pretty much like a normal chapter would when jumped-to from the table of contents. I've been using this for e.g. endnotes.

But. The Sony seems to jump to links by going to the page that contains the link, and then just displaying that page as though I'd paged to it manually. So if a link happens to wind up at the bottom of the page, then so be it. Unfortunately for my method, that means that the Markdown source above takes us to the end of Chapter 4, with Chapter 5 hidden behind the next page break. Oops. Well that is indeed what I'm explicitly telling it to do (pesky computers, taking me literally ), but the Kindle was polite enough to pretend not to notice.

What would be a process to link directly to/near headers that would work on both machines?
Snorkledorf is offline   Reply With Quote
Old 01-05-2012, 04:26 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,546
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use explicit markup for chapter titles

<h1 id="anchorForChapter5">Chapter 5</h1>

Though you can just use the table of contents directive to have calibre autogenerate your toc in markdown documents.
kovidgoyal is offline   Reply With Quote
Advert
Old 01-05-2012, 08:36 AM   #3
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
Kovid's solution should work, or what about trying:

Code:
# Chapter 4
	
Blablabla...
	
# Chapter 5

<a name="anchorForChapter5"></a>

Blablabla...
So that the anchor is actually in chapter 5? This sort of anchor can be used more generally than just TOC entries.

If this skips the chapter header you could try:
Code:
# Chapter 4
	
Blablabla...
	
# <a name="anchorForChapter5"></a>Chapter 5

Blablabla...

I use calibre to convert markdown to ePub for a Sony reader and find that it does jump to the correct position of anchors within a page.

Last edited by Agama; 01-05-2012 at 02:50 PM. Reason: Typo
Agama is offline   Reply With Quote
Old 01-05-2012, 10:06 AM   #4
Snorkledorf
Blue. Not sad...just blue
Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.Snorkledorf ought to be getting tired of karma fortunes by now.
 
Snorkledorf's Avatar
 
Posts: 218
Karma: 1267018
Join Date: Oct 2009
Location: Japan
Device: Ridibooks Paper Pro
Okay it looks like embedding the anchor into the header is the way to go for cross-platform compatibility. Putting the link before the header makes the Sony display the previous section. Putting the link after the header makes the Kindle fail to display the header text.

I think I've got it now. Thanks for the help!


Here's my test Markdown code, for anybody who wants to see it for themselves:

Spoiler:
# Anchor-placement tests for Kindle & Sony Reader

&nbsp;

### Anchor precedes target header
> [Type 1](#type1) (Sony FAIL) (Kindle WIN)

&nbsp;

### Anchor follows target header
> [Type 2](#type2) (Sony WIN) (Kindle FAIL)

&nbsp;

### Anchor embedded in target header
> [Type 3](#type3) (Sony WIN) (Kindle WIN)

&nbsp;

### HTML ID embedded in target header
> [Type 4](#type4) (Sony WIN) (Kindle WIN)


# Type 1 Fail!

You shouldn't see this...

<a name="type1"></a>

# Type 1 Success!

This is the correct text...can you see the header too?






# Type 2 Fail!

You shouldn't see this...

# Type 2 Success!

<a name="type2"></a>

This is the correct text...can you see the header too?






# Type 3 Fail!

You shouldn't see this...

# <a name="type3"></a>Type 3 Success!

This is the correct text...can you see the header too?




# Type 4 Fail!

You shouldn't see this...

<h1 id="type4">Type 4 Success!</h1>

This is the correct text...can you see the header too?
Snorkledorf is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kindle & Sony Reader negerkuss_77 Amazon Kindle 3 12-27-2011 08:17 AM
Markdown conversion: line spacing & lists Snorkledorf Conversion 16 11-09-2011 07:51 AM
Bargain (Kindle/Nook/Sony/Kobo) Simon & Schuster Science Fiction & Fantasy $3.99 hemisphire Deals and Resources (No Self-Promotion or Affiliate Links) 1 10-14-2011 02:38 PM
Using calibre for Sony Pocket & Kindle grizedale Calibre 3 08-04-2010 03:00 PM
Kindle 1.2 update makes boat anchor scotty1024 Amazon Kindle 17 03-18-2009 12:34 AM


All times are GMT -4. The time now is 01:52 PM.


MobileRead.com is a privately owned, operated and funded community.