ocsigen / ocsigen/tyxml

Indentation option might add an extra space

Open
#288 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
179
Forks
63
Avg merge
5h
Merged PRs (30d)
22

Description

The following code renders differently in the browser whether the indent option is enabled or not:

  <p>
   <span class="some padding ............................">some text here
    . and here
   </span>
  </p>

A line break is inserted between the two txt nodes. The extra breaks inside the p elements also change what C-A, C-C copies into the clipboard.

open Tyxml.Html

let content =
  html
    (head (title (txt "example")) [])
    (body
       [
         p
           [
             span
               ~a:[ a_class [ "some padding ............................" ] ]
               [ txt "some text here"; txt ". and here" ];
           ];
       ])

let () =
  Format.printf "%a" (pp ~indent:true ()) content

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pp ~indent:true () entry point shown in the OCaml example and reproduce the rendered HTML in a browser with indentation enabled and disabled. Trace how adjacent txt nodes in the span and p elements are formatted; the fix is done when indentation no longer changes visible spacing, line breaks, or copied clipboard content.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.