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

Avoid breaking between text nodes #300

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Julow
Copy link
Contributor

@Julow Julow commented Feb 10, 2022

I've attempted a fix to #288 but it isn't working in every cases, for example this example is still problematic:

      p ~a:[ a_class [ "some padding ............................" ] ] [ 
        txt "some text here"; span [ txt ". and here" ]
      ]

There's an extra space before the . when indentation is enabled. Also happens in a more common example (in Odoc):

  <p>This is a <a href="#">link</a>
  .

I don't think this can be solved on the printer side without adding metadata to node definitions, for example whether it is a "block" or "inline" element (defined for HTML only). Would this be reasonable ?

An other idea is to implicitly add txt " " nodes at the end of every block elements, which the printer could detect and decide how to break.

Breaking between two text nodes might result in different HTML whether
indentation is enabled or not.
@Drup
Copy link
Member

Drup commented Jun 21, 2022

Sorry for the very late answer.

I don't like the solution of inserting txt " " at arbitrary points.

I think the solution is indeed to have a list of "elements where white space matters" and "elements where it does not", make the printer take those list as arguments, and define the list in the respective modules. What do you think about that ?

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

Successfully merging this pull request may close these issues.

2 participants