Skip to main content

The DocHtmlList Class Reference

Node representing a Html list. More...

Declaration

class DocHtmlList { ... }

Included Headers

#include <src/docnode.h>

Base class

classDocCompoundNode

Base class for nodes with children. More...

Enumerations Index

enumType { ... }

Public Constructors Index

DocHtmlList (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs, Type t)

Public Member Functions Index

Typetype () const
const HtmlAttribList &attribs () const
Tokenparse ()
TokenparseXml ()

Private Member Attributes Index

Typem_type = Unordered
HtmlAttribListm_attribs

Description

Node representing a Html list.

Definition at line 999 of file docnode.h.

Enumerations

Type

enum DocHtmlList::Type
Enumeration values
Unordered
Ordered

Definition at line 1002 of file docnode.h.

Public Constructors

DocHtmlList()

DocHtmlList::DocHtmlList (DocParser * parser, DocNodeVariant * parent, const HtmlAttribList & attribs, Type t)
inline

Public Member Functions

attribs()

parse()

Token DocHtmlList::parse ()

Declaration at line 1007 of file docnode.h, definition at line 2647 of file docnode.cpp.

2648{
2649 AUTO_TRACE();
2650 Token retval = Token::make_RetVal_OK();
2651 int num=1;
2652 auto ns = AutoNodeStack(parser(),thisVariant());
2653
2654 // get next token
2655 Token tok=parser()->tokenizer.lex();
2656 // skip whitespace and paragraph breaks
2657 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2658 // should find a html tag now
2659 if (tok.is(TokenRetval::TK_HTMLTAG))
2660 {
2661 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2662 if (tagId==HtmlTagType::HTML_LI && !parser()->context.token->endTag) // found <li> tag
2663 {
2664 // ok, we can go on.
2665 }
2666 else if (((m_type==Unordered && tagId==HtmlTagType::HTML_UL) ||
2668 ) && parser()->context.token->endTag
2669 ) // found empty list
2670 {
2671 // add dummy item to obtain valid HTML
2673 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"empty list!");
2674 retval = Token::make_RetVal_EndList();
2675 goto endlist;
2676 }
2677 else // found some other tag
2678 {
2679 // add dummy item to obtain valid HTML
2681 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but "
2682 "found <{}{}> instead!",parser()->context.token->endTag?"/":"",parser()->context.token->name);
2683 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2684 goto endlist;
2685 }
2686 }
2687 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2688 {
2689 // add dummy item to obtain valid HTML
2691 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2692 " for a html list item");
2693 goto endlist;
2694 }
2695 else // token other than html token
2696 {
2697 // add dummy item to obtain valid HTML
2699 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <li> tag but found {} token instead!",
2700 tok.to_string());
2701 goto endlist;
2702 }
2703
2704 do
2705 {
2708 retval=li->parse();
2709 } while (retval.is(TokenRetval::RetVal_ListItem));
2710
2711 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2712 {
2713 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <{:c}l> block",
2714 m_type==Unordered ? 'u' : 'o');
2715 }
2716
2717endlist:
2718 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2719 return retval.is(TokenRetval::RetVal_EndList) ? Token::make_RetVal_OK() : retval;
2720}

References DocNodeList::append, TokenInfo::attribs, AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children, DocParser::context, DocNodeList::get_last, HTML_LI, HTML_OL, HTML_UL, Mappers::htmlTagMapper, Token::is, Token::is_any_of, DocTokenizer::lex, m_type, Ordered, DocNode::parser, DocTokenizer::pushBackHtmlTag, DocNode::thisVariant, Token::to_string, DocParserContext::token, DocParser::tokenizer, Unordered and warn_doc_error.

parseXml()

Token DocHtmlList::parseXml ()

Declaration at line 1008 of file docnode.h, definition at line 2722 of file docnode.cpp.

2723{
2724 AUTO_TRACE();
2725 Token retval = Token::make_RetVal_OK();
2726 int num=1;
2727 auto ns = AutoNodeStack(parser(),thisVariant());
2728
2729 // get next token
2730 Token tok=parser()->tokenizer.lex();
2731 // skip whitespace and paragraph breaks
2732 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2733 // should find a html tag now
2734 if (tok.is(TokenRetval::TK_HTMLTAG))
2735 {
2736 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2737 //printf("parser()->context.token->name=%s parser()->context.token->endTag=%d\n",qPrint(parser()->context.token->name),parser()->context.token->endTag);
2738 if (tagId==HtmlTagType::XML_ITEM && !parser()->context.token->endTag) // found <item> tag
2739 {
2740 // ok, we can go on.
2741 }
2742 else // found some other tag
2743 {
2744 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but "
2745 "found <{}> instead!",parser()->context.token->name);
2746 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2747 goto endlist;
2748 }
2749 }
2750 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2751 {
2752 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2753 " for a html list item");
2754 goto endlist;
2755 }
2756 else // token other than html token
2757 {
2758 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <item> tag but found {} token instead!",
2759 tok.to_string());
2760 goto endlist;
2761 }
2762
2763 do
2764 {
2767 retval=li->parseXml();
2768 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) break;
2769 //printf("retval=%x parser()->context.token->name=%s\n",retval,qPrint(parser()->context.token->name));
2770 } while (retval.is(TokenRetval::RetVal_ListItem));
2771
2772 if (retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
2773 {
2774 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while inside <list type=\"{}\"> block",
2775 m_type==Unordered ? "bullet" : "number");
2776 }
2777
2778endlist:
2779 AUTO_TRACE_EXIT("retval={}",retval.to_string());
2780 return (retval.is_any_of(TokenRetval::RetVal_EndList,TokenRetval::RetVal_CloseXml) || parser()->context.token->name=="list") ?
2781 Token::make_RetVal_OK() : retval;
2782}

References DocNodeList::append, TokenInfo::attribs, AUTO_TRACE, AUTO_TRACE_EXIT, DocCompoundNode::children, DocParser::context, DocNodeList::get_last, Mappers::htmlTagMapper, Token::is, Token::is_any_of, DocTokenizer::lex, m_type, DocNode::parser, DocTokenizer::pushBackHtmlTag, DocNode::thisVariant, Token::to_string, DocParserContext::token, DocParser::tokenizer, Unordered, warn_doc_error and XML_ITEM.

type()

Private Member Attributes

m_attribs

HtmlAttribList DocHtmlList::m_attribs

Definition at line 1012 of file docnode.h.

Referenced by attribs and DocHtmlList.

m_type

Type DocHtmlList::m_type = Unordered

Definition at line 1011 of file docnode.h.

Referenced by DocHtmlList, parse, parseXml and type.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.