// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Tokenizer.Symbols; namespace Microsoft.AspNet.Razor.Parser { public partial class HtmlMarkupParser { public override void ParseDocument() { if (Context == null) { throw new InvalidOperationException(RazorResources.Parser_Context_Not_Set); } using (PushSpanConfig(DefaultMarkupSpan)) { using (Context.StartBlock(BlockType.Markup)) { NextToken(); while (!EndOfFile) { SkipToAndParseCode(HtmlSymbolType.OpenAngle); ScanTagInDocumentContext(); } AddMarkerSymbolIfNecessary(); Output(SpanKind.Markup); } } } /// /// Reads the content of a tag (if present) in the MarkupDocument (or MarkupSection) context, /// where we don't care about maintaining a stack of tags. /// private void ScanTagInDocumentContext() { if (At(HtmlSymbolType.OpenAngle)) { if (NextIs(HtmlSymbolType.Bang)) { // Checking to see if we meet the conditions of a special '!' tag: ' or '

' etc. Optional(HtmlSymbolType.ForwardSlash); // Whitespace here is invalid (according to the spec) OptionalBangEscape(); Optional(HtmlSymbolType.Text); AcceptAll(HtmlSymbolType.WhiteSpace); Optional(HtmlSymbolType.CloseAngle); } Output(SpanKind.Markup); // End tag block tagBlock.Dispose(); } } } }