require "hemingway/block/list/list_nodes" module Hemingway module Block grammar List rule list item+ end rule list_type "itemize" / "enumerate" / "description" end rule item "\\item" whitespace? label:label? sequence:( content / whitespace )* end rule label label_start sequence:label_content* label_end end # This is oddly similar to content. We have to use label_text # instead of text though.. big time bummer.. gotta esacape that label # closing bracket. rule label_content special / tag / block / math / label_text end # Example: \item[label_text] # This totally sucks, but I need to escape a special character when # I have text that resides within an item label. Oof. rule label_text ( !( non_text / label_end ) . )+ end rule label_start "[" end rule label_end "]" end end end end