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

Change <summary> to use span content model instead of block #819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

otegami
Copy link

@otegami otegami commented Dec 11, 2024

This PR proposes changing the content model for <summary> back to inline, ensuring cleaner output and a more intuitive user experience.

In HTML5, the <summary> element can be treated as either block or inline (phrasing) content. Currently, it's set as a block element, which can lead to formatting issues in general usage scenarios like the following.

How to reproduce

Consider the following markdown file (summary.md).

<details>
<summary>Hello</summary>
World
</details>

When processed with bin/kramdown summary.md with
the --parse-block-html option.

$ bin/kramdown summary.md --parse-block-html
<h1 id="summary-test">Summary test</h1>

<details>
  <summary>
    <p>Hello&lt;/summary&gt;
World
&lt;/details&gt;</p>

  </summary>
</details>
Warning: Found no end tag for 'summary' (line 4) - auto-closing it
Warning: Found no end tag for 'details' (line 3) - auto-closing it
Warning: Found invalidly used HTML closing tag for 'summary' on line 4
Warning: Found invalidly used HTML closing tag for 'details' on line 6

Expected output

$ bin/kramdown summary.md --parse-block-html
<h1 id="summary-test">Summary test</h1>

<details>
  <summary>Hello</summary>
  <p>World</p>
</details>

Suggestion

By treating <summary> as an inline span element rather than a block element, we can align with the expected output and common usage patterns. This change is compliant with the HTML5 specification, which allows <summary> to be treated as inline content.

In HTML5, the `<summary>` element can be treated as either block or
inline (phrasing) content. Currently, it's set as a block element,
which can lead to formatting issues in general usage scenarios
like the following.

How to reproduce

Consider the following markdown file (summary.md).

```markdown

<details>
<summary>Hello</summary>
World
</details>
```

When processed with bin/kramdown summary.md with
the `--parse-block-html` option.

```console
$ bin/kramdown summary.md --parse-block-html
<h1 id="summary-test">Summary test</h1>

<details>
  <summary>
    <p>Hello&lt;/summary&gt;
World
&lt;/details&gt;</p>

  </summary>
</details>
Warning: Found no end tag for 'summary' (line 4) - auto-closing it
Warning: Found no end tag for 'details' (line 3) - auto-closing it
Warning: Found invalidly used HTML closing tag for 'summary' on line 4
Warning: Found invalidly used HTML closing tag for 'details' on line 6
```

Expected output

```console
$ bin/kramdown summary.md --parse-block-html
<h1 id="summary-test">Summary test</h1>

<details>
  <summary>Hello</summary>
  <p>World</p>
</details>
```

Suggestion

By treating `<summary>` as an inline span element rather than a
block element, we can align with the expected output and common
usage patterns. This change is compliant with the HTML5
specification, which allows `<summary>` to be treated as inline
content.

This PR proposes changing the content model for `<summary>` back
to inline, ensuring cleaner output and a more intuitive user
experience.
otegami added a commit to otegami/pgroonga.github.io that referenced this pull request Dec 12, 2024
This PR fixed the details summary layout because the kramdown's
parser regard the summary as a block and generates unpexpected
HTML layout like the following.

So we explicitly specified the summary is a inline block to solve
it. After gettalong/kramdown#819 is solved,
we can just add the parse-block-html option to handdle it.
kou pushed a commit to pgroonga/pgroonga.github.io that referenced this pull request Dec 17, 2024
This PR fixed the details summary layout because the kramdown's
parser regards the summary as a block and generates unexpected
HTML layout like the following.

So we explicitly specified the summary is a inline block to solve
it. After gettalong/kramdown#819 is solved,
we can just add the `parse-block-html` option to handle it.

|Before|After|
|---|---|
| ![Screenshot from 2024-12-12
09-09-21](https://github.com/user-attachments/assets/771496ad-1de4-4eb0-8d05-3d224f5a9f58)
| ![Screenshot from 2024-12-12
09-10-01](https://github.com/user-attachments/assets/3d97b8d6-5fb9-4567-b223-6c18eb070a83)
|

FYI: This PR doesn't add additional css to fix the layout of details and
summary.
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.

1 participant