package parser

import (
	
	
	
)

type listItemParser struct {
}

var defaultListItemParser = &listItemParser{}
NewListItemParser returns a new BlockParser that parses list items.
func () BlockParser {
	return defaultListItemParser
}

var skipListParser = NewContextKey()
var skipListParserValue interface{} = true

func ( *listItemParser) () []byte {
	return []byte{'-', '+', '*', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
}

func ( *listItemParser) ( ast.Node,  text.Reader,  Context) (ast.Node, State) {
	,  := .(*ast.List)
	if ! { // list item must be a child of a list
		return nil, NoChildren
	}
	 := lastOffset()
	,  := .PeekLine()
	,  := matchesListItem(, false)
	if  == notList {
		return nil, NoChildren
	}
	if [1]- > 3 {
		return nil, NoChildren
	}
	 := calcListOffset(, )
	 := ast.NewListItem([3] + )
	if [4] < 0 || [5]-[4] == 1 {
		return , NoChildren
	}

	,  := util.IndentPosition([[4]:], [4], )
	 := [3] + 
	.AdvanceAndSetPadding(, )
	return , HasChildren
}

func ( *listItemParser) ( ast.Node,  text.Reader,  Context) State {
	,  := .PeekLine()
	if util.IsBlank() {
		.Advance(len()-1)

		return Continue | HasChildren
	}

	,  := util.IndentWidth(, .LineOffset())
	 := lastOffset(.Parent())
	if  <  &&  < 4 {
new list item found
		if  != notList {
			.Set(skipListParser, skipListParserValue)
		}
		return Close
	}
	,  := util.IndentPosition(, .LineOffset(), )
	.AdvanceAndSetPadding(, )

	return Continue | HasChildren
}

nothing to do