Exemplo n.º 1
0
        public void ProcessDocument(DocumentDef doc)
        {
            Contract.Requires(doc != null);

            paragraphsStack.Clear();
            OnDocumentBegin(doc);

            foreach (IDocumentElement el in doc.Children)
            {
                ParagraphElement paragraphEl = el as ParagraphElement;
                HeadingElement   headingEl   = el as HeadingElement;

                if (paragraphEl != null)
                {
                    ProcessParagraphElement(paragraphEl);
                }
                else if (headingEl != null)
                {
                    ProcessHeadingElement(headingEl);
                }
                else
                {
                    throw new NotImplementedException("todo next: {0}".Fmt(el.GetType().Name));
                }
            }

            EnsureParagraphStackIsCleared();

            OnDocumentEnd(doc);
        }
Exemplo n.º 2
0
        private void ProcessHeadingElement(HeadingElement headingEl)
        {
            Contract.Requires(headingEl != null);

            EnsureParagraphStackIsCleared();
            OnHeadingElement(headingEl);
        }
Exemplo n.º 3
0
        protected override void OnHeadingElement(HeadingElement headingEl)
        {
            if (headingEl.AnchorId != null)
            {
                writer.AddAttribute("id", headingEl.AnchorId);
            }

            writer.RenderBeginTag("h{0}".Fmt(headingEl.HeadingLevel));
            writer.WriteEncodedText(headingEl.HeadingText);
            writer.RenderEndTag();
        }
Exemplo n.º 4
0
        public static DivElement CreatePanelHeader()
        {
            var header = new DivElement
            {
                ClassName = "panel-heading logo"
            };

            var title = new HeadingElement
            {
                InnerHTML = "Bridge.NET HTML5 Demo"
            };

            header.AppendChild(title);

            return(header);
        }
Exemplo n.º 5
0
        private bool Write(HeadingElement header)
        {
            if (header == null)
            {
                return(false);
            }

            if (!HaveRoomFor(2))
            {
                NewPage();
            }

            WriteLine(header.Value.ToUpperInvariant());
            EmptyLine();
            return(true);
        }
Exemplo n.º 6
0
        private static void HandleHeadingLine(DocumentDefBuilder docBuilder, ParsingContext context, TokenBuffer tokenBuffer)
        {
            Contract.Requires(docBuilder != null);
            Contract.Requires(context != null);
            Contract.Requires(tokenBuffer != null);

            WikiTextToken firstToken = tokenBuffer.Token;

            WikiTextToken.TokenType endingTokenNeeded;
            int headingLevel;

            switch (firstToken.Type)
            {
            case WikiTextToken.TokenType.Heading1Start:
                headingLevel      = 1;
                endingTokenNeeded = WikiTextToken.TokenType.Heading1End;
                break;

            case WikiTextToken.TokenType.Heading2Start:
                headingLevel      = 2;
                endingTokenNeeded = WikiTextToken.TokenType.Heading2End;
                break;

            case WikiTextToken.TokenType.Heading3Start:
                headingLevel      = 3;
                endingTokenNeeded = WikiTextToken.TokenType.Heading3End;
                break;

            case WikiTextToken.TokenType.Heading4Start:
                headingLevel      = 4;
                endingTokenNeeded = WikiTextToken.TokenType.Heading4End;
                break;

            case WikiTextToken.TokenType.Heading5Start:
                headingLevel      = 5;
                endingTokenNeeded = WikiTextToken.TokenType.Heading5End;
                break;

            case WikiTextToken.TokenType.Heading6Start:
                headingLevel      = 6;
                endingTokenNeeded = WikiTextToken.TokenType.Heading6End;
                break;

            default:
                throw new InvalidOperationException("BUG");
            }

            tokenBuffer.MoveToNextToken();

            StringBuilder headingText = new StringBuilder();

            if (!ProcessHeadingText(context, tokenBuffer, endingTokenNeeded, headingText))
            {
                return;
            }

            HeadingElement headingEl = new HeadingElement(headingText.ToString().Trim(), headingLevel);

            docBuilder.AddRootChild(headingEl);

            tokenBuffer.MoveToNextToken();
            string anchorId;

            if (!ProcessHeadingAnchor(context, tokenBuffer, out anchorId))
            {
                return;
            }

            tokenBuffer.ProcessUntilEnd(
                t =>
            {
                context.ReportError("Unexpected token at the end of heading");
                return(false);
            });

            headingEl.AnchorId = anchorId;
        }
Exemplo n.º 7
0
 protected virtual void OnHeadingElement(HeadingElement headingEl)
 {
     Contract.Requires(headingEl != null);
 }
Exemplo n.º 8
0
        private bool Write(HeadingElement header)
        {
            if (header == null)
                return false;

            if (!HaveRoomFor(2))
                NewPage();

            WriteLine(header.Value.ToUpperInvariant());
            EmptyLine();
            return true;
        }
Exemplo n.º 9
0
        public static ModalDlg Make(string titleText, string bodyText, string id)
        {
            DivElement myModal = new DivElement();

            myModal.ClassName = "modal fade";
            myModal.Id        = id;
            myModal.SetAttribute("role", "dialog");
            jQuery jq = new jQuery(myModal).On("hidden.bs.modal", OnHidden);


            DivElement modalDlg = new DivElement();

            modalDlg.ClassName = "modal-dialog-sm";
            myModal.AppendChild(modalDlg);


            DivElement modalContent = new DivElement();

            modalContent.ClassName = "modal-content";
            modalDlg.AppendChild(modalContent);

            DivElement modalHeader = new DivElement();

            modalHeader.ClassName = "modal-header";
            modalContent.AppendChild(modalHeader);

            ButtonElement button = new ButtonElement();

            button.SetAttribute("type", "button");
            button.ClassName = "close";
            button.SetAttribute("data-dismiss", "modal");
            button.InnerHTML = "×";
            modalHeader.AppendChild(button);

            HeadingElement title = new HeadingElement(HeadingType.H4);

            title.ClassName = "modal-title";
            title.InnerHTML = titleText;
            modalHeader.AppendChild(title);


            DivElement modalBody = new DivElement();

            modalBody.ClassName = "modal-body";
            modalContent.AppendChild(modalBody);

            ParagraphElement bodyContent = new ParagraphElement();

            bodyContent.InnerHTML = bodyText;
            modalBody.AppendChild(bodyContent);

            DivElement footer = new DivElement();

            footer.ClassName = "modal-footer";


            ButtonElement footerButton = new ButtonElement();

            footerButton.SetAttribute("type", "button");
            footerButton.ClassName = "btn btn-default";
            footerButton.SetAttribute("data-dismiss", "modal");
            footerButton.InnerHTML = "Close";

            footer.AppendChild(footerButton);
            modalContent.AppendChild(footer);

            Document.Body.AppendChild(myModal);

            ModalDlg dlg = new ModalDlg();

            dlg.TopElement  = myModal;
            dlg.Body        = modalBody;
            dlg.Title       = title;
            dlg.BodyContent = bodyContent;
            dlg.Footer      = footer;
            dlg.id          = id;
            return(dlg);
        }