Ejemplo n.º 1
0
            private void ValidateCharacterTypeTag(UsfmParserState state, string marker)
            {
                prevMarkerWasChapter = false;
                if (!Canon.IsCanonical(state.VerseRef.BookNum)) // only validate order/occursUnder in Canonical
                {
                    return;
                }

                // Determine if nested styles are used correctly within a cross reference quote
                bool skipCharStyle     = false;
                int  index             = state.Stack.Count - 2;
                UsfmParserElement elem = index >= 0 ? state.Stack[index] : null;

                while (elem != null && elem.Type != UsfmElementTypes.Note)
                {
                    if (elem.Marker == "xq")
                    {
                        skipCharStyle = true;
                        break;
                    }
                    index--;
                    elem = index >= 0 ? state.Stack[index] : null;
                }

                if (skipCharStyle)
                {
                    return; // allow any embedded character styles within cross reference quote
                }
                string contextMarker = null;

                if (state.NoteTag != null)
                {
                    contextMarker = state.NoteTag.Marker;
                }
                else if (state.ParaTag != null)
                {
                    contextMarker = state.ParaTag.Marker;
                }

                ValidateOccursUnder(state, marker, contextMarker, true);
            }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            UsfmParserElement elm = obj as UsfmParserElement;

            return(elm != null && elm.Type == Type && elm.Marker == Marker);
        }
Ejemplo n.º 3
0
 internal MarkerLevel(UsfmParserState state)
 {
     element    = state.Stack.Last();
     stackLevel = state.Stack.Count();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Closes the top element on the stack
        /// </summary>
        void CloseElement()
        {
            UsfmParserElement element = State.Stack[State.Stack.Count - 1];

            State.Stack.RemoveAt(State.Stack.Count - 1);
            switch (element.Type)
            {
            case UsfmElementTypes.Book:
                if (sink != null)
                {
                    sink.EndBook(State, element.Marker);
                }
                break;

            case UsfmElementTypes.Para:
                if (sink != null)
                {
                    sink.EndPara(State, element.Marker);
                }
                break;

            case UsfmElementTypes.Char:
                if (sink != null)
                {
                    sink.EndChar(State, element.Marker, element.Attributes);
                }
                break;

            case UsfmElementTypes.Note:
                if (sink != null)
                {
                    sink.EndNote(State, element.Marker);
                }
                break;

            case UsfmElementTypes.Table:
                if (sink != null)
                {
                    sink.EndTable(State);
                }
                break;

            case UsfmElementTypes.Row:
                if (sink != null)
                {
                    sink.EndRow(State, element.Marker);
                }
                break;

            case UsfmElementTypes.Cell:
                if (sink != null)
                {
                    sink.EndCell(State, element.Marker);
                }
                break;

            case UsfmElementTypes.Sidebar:
                if (sink != null)
                {
                    sink.EndSidebar(State, element.Marker);
                }
                break;
            }
        }