JetBrains / markdown

Markdown parser written in kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for cancellation of the parsing process

FirstTimeInForever opened this issue · comments

Sometimes it is needed to cancel the currently running parsing process (e.g. if the input was updated and the parsing result would be immediately outdated). Typing in some editor can be considered an example of such a case.

To achieve this, we can provide an instance of CancellationToken to the parser:

fun interface CancellationToken {
    fun checkCancelled()
}

The parser can then call checkCancelled in relevant places (loops/ast construction/html generation/...) to abort its execution if needed.