Skip to content

[Suggestion]: Allow all unclosed inline markups #53

@boltlessengineer

Description

@boltlessengineer

Norg spec's Layer 1 is for use-cases like general messaging apps.

And for messaging apps, it's really weird to have "syntax error" on message text.
v1 spec tried fallback to punctuations in most cases when any inline markups are incomplete or invalid.

But that made parser implementation really difficult.
Instead, I'm suggesting to make every incomplete markups valid and never throw syntax error on paragraph level.

Example

*unclosed bold is valid bold
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bold

*last /markup should _close/ first.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bold
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ italic
                     ^^^^^^^^^^^^^^ underline
                           ^ punctuation (not italic closing modifier)

[unclosed link is also valid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ anchor for "unclosed link is also valid"

We are still forcing user to close last markup like #34 suggested.
But we are allowing all incomplete markups as valid instead.

Implementation

Parser can automatically close any markups with zero-width token when it encounters paragraph break (or any other tokens that make paragraph end.)
This is fairly easy in tree-sitter parser too. Why v3 couldn't do this before was because I tried to make /*bold/ not bold not /*bold/ still italic&bold.

Pros

More suitable for layer 1 use-cases

As I mentioned above, it is extremely weird to have syntax error in simple messaging app.

Better editor UX

In mobile applications, user might use keyboard toolbar buttons to toggle markups instead of manually inserting special characters.
If they turn on "bold" button, app should insert bold closing modifier like auto-pair to make it valid bold forcing user to move the cursor when they want to end the bold text. But moving cursor in mobile applications is quite hard.

If we allow unclosed markups, the editor UX feels more like WYSIWYG editor. When user turns on "bold" button, every following text will be bold unless user turns off "bold". If user wants to end the bold text, they can simply turns off the "bold" from keyboard toolbar. No need to manually move the cursor.

Edge-cases

Only edge-case I can think of right now is \. When norg content ends with \ character without EOL or EOF.
Though I think this edge-case is rare enough to just ignore on parsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions