我有一本 fb2 格式的书。我想打印目录,其中包含“部分”、“章节”、“剧集”等的名称和编号。
有没有办法可以从终端执行此操作?有一个类似的问题,但对于 epub 格式。
我知道 fb2 是一种 xml 格式。但是有没有一种工具可以只提取TOC?它们在标签<section>
,<title>
和内<subtitle>
。
如果没有,我想可以根据官方的FB2_to_txt.xsl文件制作 xsl 文件。也许ebook-convert可以做到这一点?
我正在写的书具有以下结构:
<?xml version="1.0" encoding="utf8"?>
<FictionBook xmlns:l="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.gribuser.ru/xml/fictionbook/2.0">
<description>
<title-info>
<genre>fiction</genre>
<author>
<first-name>John</first-name>
<last-name>Doe</last-name>
</author>
<book-title>Fiction Book</book-title>
<annotation>
<p>Hello</p>
</annotation>
<keywords>john, doe, fiction</keywords>
<date value="2011-07-18">18.07.2011</date>
<coverpage></coverpage>
<lang>en</lang>
</title-info>
<document-info>
<author>
<first-name></first-name>
<last-name></last-name>
<nickname></nickname>
</author>
<program-used>Fb2 Gem</program-used>
<date value="2011-07-18">18.07.2011</date>
<src-url></src-url>
<src-ocr></src-ocr>
<id></id>
<version>1.0</version>
</document-info>
<publish-info>
</publish-info>
</description>
<body>
<title>
<p>John Doe</p>
<empty-line/>
<p>Fiction Book</p>
</title>
<section>
<title>
<p>Part 1</p>
<p>Some name of Part 1</p>
</title>
<section>
<title>
<p>Chapter 1</p>
<p>Some name of Chapter 1</p>
</title>
<subtitle>Episode 1</subtitle>
<p>Line one of the first episode</p>
<p>Line two of the first episode</p>
<p>Line three of the first episode</p>
<subtitle>Episode 2</subtitle>
<p>Line one of the second episode</p>
<p>Line two of the second episode</p>
<p>Line three of the second episode</p>
</section>
</section>
<section>
<title>
<p>Part 2</p>
<p>Some name of Part 2</p>
</title>
<section>
<title>
<p>Chapter 3</p>
<p>Some name of Chapter 3</p>
</title>
<subtitle>Episode 3</subtitle>
<p>Line one of the third episode</p>
<p>Line two of the third episode</p>
<p>Line three of the third episode</p>
<subtitle>Episode 4</subtitle>
<p>Line one of the fourth episode</p>
<p>Line two of the fourth episode</p>
<p>Line three of the fourth episode</p>
</section>
</section>
</body>
</FictionBook>
我想在输出中获得以下内容:
Part 1
Some name of Part 1
Chapter 1
Some name of Chapter 1
Episode 1
Episode 2
Part 2
Some name of Part 2
Chapter 3
Some name of Chapter 3
Episode 3
Episode 4