diff --git a/block.go b/block.go index 45c21a6c..4e8779f8 100644 --- a/block.go +++ b/block.go @@ -1051,8 +1051,8 @@ func (p *parser) oliPrefix(data []byte) int { i++ } - // we need >= 1 digits followed by a dot and a space - if start == i || data[i] != '.' || data[i+1] != ' ' { + // we need 1,2 or 3 digits followed by a dot and a space + if start == i || start < i-3 || data[i] != '.' || data[i+1] != ' ' { return 0 } return i + 2 diff --git a/block_test.go b/block_test.go index 820fe890..e9d99cd6 100644 --- a/block_test.go +++ b/block_test.go @@ -836,6 +836,15 @@ func TestOrderedList(t *testing.T) { "* Start with unordered\n 1. Ordered\n", "\n", + "random numbers:\n\n 3. Bird\n 1. McHale\n 8. Parish", + "

random numbers:

\n\n
    \n
  1. Bird
  2. \n
  3. McHale
  4. \n
  5. Parish
  6. \n
\n", + + "big numbers should be skipped:\n\n 3. Bird\n 1. McHale\n 8. Parish\n\n 999. last element", + "

big numbers should be skipped:

\n\n
    \n
  1. Bird
  2. \n
  3. McHale
  4. \n\n
  5. Parish

  6. \n\n
  7. last element

  8. \n
\n", + + "big numbers should be skipped:\n\n 3. Bird\n 1. McHale\n 8. Parish\n\n 2019. is the actual year", + "

big numbers should be skipped:

\n\n
    \n
  1. Bird
  2. \n
  3. McHale
  4. \n
  5. Parish
  6. \n
\n\n

2019. is the actual year

\n", + "1. numbers\n1. are ignored\n", "
    \n
  1. numbers
  2. \n
  3. are ignored
  4. \n
\n",