1<?php 2 3namespace dokuwiki\Parsing\Handler; 4 5/** 6 * CallWriter rewriter for GFM lists. 7 * 8 * GFM accepts `-`, `*`, or `+` for unordered markers and `\d{1,9}[.)]` for 9 * ordered markers, with the first ordered item's number carried through as 10 * the `start` attribute. Indentation is a multiple of 2 starting at 0; 11 * depth = (spaces / 2) + 1, odd indents round down, tabs become two spaces. 12 * 13 * The state machine lives in {@see AbstractListsRewriter}; this class 14 * supplies only the marker parser. 15 */ 16class GfmLists extends AbstractListsRewriter 17{ 18 /** @inheritdoc */ 19 protected function interpretSyntax(string $match): array 20 { 21 $stripped = str_replace("\t", ' ', ltrim($match, "\n")); 22 $indent = strspn($stripped, ' '); 23 $digitLen = strspn($stripped, '0123456789', $indent); 24 25 return [ 26 'depth' => intdiv($indent, 2) + 1, 27 'type' => $digitLen > 0 ? 'o' : 'u', 28 'start' => $digitLen > 0 ? (int) substr($stripped, $indent, $digitLen) : 1, 29 ]; 30 } 31} 32