Ejemplo n.º 1
0
        DefinitionListing ParseDefinitionList()
        {
            DefinitionListing listing = new DefinitionListing();

            while (!_classifier.AtEnd)
            {
                // Read the term line:
                Line definitionLine = _classifier.PeekLine();

                if (definitionLine.Classification != LineClassification.DefinitionListTerm)
                {
                    Debug.Assert(listing.Items.Count != 0);

                    return listing;
                }

                DefinitionListItem listingItem = new DefinitionListItem(definitionLine.Text);

                _classifier.ReadLine();

                ParseDefinitionListingItemContents(listingItem);

                listing.Items.Add(listingItem);
            }

            return listing;
        }
Ejemplo n.º 2
0
 public virtual void VisitDefinitionListingItem(DefinitionListItem listingItem)
 {
 }
Ejemplo n.º 3
0
        void ParseDefinitionListingItemContents(DefinitionListItem listingItem)
        {
            while (!_classifier.AtEnd)
            {
                Line line = _classifier.PeekLine();

                switch (line.Classification)
                {
                    case LineClassification.Unclassified:
                        listingItem.Blocks.Add(ParseParagraph());
                        break;

                    case LineClassification.Comment:
                        _classifier.ReadLine();
                        break;

                    case LineClassification.Blank:
                        _classifier.ReadLine();

                        // Ignore single lines; but not double lines:
                        Line followingLine = _classifier.PeekLine();

                        if (followingLine.Classification == LineClassification.Blank) return;

                        break;

                    case LineClassification.ListItem:
                    case LineClassification.NumeredListItem:
                        throw new AdornedTextParsingException(AdornedTextStrings.ListInDefinitionListIsInvalid);

                    case LineClassification.SingleVerbatimBlockLine:
                        listingItem.Blocks.Add(ParseSingleVerbatimLine());
                        break;

                    case LineClassification.VerbatimBlockLine:
                        listingItem.Blocks.Add(ParseVerbatimBlock());
                        break;

                    case LineClassification.TableOpen:
                        listingItem.Blocks.Add(ParseTable());
                        break;

                    case LineClassification.Title:
                        throw new AdornedTextParsingException(AdornedTextStrings.TitleInListIsInvalid);

                    case LineClassification.NumberedTitle:
                        throw new AdornedTextParsingException(AdornedTextStrings.TitleInListIsInvalid);

                    case LineClassification.DefinitionListTerm:
                        return;

                    default:
                        throw new AdornedTextParsingException(AdornedTextStrings.AdornedInternalUnexpected);
                }
            }
        }