jxxcarlson/meenylatex/4.0.0

NOTE: the latest version is 15.2.0

MiniLatex.Differ

This module is used to speed up parsing-rendering by comparing the old and new lists of paragraphs, noting the changes, then parsing and rendering the changed paragraphs.

API

type alias EditRecord a =
{ paragraphs : List String
, renderedParagraphs : List a
, latexState : LatexState
, idList : List String
, newIdsStart : Maybe Int
, newIdsEnd : Maybe Int
}

An EditRecord records a list of (logical) newParagraphs correspoing to the text to be rendered as well as corresponding list of rendered parapgraphs. We need to reveiw this strucure.

emptyStringRecord : EditRecord String

An empty EditRecord -- like the integer 0 in another context.

emptyHtmlMsgRecord : EditRecord (Html msg)

An empty EditRecord -- like the integer 0 in another context. For renderers with Html a as target.

isEmpty : EditRecord a -> Bool

An EditRecord is considered to be empyt if its list of parapgraphs and its list of rendered paraagrahs is empty

createRecord : (String -> a) -> String -> EditRecord a

createRecord: Create an edit record by (1) breaking the text in to pargraphs, (2) applying the transformer to each string in the resulting list of strings.

diff : List String -> List String -> DiffRecord

Let u and v be two lists of strings. Write them as u = axb, v = ayb, where a is the greatest common prefix and b is the greatest common suffix. Return DiffRecord a b x y

prefixer : Int -> Int -> String

The prefixer is used to generate unique id's "p.1", "p.2", etc. for each paragraph.

update : Int -> (String -> a) -> EditRecord a -> String -> EditRecord a

The update function takes an EditRecord and a string, the "text", breaks the text into a list of logical paragraphs, diffs it with the list of paragraphs held by the EditRecord, uses differentialRender to render the changed paragraphs while copying the unchanged rendered paragraphsto prodduce an updated list of rendered paragraphs. The 'differentialRender' accomplishes this using the transformer. The seed is used to produces a differential idList. This last step is perhaps unnecessary. To investigate. (This was part of an optimization scheme.)