ChatGPT解决这个技术问题 Extra ChatGPT

GitHub satanically messing with Markdown - changes 666 to DCLXVI

My GitHub repository has nothing but a readme in it. In this readme, locally I wrote this:

Factoids:
 - There are about six different ways to do everything in Forked.
 - There are actually six different ways to enter loops.
 - There are six directionals and six I/O commands.
 - 666. ha.

Emphasis on the last line. What GitHub decided to show was not 666.

https://i.stack.imgur.com/AVSsT.png

DCLXVI is the Roman Numeral number for 666.

This really creeped me out. My local file and the raw file both show 666.

What is GitHub doing, and why is the indentation on the un-numbered list messed up? Is this an easter egg, or some satanic bug?

Did you try - 5. whatever it should turn into ·V whatever if i see it correctly
Just tested myself and all numbers convert to roman numerals: github.com/NoahCristino/Forked/tree/…
@immibis using hyphens for bullets is standard markdown isn't it?
@EdmundReed Isn't the nested list notation also standard markdown?
Don't worry about the actual Latin number, either. That number probably doesn't mean at all what the common understanding is because of a translation error.

C
Community

This seems to be followed by github/markup issue 991, where on ordered sub-list, decimal numerals automatically turns into roman numerals.

I have found the cause of problem. It is CSS This is the expected way for nested ordered lists to render in HTML. This is not expected in HTML. https://jsfiddle.net/tf5jtv8s We don't make any modifications to the default HTML behavior. ol ol,ul ol{list-style-type:lower-roman} I don't know CSS but my understanding is that this is the cause of problem. I can get expected result by disabling CSS. (I am from my mobile so I can't use browser inspector)

As mentioned in "A formal spec for GitHub Flavored Markdown", GitHub markdown spec GFM: GitHub Flavored Markdown Spec is built on top of the CommonMark Spec.

And as Tommi Kaikkonen mentioned in his answer, the ordered list is because of the dot following 666. See GFM Spec section 5.2.

As mentioned in section 6.1, any ASCII punctuation character may be backslash-escaped, to avoid this issue.
That means:

- 666\. ha.

(as explicitly shown in ForNeVeR's answer)

That is why that 666 number is changed to roman numerals in a GitHub README markdown.

Mike Lippert commented:

the 1st element in that list so it should show as i not dclxvi. Markdown ordered lists ignore the actual number used and number sequentially, and I haven't seen a way to change that.

However, no: it shows dclxvi, because the generated html code is <ol start="666">, which is consistent with the GFM specs:

If the list item is ordered, then it is also assigned a start number, based on the ordered list marker"

(here, '666' is the ordered list marker)

Mike adds:

@VonC For anyone else here's another useful excerpt from VonC's doc link: "The start number of an ordered list is determined by the list number of its initial list item. The numbers of subsequent list items are disregarded."

Also, why is the spacing messed up? I didn't catch that in your answer

You get an ordered list <ol> within an un-ordered list item <li>:

<ul>
  <li>
    <ol start="666">
      <li>ha.</li>
    </ol>
  </li>
</ul>

GitHub CSS rules include:

.markdown-body ol {
    padding-left: 2em;
}

https://i.stack.imgur.com/zmUrx.png


@MDXF I suspect because the number followed by a dot is transformed into an ordered list on the same line as an un-ordered list item (the '-'). Normally,
  • and
      are not supposed to be rendered on the same line...
  • @MDXF I have edited the answer with the exact CSS rule which cause the incorrect spacing.
    Actually I think the output is either a markdown enhancement I haven't heard of, or a bug. Yes - .666 is an ordered sublist, HOWEVER, it is the 1st element in that list so it should show as i not dclxvi . Markdown ordered lists ignore the actual number used and number sequentially, and I haven't seen a way to change that.
    @MikeLippert no, it shows at dclxvi, because the generated html code is <ol start="666">, which is consistent with github.github.com/gfm/#list-items: "If the list item is ordered, then it is also assigned a start number, based on the ordered list marker" (here, '666' is the ordered list marker)
    @VonC Thanks, I hadn't known that enhancement for github-flavored markdown, and didn't find it w/ quick googling before I commented. For anyone else here's another useful excerpt from VonC's doc link "The start number of an ordered list is determined by the list number of its initial list item. The numbers of subsequent list items are disregarded."
    T
    Tommi Kaikkonen

    Adding a period after 666 makes it an ordered list marker.

    GitHub declares CSS that renders ordered list markers using roman numerals:

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

    Escape the period with a backslash, and you should see the correct output.


    F
    ForNeVeR

    While other answers are good at explaining why you have the problem, they haven't given you an exact example of how to fix that.

    And it seems that you've already solved it in an imperfect manner, replacing your text with

    - `666`. ha.
    

    There's a common trick to escape the dot after the number to make it look like a normal text (and not an ordered list label):

    - 666\. ha. (this will render as you probably want)