Skip to content

Add literals holding original text to ThematicBreak and HardLineBreak #295

@Jeyhey

Description

@Jeyhey

Currently it is not possible to know which text was parsed to ThematicBreak. Was it --- or was it *** ? This information is lost when parsing mark up text in this library.

In order to enable the user of the library to differentiate, it would be useful to keep the text literal in a variable of ThematicBreak. So one could do (in Kotlin)

// prints the original text that was parsed
fun print(node: Node): String {
    return when (node) {
        is ThematicBreak -> node.literal
        ...
    }
}

The same issue exists with HardLineBreak where two or more line breaks are reduced to one HardLineBreak-element. Adding a literal variable would enable to reconstruct the original text that was parsed and one could check how many line breaks the text originally had.

More generally, this feature request goes into the direction of enabling a bijection between the text and its parsed representation. I am not sure if a full bijection makes sense, but for the two node types of ThematicBreak and HardLineBreak it definitely does.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions