Developers' side bar Selected categories Edit Links |
Devel /
LyXFileFormatReverseCategories: Category Development << | Page list | >>Notes on the LyX file format from the author of a lyx-to-xml converter. See also LyXFileFormat. General structureA .lyx-file consist of a header and a body. For a simple document, the body is a serie of paragraphs. #LyX 2.0 created this file. For more info see http://www.lyx.org/ \lyxformat 413 \begin_document \begin_header ... \end_header \begin_body \begin_layout Section Lorem ipsum... \end_layout \begin_layout Standard Lorem ipsum dolor sit amet, ... \end_layout \begin_layout Standard Duis autem vel eum iriure dolor in ... \end_layout \end_body \end_document ParagraphSee \n\begin_deeper (optionally)\n\end_deeper (optionally)\n\begin_layout name\n ...parameters... ...children... \n\end_layout\n
Parameters: something like Children: loop over them, with tracking of current column position. For each child:
TODO: insets writen directly: which ones? TODO: how code listings are not corrupted? InsetsEach type of an inset has its own serialization. Fortunately, they follow the common approach. name type \n options (without backslashes now) inset text Some options must present and be in specific order. For example, The wrapping Inset text is actually not character data, but an object of type Insets are always inside a paragraph. Character stylesMore precisely, insets of the type "Flex". The unused name of the paragraph style is So, the paragraph Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ...
is serialized as: \begin_layout Standard Lorem \begin_inset Flex Emph status collapsed \begin_layout Plain Layout ipsum dolor \end_layout \end_inset sit amet, consetetur sadipscing elitr, ... \end_layout Character escapingBackslash becomes Forced newline: \begin_inset Newline newline \end_inset LyX ignores newline, therefore something-to-lyx converter should handle it specially:
TODO LyX grammaticThere is no official grammar, but there is enough regularity to suggest our own. LYX := HEADER, BEGIN_DOCUMENT, DOCUMENT, END_DOCUMENT DOCUMENT := LAYOUT* LAYOUT := LAYOUT_BEGIN, LAYOUT_OPTION*, (CHARDATA | INSET)*, LAYOUT_END LAYOUT_BEGIN := \begin_layout LAYOUT_NAME Can contain spaces (special name "Plain Layout") LAYOUT_OPTION := OPTION_NAME OPTION_VALUE? OPTION_NAME := Name prefixed with slash. Should not be confused with character data '\backslash' ..... LAYOUT_END := \end_layout INSET := INSET_BEGIN, INSET_OPTION*, LAYOUT*, INSET_END INSET_BEGIN := \begin_inset INSET_NAME INSET_ANNOTATION* INSET_OPTION := OPTION_NAME OPTION_VALUE INSET_END := \end_inset TABULAR := angle-brackets-style Tables are different. Once again to note:
A LyX parser can be found here: http://github.com/olpa/tex, file "lyxml/lyxparser.py". TablesA table is stored with help of html-like chunk. \begin_inset Tabular <lyxtabular version="3" rows="2" columns="2"> <features tabularvalignment="middle"> <column alignment="center" valignment="top" width="0"> <column alignment="center" valignment="top" width="0"> <row> <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> \begin_inset Text \begin_layout Plain Layout r1c1 \end_layout \end_inset </cell> ... </row> ... </lyxtabular> \end_inset Elements The order of parameters-attributes is important. Each |