Search:   Help

Developers' side bar

Selected categories


Shared groups



Categories: Development, LyX_2_1
<< | Page list | >>

Almost from the very beginning, there have been recurrent proposals to switch to an XML based format for LyX files. So far, no steps towards it have been made.

Table of contents (hide)

  1.   1.  Advantages and drawbacks
  2.   2.  Real world example
  3.   3.  Active questions
  4.   4.  Road to an XML format
  5.   5.  Testing tips
    1.   5.1  Command sequences
  6.   6.  Categories

1.  Advantages and drawbacks

Here are some key advantages of switching to an XML based format:

  • XML is an industry standard, while LyX's own format is not used outside the program.
  • There are many well tested tools to validate and manipulate XML
  • XML tags are more easily converted by something like Pandoc. At the time of writing, there doesn't seem to be a LyX parser for Pandoc, and this transition could help.
  • LyX's current format doesn't represent "encapsulation": we only know that an element is inside a section because the section title precedes it, and not because it's actually inside.

Here are some drawbacks:

  • Migration will take considerable effort and introduce many bugs. We would be back at square one(.5 maybe).
  • Theoretically doesn't break user space, because users need not even notice. But eventually something will break.

2.  Real world example

Here is a sample LyX document in the normal format

\lyxformat 620
\inputencoding utf8
\fontencoding auto
\spacing single
\use_hyperref false
\begin_layout Title
Example document
\begin_layout Standard
Here are some formulas
\begin_layout Section
Some formulas
\begin_layout Standard
\begin_inset Formula
Hello i'm a formula.

Here is a way it could look with XML:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document PUBLIC "-//LyX//DTD lyx//EN" "">
<param name="inputencoding">utf8</param>
<param name="fontencoding">auto</param>
<param name="spacing">single</param>
<param name="use_hyperref">false</param>
<layout type="Title">Example document</layout>
<layout type="Standard">Here are some formulas</layout>
<layout type="Section">Some formulas</layout>
<layout type="Standard"><inset type="Formula">Hello i'm a formula.</inset></layout>

3.  Active questions

Here are some questions we need to answer before:

  • <layout type="Standard">Hello</layout>
    <inset type="Formula">Hi</inset>
  • XML formats for documents already exist! Take a look here: Document file format. Out of them, the one that LyX can realistically use is DocBook. We can write a layer on top of the existing schema: Click me!(approve sites).
  • Why? What does this solve? [Author's own opinion here] In short, nothing. In the long run, however, it could help a lot. I have tried many (MANY!) document editors, and none come close to LyX in practicity, easiness to use, etc. It really is a marvel of an editor. However, LyX is tied to LaTeX. But times are a-changing, TeX is showing it's age (see typst), and more output formats are required. LyX can output to HTML and Docbook magnificently, but it's interface is very much tied to LaTeX. My question is: what if LyX was a general editor which outputted in a general format that a universal markup converter could translate to other formats? LyX could just output to that and have external converter do the conversion work. We would lose a lot of control, and probably it won't appeal anymore to a lot of the user base. Still, a question worth pondering... Is there a way to save the goat AND the cabbage?

4.  Road to an XML format

The first step should be to change the current format meta-characters \ to an intermediate format where the meta-characters are those of XML <&>

Some examples:

  • \lyxformat<lyxformat>
  • \backslask\
  • <, >, &&lt;, &gt;, &amp;

5.  Testing tips

5.1  Command sequences

  • Command that instructs LyX to open a file and save it under a different name. The file is deleted first to avoid a question about overwriting the output file.
    rm -f $fout
    lyx -x "command-sequence file-open $fin; buffer-write-as $fout; lyx-quit;"
    Note: An extra argument -lyxdir <path-to-lyxdir/lib> may be needed.

6.  Categories

Category: Development, LyX_2_1

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2024-03-29 16:57 UTC