In the previous article, we discussed . Today, we decided to focus on the FictionBook2 format, better known as FB2, and its 'successor' FB3.
/ Flickr / /
The emergence of the format
In the mid-90s, enthusiasts digitizing Soviet books. They translated and preserved literature in a variety of formats. One of the first libraries on the Runet — — used a formatted text file (TXT).
The choice was made due to its resilience to byte corruption and universality — TXT can be opened on any operating system. However, it the processing of stored text information. For example, to access the thousandth line, one had to process the 999 lines preceding it. Books were also in Word documents and PDF — the latter was difficult to convert to other formats, and weak computers opened and PDF documents with delays.
HTML was also used for 'storing' electronic literature. It simplified indexing, converting to other formats, and creating documents (text markup with tags), but introduced its own drawbacks. One of the most significant was '» standard: it allowed for certain liberties in tag writing. Some of them had to be closed, while others (for example, <p>) — closing was not mandatory. The tags themselves could have an arbitrary nesting order.
. Although such work with files was discouraged — such documents were considered incorrect — the standard required readers to attempt to display the content. This is where difficulties arose, as each application implemented the 'guessing' process differently. At that time, the available devices and reading applications on the market one or two specialized formats. If a book existed in one format, it had to be reformatted to be read. To solve all these shortcomings was the task of , or FB2, which took on the primary 'tidying up' of text and conversion.
It is worth noting that the format had an earlier version — — which was only experimental, lasted a short time, is no longer supported, and has no backward compatibility. Therefore, FictionBook usually refers to its 'successor' — the FB2 format.
FB2 was created by a group of developers led by , who is the technical director of the company "LitRes," and Mikhail Matsnev, the creator of the Haali Reader. The format is based on XML, which is stricter than HTML and regulates the handling of unclosed and nested tags. An XML document is accompanied by what is known as an XML schema. An XML schema is a special file that contains all the tags and describes the rules for their application (sequence, nesting, mandatory and optional elements, etc.). In FictionBook, the schema is found in the file FictionBook2.xsd. You can find an example of an XML schema at (it is used by the eBook store "LitRes").
The structure of the FB2 document
Text in the document in special tags — elements of paragraph types: <p>, <v> and <subtitle>. There is also an element <empty-line>, which has no content and is used to insert gaps.
All documents start with the root tag <fictionbook>, under which other tags may appear <stylesheet>, <description>, <body> and <binary>.
The tag contains style sheets to facilitate conversion to other formats. The contains data encoded in that may be needed for rendering the document.
The element contains all the necessary information about the book: the genre of the work, a list of authors (full name, email address, and website), the title, a block with keywords, and a synopsis. It may also include information about the changes made to the document and details about the book's publisher, if it was published in print.
Here is what part of the block looks like in the FictionBook entry for "A Study in Scarlet" by Arthur Conan Doyle, taken from :
detective
Arthur
Conan
Doyle
A Study in Scarlet
1887
The key component of a FictionBook document is <body>. It directly contains the text of the book. There may be several of these tags throughout the document—additional blocks are used to store footnotes, comments, and annotations.
FictionBook also provides several tags for working with hyperlinks. They are based on the specification , developed by the consortium specifically for creating links between various resources in XML documents.
Advantages of the format
The FB2 standard includes only the minimally necessary set of tags (sufficient for 'formatting' fiction literature), which simplifies its processing by readers. Moreover, when a reader works directly with the FB format, the user can customize almost all display parameters.
The strict document structure allows for the automation of the conversion process from FB format to any other. This structure also enables working with individual document elements — setting filters by book authors, titles, genres, etc. For this reason, the FB2 format gained popularity in the Russian Internet, becoming the default standard in Russian electronic libraries and libraries in the CIS countries.
Disadvantages of the format
The simplicity of the FB2 format is both its strength and its weakness. This limits functionality for complex text formatting (for instance, side notes). It lacks vector graphics and support for numbered lists. For this reason, the format for textbooks, reference books, and technical literature (the very name of the format — fiction book, indicates 'fiction literature').
At the same time, to display minimal information about a book — title, author, and cover — the program needs to process almost the entire XML document. This is due to the fact that metadata are placed at the beginning of the text, while images are at the end.
FB3 — development of the format
In response to the increased formatting demands for book texts (and to mitigate some of the disadvantages of FB2), Gribov began working on the FB3 format. Later, the development stopped, but in 2014 it was .
According to the authors, they studied the actual needs in publishing technical literature, reviewed textbooks, reference books, and guides, and outlined a more specific set of tags that would allow for displaying any book.
In the new specification, the FictionBook format is a zip archive, where metadata, images, and text are stored as separate files. The requirements for the zip file format and the agreements on its organization are outlined in the standard , which defines Open XML.
A number of improvements have been made related to formatting (spacing, underlining), and a new object — the "block" — has been added, which formats a random fragment of a book as a rectangle and can be embedded in text with wrapping. Support for numbered and bulleted lists has also been introduced.
FB3 is distributed under a free license and has open code, making all utilities available to publishers and users: converters, cloud editors, readers. The current of the format, and can be found in the project repository on GitHub.
Overall, FictionBook3 is still less widespread than its older counterpart, but several e-libraries are already offering books in this format. A couple of years ago, "LitRes" announced plans to convert their entire catalog to this new format. Some readers already support all necessary FB3 functionality. For instance, all modern models of ONYX readers can work with this format "out of the box," such as or .

/
A broader adoption of FictionBook3 will allow for the formation of an ecosystem on a full and effective interaction with text on any device with limited resources: black and white or small display, low memory capacity, etc. According to the developers, a book typeset once will be maximally convenient in any environment.
P.S. We present to you some reviews of ONYX BOOX readers:
Source: habr.com
