LMA-tiedostoformaatti

Tällä sivulla dokumentoidaan L'Mathin käyttämä LMA-tiedostoformaatti.


  Nörttivaroitus!
Tämän sivun sisältö on kiinnostavaa luultavasti vain kehittäjille, kokeilijoille ja propellipäille, jotka haluavat tietää enemmän L'Mathin teknisestä toteutuksesta. Samasta syystä sivun sisältö on saatavilla vain englanniksi.

This specification-ish is mainly written because of the open source lmafix tool. If a file of yours is broken, you may attempt fixing it with the user interface of the tool.

Format versions

LMA1 is the original JSON-based version. Even the newer L'Math versions should be able to open them, but they are not officially supported anymore. Images and formulas are stored inline in the html, as base64 encoded strings.

LMA2 is the new ZIP-based version, where individual pages and metadata are stored as JSON, and images are stored as image files, and formulas stored as TeX renderer URLs.

  • "LMA1" (legacy)
    • File extension: .lma
    • Inner structure: UTF-8 encoded JSON data
  • "LMA2" (current)
    • File extension: .lma
    • Inner structure: ZIP deflated, see below for details

LMA2 structure (r1.10-r1.10.15)

An LMA2 file is a zip file, containing the following files and folders.

  • images/
    • Contains required images in PNG or JPEG format
    • File name of an image file is its corresponding image id
    • No file name extension is used
    • Example: File called image_123_321 is loaded in the editor as limg://image_123_321
  • pages/ (required)
    • Contains individual page files formatted as JSON containing objects (see below for details)
    • File names follow the format <page_id>.json
    • Example: File called page_123_321.json is loaded in the editor with the page id page_123_321
  • pages.json (required)
    • Contains the page ids encoded as a JSON object
    • The order of ids defines the order of pages in the editor page list
    • Example: ["page_aabbccdd_0000111122223333","page_asdf3210_9999888877776666"]
  • worksheet.json (required)
    • Contains metadata about the worksheet, encoded as JSON, with following keys:
      • latestVersion (string) - App version used in last save
      • created (YYYY-mm-ddTHH:MM:SS.xxxx) - Timestamp of worksheet initialization
      • theme (optional, either "light" or "dark")
      • color (optional, one of ...) - Notebook icon color
      • currentPageId (optional, string) - ID of the page that was last opened
    • Some legacy keys that are no longer actively used or supported:
      • title (string) - Worksheet title (legacy)
      • description (string) - Worksheet description (legacy)
      • author (string) - Author name (legacy)
      • protected (optional, boolean) - Legacy. Not used anywhere anymore.
      • password (optional, string) - Legacy. Not used anywhere anymore.
      • bookmarks (Bookmark[], optional) - List of bookmarks
        • Bookmark is an object with keys "id", "title", "pageId" and "timestamp"
      • deletedBookmarks (string[], optional) - List of deleted bookmark IDs
  • pagemeta.json (optional)
    • Contains only the metadata of pages, as a JSON array of objects (see below for details)
    • The page metadata format is the same as in a page JSON file, except there is no "content" field
    • This file is not required, and it is currently not used in the editor. In the future, page content and metadata could be separated, however, current versions read the metadata from the page files themselves.

Notes on the ZIP format...

  • Passwords or encryption are not supported.
  • All text-based files should be UTF-8 encoded.
  • The app itself uses level 9 compression on text files, and level 0 compression on image files; however, other implementations should work as well.

Page JSON structure

An individual page file located in pages/ named with the corresponding id (i.e. <page_id>.json) contains a JSON object in the following format:

  • id (string) - Page id. Must be the same as in the page name.
  • type ("textAnswer" | "richSlide" | "codeEditor", optional) - The content type of this page. If undefined, "textAnswer" is assumed. Currently, "richSlide" is under development and has no implementation, and "codeEditor" means a Python programming page.
  • title (string) - Page title, shown in the page list and PDF exports
  • icon (string, optional) - Page icon, if any. Any icon id from Feather.
  • hilight ("red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "magenta", optional) - Page highlight color, if any.
  • requiredImages (string[], optional) - An array of image IDs used on the page
  • length (number) - Length of page content
  • drawings (Record<string, string>, optional) - Drawing data of drawings on the page, indexed by their ID
  • content (string, undefined if meta only) - The page content. If type is "textAnswer", this is pure HTML. If type is "codeEditor", this contains a stringified JSON representation of the code, outputs, and errors.

Changes to LMA2

(To be written. LMA2 files from new L'Math versions will not work properly in older L'Math versions.)