Support superscripts and subscripts. Fixes #157.

This commit is contained in:
Kovid Goyal 2007-08-14 16:33:18 +00:00
parent 40d13ecac5
commit 0128e3bb01
2 changed files with 10 additions and 3 deletions

View File

@ -35,7 +35,7 @@ from libprs500.ebooks.BeautifulSoup import BeautifulSoup, Comment, Tag, \
from libprs500.ebooks.lrf.pylrs.pylrs import Paragraph, CR, Italic, ImageStream, \ from libprs500.ebooks.lrf.pylrs.pylrs import Paragraph, CR, Italic, ImageStream, \
TextBlock, ImageBlock, JumpButton, CharButton, \ TextBlock, ImageBlock, JumpButton, CharButton, \
Plot, Image, BlockSpace, RuledLine, BookSetting, Canvas, DropCaps, \ Plot, Image, BlockSpace, RuledLine, BookSetting, Canvas, DropCaps, \
LrsError LrsError, Sup, Sub
from libprs500.ebooks.lrf.pylrs.pylrs import Span as _Span from libprs500.ebooks.lrf.pylrs.pylrs import Span as _Span
from libprs500.ebooks.lrf import Book from libprs500.ebooks.lrf import Book
from libprs500.ebooks.lrf import option_parser as lrf_option_parser from libprs500.ebooks.lrf import option_parser as lrf_option_parser
@ -1182,6 +1182,11 @@ class HTMLConverter(object):
self.current_para = Paragraph() self.current_para = Paragraph()
self.current_block = self.book.create_text_block(textStyle=pb.textStyle, self.current_block = self.book.create_text_block(textStyle=pb.textStyle,
blockStyle=pb.blockStyle) blockStyle=pb.blockStyle)
elif tagname in ['sub', 'sup']:
text = self.get_text(tag)
elem = Sub if tagname == 'sub' else Sup
self.current_para.append(elem(text))
elif tagname in ['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']: elif tagname in ['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']:
if tag.has_key('id'): if tag.has_key('id'):
target = self.book.create_text_block(textStyle=self.current_block.textStyle, target = self.book.create_text_block(textStyle=self.current_block.textStyle,

View File

@ -104,6 +104,7 @@
<p> <p>
A simple <i>paragraph</i> of <b>formatted A simple <i>paragraph</i> of <b>formatted
<i>text</i></b>, with a ruled line following it. <i>text</i></b>, with a ruled line following it.
Super<sup>scripts</sup> and Sub<sub>scripts</sub>.
</p> </p>
<hr/> <hr/>
<p> A <p> A
@ -122,7 +123,8 @@
<hr/> <hr/>
<p style='text-indent:30em'>A very indented paragraph</p> <p style='text-indent:30em'>A very indented paragraph</p>
<p style='text-indent:0em'>An unindented paragraph</p> <p style='text-indent:0em'>An unindented paragraph</p>
<p>A default indented paragrpah<br /></p> <p>A default indented paragrpah</p>
<hr/>
<p class='toc'> <p class='toc'>
<hr /> <hr />
<a href='#toc'>Table of Contents</a> <a href='#toc'>Table of Contents</a>