You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am developing an editor for my markup documents. Perhaps I'm doing something wrong here, but the error message is not helping me understand. Here it is:
DOCUMENT DOESN'T ALLOW
You tried to insert a
|> Card
but the block at the provided Mark.Edit.Id is expecting
|> Card
Here is the code that generates the edit:
addCard:Mark.Edit.Id->Mark.Parsed->Result (ListError) Mark.ParsedaddCard id ast =let
block =Mark.New.record "Card"[("front",Mark.New.string "Card front content"),("back",Mark.New.string "Card back content"),("options",Mark.New.many [])]|>Debug.log "Card to be inserted"
edit =Mark.Edit.insertAt id 0 block
|>Debug.log "Edit"inDeck.update edit ast
and document definition (plus Editable a and update helpers):
document:Documentdocument =Mark.documentWith Deck{ metadata = deckBlock
, body = cardBlocks
}deckBlock:Mark.Block (EditableString)
deckBlock =Mark.string
|>Mark.withId Editable|>Mark.block "Deck" identity
cardBlocks:Mark.Block (Editable (ListCard))
cardBlocks =[ cardBlock ]|>Mark.manyOf
|>Mark.withId EditablecardBlock:Mark.BlockCardcardBlock =Mark.record "Card"Card|>Mark.field "front"Mark.string
|>Mark.field "back"Mark.string
|>Mark.field "options" optionsBlock
|>Mark.toBlock
optionsBlock:Mark.Block (ListOption)
optionsBlock =Mark.manyOf [ optionBlock ]optionBlock:Mark.BlockOptionoptionBlock =Mark.record "Option"Option|>Mark.field "value"Mark.string
|>Mark.field "correct"Mark.bool
|>Mark.field "hint"Mark.string
|>Mark.toBlock
type alias Editable a ={ id :Mark.Edit.Id, value : a
}update:Edit->Mark.Parsed->Result (ListMark.Error.Error) Mark.Parsedupdate edit ast =Mark.Edit.update document edit ast
I can try to recreate a minimal example on Ellie if you think that will help.
The text was updated successfully, but these errors were encountered:
tad-lispy
added a commit
to tad-lispy/elm-markup
that referenced
this issue
Jul 16, 2020
The bug is described in
mdgriffith#42, but I would not
consider it a fix as it does not address the error message helpfullness.
The problem is that in `ExpectManyOf` case of
`Mark.Internal.Description.matchExpected` . There are two variables
there:
- `oneOptions` `twoOptions`
In case of updates `oneOptions` will be a list of all valid options. The
`twoOptions` will be blocks that are actually inserted.
We want to check if all inserted blocks match any of the valid options.
But it was the other way around - the test was "all valid options are
inserted". Coincidentally when there is only one valid option and at
least one block is inserted, the result is the same. That's probably why
the problem remained undetected for relatively long time. I ran into it
becasue my list was nested in a record (as described in the linked
issue) and was initially empty.
I am developing an editor for my markup documents. Perhaps I'm doing something wrong here, but the error message is not helping me understand. Here it is:
Here is the code that generates the edit:
and document definition (plus
Editable a
andupdate
helpers):I can try to recreate a minimal example on Ellie if you think that will help.
The text was updated successfully, but these errors were encountered: