mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-21 12:19:03 +03:00
Fix the indexing of the fromMarkdown fragments
This commit is contained in:
parent
777fbba780
commit
3d33ce400b
@ -21,6 +21,7 @@ just a single whitespace.
|
||||
- remove initFragment, splitHighlightableOnWords, splitWords
|
||||
- remove toggle, which is not used
|
||||
- rename groupIndex -> index
|
||||
- ensure that fromMarkdown indexes the fragments correctly
|
||||
|
||||
|
||||
## Types
|
||||
@ -330,6 +331,7 @@ fromMarkdown markdownString =
|
||||
)
|
||||
( Nothing, [] )
|
||||
|> Tuple.second
|
||||
|> List.indexedMap (\i highlightable -> { highlightable | index = i })
|
||||
|
||||
|
||||
{-| -}
|
||||
|
@ -126,8 +126,16 @@ fromMarkdownSpec =
|
||||
let
|
||||
testFromMarkdown startingString expected =
|
||||
Highlightable.fromMarkdown startingString
|
||||
|> List.map (\{ text, marked } -> ( text, marked ))
|
||||
|> Expect.equal expected
|
||||
|> Expect.all
|
||||
[ -- the right words are marked
|
||||
List.map (\{ text, marked } -> ( text, marked ))
|
||||
>> Expect.equal expected
|
||||
, -- the indexing is correct
|
||||
\highlightables ->
|
||||
Expect.equal
|
||||
(List.indexedMap (\index _ -> index) highlightables)
|
||||
(List.map (\{ index } -> index) highlightables)
|
||||
]
|
||||
|
||||
defaultMark =
|
||||
Tool.buildMarker
|
||||
|
Loading…
Reference in New Issue
Block a user