private List parseList(String s, boolean ordered) throws IOException {
        List list = new List(ordered ? List.ORDERED : List.UNORDERED);

        final Character listChar = ordered ? '#' : '*';

        final int level = countChars(s, listChar);

        ListItem item = parseListItem(s, listChar);
        list.add(item);

        String line = null;
        while ((line = readLine()) != null) {
            line = line.trim();

            int starCount = countChars(line, listChar);

            if (starCount > level) {
                item.add(parseList(line, ordered));

                line = currentLine;
                starCount = countChars(line, listChar);
            }

            if (line.length() == 0) {
                break;
            } else if (!line.startsWith(listChar.toString())) {
                break;
            }

            if (starCount == level) {
                item = parseListItem(line, listChar);
                list.add(item);

            } else if (starCount > level) {
                item.add(parseList(line, ordered));

            } else if (starCount < level) {
                break;
            }
        }

        return list;
    }