lerzegov/elm-markup-fork/2.0.0

Formerly lerzegov/elm-markup. Search finds this package by either name.

Mark.Internal.Description

Document meta data
-> Parsed
(List Rendered)
{ errors : List Rendered
, result : ( meta, List data )
}
( meta, List data )

Render is a little odd.

We should always expect Parsed to either already have our error messages, or to succeed.

Render can't add additional errors.

Document meta data
-> String
-> Result
(List Rendered)
{ errors : List Rendered
, result : ( meta, List data )
}
( meta, List data )
)
(List Rendered)
{ errors : List Rendered
, result : ( meta, List data )
}
( meta, List data )
)
type Icon
= Bullet
| AutoNumber Int
= DescribeBlock
{ id : Id
, name : String
, found : Description
}
| Record
{ id : Id
, name : String
, found : List ( String, Description )
}
| Group
{ id : Id
, children : List Description
}
| StartsWith
{ id : Id
, first : Description
, second : Description
}
| DescribeItem
{ id : Id
, icon : Icon
, content : List Description
, children : List Description
}
| DescribeBoolean
{ id : Id
, found : Bool
}
| DescribeInteger
{ id : Id
, found : Int
}
| DescribeFloat
{ id : Id
, found : ( String, Float )
}
| DescribeText
{ id : Id
, text : List TextDescription
}
| DescribeString Id String
| DescribeUnexpected Id UnexpectedDetails
= Styled Text
| InlineBlock
{ kind : InlineSelection
, record : Description
}
type Text
= Text Styling String

A text fragment with some styling.

type Style
= Bold
| Italic
| Strike
= ExpectBlock String Expectation
| ExpectRecord String (List ( String, Expectation ))
| ExpectOneOf (List Expectation)
| ExpectManyOf (List Expectation)
| ExpectStartsWith Expectation Expectation
| ExpectBoolean Bool
| ExpectInteger Int
| ExpectFloat Float
| ExpectTextBlock (List InlineExpectation)
| ExpectString String
| ExpectTree Expectation
= ExpectText Text
| ExpectInlineBlock
{ name : String
, kind : InlineSelection
, fields : List ( String, Expectation )
}
type Parsed
= Parsed ParsedDetails
toString : Parsed -> String
(success -> a -> b)
-> Outcome failure (Uncertain success) success
-> Outcome c (Uncertain a) a
-> New
-> { desc : Description
, seed : Seed
}

This function does no validation, it only creates a new Description.

`
type alias Styling =
{ bold : Bool
, italic : Bool
, strike : Bool
}
emptyStyles : Styling
inlineExample : InlineSelection -> Block a -> Maybe String
blockName : Block data -> Maybe String
uncertain : UnexpectedDetails -> Outcome AstError (Uncertain data) data
type Uncertain data
= Uncertain ( UnexpectedDetails, List UnexpectedDetails )
| Recovered ( UnexpectedDetails, List UnexpectedDetails ) data

With this type, we're not quite sure if we're going to be able to render or not.

Scenarios:

  • A field value of a record has multiple errors with it.
  • It's caught and the error statue is rendered immediately.
  • The document can be rendered, but we still have multiple errors to keep track of.
(success -> otherSuccess)
-> BlockOutcome success
-> BlockOutcome otherSuccess
renderBlock : Block data -> Description -> BlockOutcome data
type Block data
= Block
{ kind : BlockKind
, converter : Description -> BlockOutcome data
, expect : Expectation
, parser :
-> Seed
}
A `Block data` is just a parser that results in `data`.

You'll be building up your Document in terms of the Blocks.

A block starts with | and has a name(already built into the parser)

A value is just a raw parser.

--- Error Propagation

Failure
    -> The document has had a mismatch
    -> This can only be recovered by `oneOf` or `manyOf`
Almost
    -> An `Error` has been "raised".  It's propogated until it's resolved by `onError`
    ->


Success
    -> Well, this is the easy one.


Ids are only available on the element they apply to.


Recovery is done at the level above the errored block.


So, if there is a record with a string that is constrained


If the constraint fails, the record can say "Here's the reset"
= Value
| Named String
| VerbatimNamed String
| AnnotationNamed String
type Document meta data
= Document
{ expect : Expectation
, metadata :
Parser Context Problem (Result UnexpectedDetails meta)
, parser : Parser Context Problem Parsed
, converter : Parsed -> BlockOutcome ( meta, List data )
}
boldStyle : Styling
italicStyle : Styling
strikeStyle : Styling
Range
-> { offset : Int
, line : Int
}
type Record data
= ProtoRecord
{ name : String
, blockKind : BlockKind
, expectations : List ( String, Expectation )
, fieldConverter :
-> BlockOutcome (FieldConverter data)
, fields : List FieldParser
}
type alias Range =
{ start : Position
, end : Position
}
recordName : Description -> Maybe String
= ParseBlock
| ParseInline
| ParseInTree

Is the first expectation a subset of the second?

type alias BlockOutcome data =
Outcome AstError (Uncertain (WithAttr data)) (WithAttr data)
= EmptyAnnotation
| SelectText (List Text)
| SelectString String
type New
= NewBlock String New
| NewRecord String (List ( String, New ))
| NewGroup (List New)
| NewStartsWith New New
| NewBoolean Bool
| NewInteger Int
| NewFloat Float
| NewTextBlock (List NewInline)
| NewString String
| NewItem Icon (List New)
= NewText Text
| NewInlineBlock
{ name : String
, kind : InlineSelection
, fields : List ( String, New )
}
type alias ParsedDetails =
{ errors : List Rendered
, found : Description
, expected : Expectation
, initialSeed : Seed
, currentSeed : Seed
, attributes : List Attribute
}
-> List New
-> { new : List Description
, seed : Seed
}

NOTE, this returns items in reversed order!

{ start :
{ offset : number
, line : number
, column : number
}
, end :
{ offset : number
, line : number
, column : number
}
}

Subtle destinction between this and find.

This will NOT reconstruct the full hierarchy, but return the exact blocks asked for.

This also won't verify that all ids in the document were found, it'll just return the stuff it finds.

-> List (Block a)
-> Outcome AstError (Uncertain (WithAttr a)) (WithAttr a)
-> Document meta block
-> Parsed
-> Outcome (List Rendered) (Partial block) block

In order for block lookups to work and for the block to be renderable, we need to retrieve a block, but keep the general structure.

So, if we have ManyOf [ One,Two ], and our ID matches Two, we need to return ManyOf [Two], not just Two.

Then our rendering function will still work.

(List one -> List two -> final)
-> ListOutcome one
-> ListOutcome two
-> BlockOutcome final
(one -> two -> final)
-> BlockOutcome one
-> BlockOutcome two
-> BlockOutcome final

mergeWithAttrs

minusPosition : Position -> Position -> Position
valid : New -> Expectation -> Bool