|
|
#1 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 63
Karma: 43710
Join Date: Jun 2008
Device: zaurus->palm->iPad->Sony PRS-T1,T2,T3->KoboForma&Likebook Ares->Palma2
|
modifying the TXT output format
Hi there,
I would like to slightly modify the TXT output format in the following way: I want to have '*' characters in front of each headline (that is H1 .. H6 in HTML) so that the number of star characters reflects the depth of the headline; e.g. H3 would turn into *** . I wonder how such a change could be made. Any help welcome! Ctop |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,620
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at the file txtml.py in the source code and change it to do what you need.
|
|
|
|
|
|
#3 |
|
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
In the txtml.py file look at line 170, # Are we in a paragraph block?. At the end of this block just check for the h tags and append the correct number of *s.
Though instead of making this very specific why not create a new txt output generator that produces markdown text? |
|
|
|
|
|
#4 | ||
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 63
Karma: 43710
Join Date: Jun 2008
Device: zaurus->palm->iPad->Sony PRS-T1,T2,T3->KoboForma&Likebook Ares->Palma2
|
Quote:
Quote:
Another question: I tried to add more markup, for example italic or bold. I see the settings in the CSS file and even in the intermediate versions I get with debug output, but when I try to work with the styles (for example 'font-style; italic;'), they seem at some point to be changed to 'font-style: normal;' and do not arrive at txtml.py. Could this be a bug? I looked around a bit, but could not find where this replacing happens. Just to check I looked at the RTF output, and there seems to be the italic missing as well. Any help appreciated, Ctop |
||
|
|
|
|
|
#5 | ||
|
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
Quote:
Supporting the MarkdownMLizer would be the easiest part. In the txt output.py file all you would need to do is add an option (--markdown-output for example) and in the convert function assign the writer variable to the MarkdownMLizer object. For example: Code:
def convert(self, oeb_book, output_path, input_plugin, opts, log):
if opts.markdown-output:
writer = MarkdownMLizer(log)
else:
writer = TXTMLizer(log)
txt = writer.extract_content(oeb_book, opts)
Quote:
|
||
|
|
|
|
|
#6 | ||
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 63
Karma: 43710
Join Date: Jun 2008
Device: zaurus->palm->iPad->Sony PRS-T1,T2,T3->KoboForma&Likebook Ares->Palma2
|
Quote:
Quote:
best, Ctop |
||
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I want to change output pdf format | miguel.ossa | Calibre | 7 | 09-06-2010 02:33 PM |
| Output Format Query | Splashfart | Calibre | 5 | 08-24-2010 12:32 AM |
| Multiple Format Output | jim6064 | Calibre | 4 | 03-10-2010 02:01 PM |
| Is it possible to specify output format in recipe file | madcow_x2 | Calibre | 3 | 01-07-2010 05:10 PM |
| output filename format | jdh | Calibre | 6 | 08-12-2009 10:35 PM |