jxxcarlson / math-markdown / MMDiffer

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.


type alias EditRecord a =
{ paragraphs : List String
, renderedParagraphs : List a
, idList : List String 
}

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.

createRecord : (String -> Html a) -> String -> EditRecord (Html 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.

update : Basics.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.)