Coder Social home page Coder Social logo

Comments (4)

MichaelHatherly avatar MichaelHatherly commented on July 22, 2024 1

Ok thanks! So it's a question of number of spaces? (4 in your example instead of 2?) The thing that confuses me is that there's the same number in both cases yet in the second one it picks up the "child" element.

It's not really to do with any particular set number of spaces, it's relative to the lines above. See for example:

julia> cm"""
          100000. one
           1. two
       """ |> CommonMark.ast_dump
Document
  List
    Item
      Paragraph
        Text
          "one"
        SoftBreak
          ""
        Text
          "1"
        Text
          "."
        Text
          " two"

julia> cm"""
          100000. one
                  1. two
       """ |> CommonMark.ast_dump
Document
  List
    Item
      Paragraph
        Text
          "one"
      List
        Item
          Paragraph
            Text
              "two"

Where the first list marker 100000. is much wider than 4 spaces, so any child lists need to start from much further to the right. Once you start putting in weird amounts of indentation the parser consistency drops somewhat: https://babelmark.github.io/?text=+++100000.+one%0A++++1.+two

from commonmark.jl.

tlienart avatar tlienart commented on July 22, 2024 1

Ok this makes sense, thanks!

from commonmark.jl.

MichaelHatherly avatar MichaelHatherly commented on July 22, 2024

Nested lists are tricky syntax, they need the child element markers to be indented in line with the start of the list item's content, i.e

julia> a = """
       1. abc
       2. def
          1. ghi
       """
"1. abc\n2. def\n   1. ghi\n"

julia> p(a)
  1. abc

  2. def

      1. ghi

which is the equivalent to the second, unordered list above.

This is how markdown, commonmark at least, is meant to handle nested lists: see the below babelmark tests:

and the spec for list syntax: https://spec.commonmark.org/0.29/#lists.

https://www.johnmacfarlane.net/beyond-markdown.html is a nice read about the list syntax shortcomings (among other things).

from commonmark.jl.

tlienart avatar tlienart commented on July 22, 2024

Ok thanks! So it's a question of number of spaces? (4 in your example instead of 2?) The thing that confuses me is that there's the same number in both cases yet in the second one it picks up the "child" element.

(I see that the common mark editor does exactly the same thing so feel free to close this issue and I can just refer people to it and tell them to use 4 spaces for indentation)

from commonmark.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.