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

lists.scss: reset <ol> without 'type' attr to "decimal" #1420

Merged
merged 2 commits into from
May 26, 2021

Conversation

hpalacio
Copy link
Contributor

@hpalacio hpalacio commented May 25, 2021

HTML default list-style-type is "decimal" when there is no 'type'
attribute.

In MarkDown language, you can't specify the style type of a list
item, so nested lists always represent with decimal numbers at
any level. Since this is not user friendly, GitHub CSS styling
overrides the HTML standard by setting lower-roman for second-level
items and lower-alpha for third-level items.

In AsciiDoc language, you can specify the style type of a list
item using a tage before the list, for example:

   Tag		    Produces
   [loweralpha]     <ol type="a">
   [lowerroman]     <ol type="i">
   [decimal]        <ol>

The [decimal] tag doesn't generate any 'type' attribute because
the HTML standard when there is no type, is decimal.
If such a [decimal] tag is used on a second-level or third-level
item, GitHub CSS for MarkDown overrides HTML standard and you get
instead a lowerroman or loweralpha sign.

The added CSS resets the list-style-type of <ol> without type to
decimal, as it should be in the first place, for the construction
div > ol, which is only produced by AsciiDoc files, to avoid any effect
on existing MarkDown files.

@changeset-bot
Copy link

changeset-bot bot commented May 25, 2021

🦋 Changeset detected

Latest commit: 55302dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/css Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@simurai
Copy link
Contributor

simurai commented May 26, 2021

Tried the reproduce this issue and yes... the following

. Item 1
. Item 2
. Item 3
[decimal]
.. Item 1
.. Item 2
.. Item 3
[decimal]
... Item 1
... Item 2
... Item 3

saved as .adoc file does show the 2nd and 3rd level with lower-roman and lower-alpha instead of decimal.

Screen Shot 2021-05-26 at 15 42 27

I guess this logic comes from

ol ol,
ul ol {
list-style-type: lower-roman;
}
ul ul ol,
ul ol ol,
ol ul ol,
ol ol ol {
list-style-type: lower-alpha;
}
.

@@ -26,6 +26,12 @@
list-style-type: lower-roman;
}

// Reset <ol> style to decimal (HTML default) specifically for AsciiDoc
// <div><ol> construction (doesn't affect MarkDown)
div ol:not([type]) {
Copy link
Contributor

@simurai simurai May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it seems the <div> as a wrapper is the only thing that differentiates AsciiDoc and MarkDown. @hpalacio Should we use the > child selector to make it even more specific?

Suggested change
div ol:not([type]) {
div > ol:not([type]) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! I missed that.
Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed-up the commit with child selector div > ol

hpalacio and others added 2 commits May 26, 2021 08:56
HTML default list-style-type is "decimal" when there is no 'type'
attribute.

In MarkDown language, you can't specify the style type of a list
item, so nested lists *always* represent with decimal numbers at
any level. Since this is not user friendly, GitHub CSS styling
overrides the HTML standard by setting lower-roman for second-level
items and lower-alpha for third-level items.

In AsciiDoc language, you can specify the style type of a list
item using a tage before the list, for example:

   Tag		    Produces
   [loweralpha]     <ol type="a">
   [lowerroman]     <ol type="i">
   [decimal]        <ol>

The [decimal] tag doesn't generate any 'type' attribute because
the HTML standard when there is no type, *is* decimal.
If such a [decimal] tag is used on a second-level or third-level
item, GitHub CSS for MarkDown overrides HTML standard and you get
instead a lowerroman or loweralpha sign.

The added CSS resets the list-style-type of <ol> without type to
decimal, as it should be in the first place, for the construction
div > ol, which is only produced by AsciiDoc files, to avoid any effect
on existing MarkDown files.

Signed-off-by: Hector Palacios <[email protected]>
Copy link
Contributor

@simurai simurai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think this is good to go. 🚢 @hpalacio thanks 🙇

@simurai simurai merged commit 57c1797 into primer:main May 26, 2021
@primer-css primer-css mentioned this pull request May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants