lg_noteutilities

Name

lg_noteutilities -- Utilties for dealing with notes

Synopsis


package require lg_noteutilities
      

makeNoteImageList text

validateImageFiles images

makeNoteMarkdown noteDict

_noteToFd id fd

DESCRIPTION

This package provides some utilities that support high level note processing. The package was written to support the note composition software, howver it may be used generally as well.

COMMANDS

makeNoteImageList text

Creating a note requries that the images referenced by the notes be included in the database to support later rendering. makeNoteImageList takes the raw text of a note, locates image references and creates a list of pairs, one for each image reference. The pairs are the the byte offset at which the image reference occurs in the text and the filename of the image itself.

validateImageFiles images

Given a list of pairs such as that produced by makeNoteImageList, ensures that each of the filenames in the image list exists and is readable. Returns a list of strings, where each string is an unreadable image file. For a note to be imported, all image file references must point to files that exist and are readable so they can be imported into the database.

Note that no effort is made to ensure that the files are, in fact, valid image files. If a reference to an image file is invalid, the markdown generated will be invalid but some renderers, such as the PDF renderer may not be able to create output.

makeNoteMarkdown noteDict

When the logbook software generates the note for rendering, in addition to exporting images and fixing up their references it prepends a table of metatdata about the note, including the author's name, when the note wsas written and, if the note is associated with a run, the run number, title and when the run started and, if the run ended, when the run ended.

This command takes a note dict and performs the processing described above. The resulting markdown texts is the return value of this command.

_noteToFd id fd

Given a note who's primary key is id, and an open file descriptor fd, Creates the full markdown text (what makeNoteMarkdown) creates, and outputs it to fd. This is used internally to the logbook browser software to e.g. pipe fully formed markdown to the pandoc markdown processor.