Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add literals holding original text to ThematicBreak and HardLineBreak #295

Closed
Jeyhey opened this issue Jul 12, 2023 · 2 comments · Fixed by #309
Closed

Add literals holding original text to ThematicBreak and HardLineBreak #295

Jeyhey opened this issue Jul 12, 2023 · 2 comments · Fixed by #309

Comments

@Jeyhey
Copy link

Jeyhey commented Jul 12, 2023

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.

@robinst
Copy link
Collaborator

robinst commented Mar 12, 2024

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.)

@robinst
Copy link
Collaborator

robinst commented Mar 15, 2024

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

Successfully merging a pull request may close this issue.

2 participants