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

Blank line in highlighted code #12364

Open
3 tasks done
PassionPenguin opened this issue Dec 23, 2024 · 7 comments
Open
3 tasks done

Blank line in highlighted code #12364

PassionPenguin opened this issue Dec 23, 2024 · 7 comments
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@PassionPenguin
Copy link
Contributor

PassionPenguin commented Dec 23, 2024

Summary

formatted code with many lines defined with raw <pre class="brush: json"> and a blank line following it will have a blank line at the very beginning

Note

Just a glance, there are 133 occurences that are alike and have problems (blank line at the beginning of the code)


Note

i'm not sure if this is caused by the format of the document's <pre> code, or is caused by yari? This is caused by yari and rari's addition of <code> (see discussion below)

### URL

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action#choosing_icon_sizes

Reproduction steps

image

Expected behavior

Without line-breaking

Actual behavior

image
image

Device

Desktop

Browser

Chrome

Browser version

Stable

Operating system

Windows

Screenshot

No response

Anything else?

No response

Validations

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Dec 23, 2024
@yin1999
Copy link
Member

yin1999 commented Dec 24, 2024

The rendered HTML looks good to me. Did you check the row html content of this document (that is, download the document using wget/curl). I can see there is no such an empty line in this <pre> element.

image

@PassionPenguin
Copy link
Contributor Author

PassionPenguin commented Dec 24, 2024

The rendered HTML looks good to me. Did you check the row html content of this document (that is, download the document using wget/curl). I can see there is no such an empty line in this \<pre\> element.

image

not this line. check line 24 or line 171, where <code>'s content starts with \n

@PassionPenguin
Copy link
Contributor Author

the problem may be resolved simply by deleting the \n in the <pre> (but unsure how many content will need to be altered), but i'm curious if adding a triming the rendered pre's first and last blank line process will be better in the markdown processor?

@yin1999
Copy link
Member

yin1999 commented Dec 24, 2024

It may caused by the post processing of HTML in rari: https://github.com/mdn/rari/blob/df364f905549a025f7607fe5086a62a71d9697aa/crates/rari-doc/src/html/rewriter.rs#L119-L122

The adding of <code> tag makes the first empty line would not be ignored by User Agent, see the spec, and the following tests:

image

@PassionPenguin
Copy link
Contributor Author

It may caused by the post processing of HTML in rari: https://github.com/mdn/rari/blob/df364f905549a025f7607fe5086a62a71d9697aa/crates/rari-doc/src/html/rewriter.rs#L119-L122

The adding of <code> tag makes the first empty line would not be ignored by User Agent, see the spec, and the following tests:

image

then we may just remove the blank line at the very begining of the code content to resolve it

@PassionPenguin
Copy link
Contributor Author

FYI: yari's handler for codeblocks:

const $code = $("<code>").text(code);

@yin1999

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

3 participants
@yin1999 @PassionPenguin and others