Skip to content

Add literals holding original text to ThematicBreak and HardLineBreak #295

Closed

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.

Activity

  1. added a commit that references this issue on Mar 12, 2024
    bd40c08
  2. robinst commented on Mar 12, 2024

    @robinst
    Collaborator

    Thanks, done for ThematicBreak. Can you create a separate issue for HardLineBreak please? I'm not sure what you mean by "The same issue exists with HardLineBreak where two or more line breaks are reduced to one HardLineBreak-element".

    On printing the original text that was parsed, have you seen this recently merged pull request?:

    (To be released in the next release soon.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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