Skip to content

Trailing spaces in string blocks are ignored even in Mark.New.string #40

Description

@tad-lispy

When parsing a string block like this:

|> Title
    There are spaces here ->  

the trailing spaces will be ignored. In most cases it makes sense - probably the whitespace is there by mistake. The problem is that when creating a new block programmatically with Mark.New the trimming is also applied. This makes incremental updates to string block difficult.

Say I have a text input that on change replaces the text block:

setTitle : Mark.Edit.Id -> String -> Mark.Parsed -> Result (List Error) Mark.Parsed
setTitle id value ast =
    let
        block =
            Mark.New.string value

        edit =
            Mark.Edit.replace id block
    in
    Mark.update document edit ast

This works great except when a user tries to insert a space at the end of the field with intention of adding another word after it. Then the space simply does not get added.

It seems to me that trimming should be applied when parsing, but not when blocks are created with Mark.New.string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions