Skip to main content

The Private Struct Reference

Declaration

struct Markdown::Private { ... }

Public Member Typedefs Index

usingAction_t = std::function< int(std::string_view, size_t)>

Public Constructors Index

Private (const QCString &fn, int line, int indent)

Public Member Functions Index

QCStringprocessQuotations (std::string_view data, size_t refIndent)
QCStringprocessBlocks (std::string_view data, size_t indent)
QCStringisBlockCommand (std::string_view data, size_t offset)
size_tisSpecialCommand (std::string_view data, size_t offset)
size_tfindEndOfLine (std::string_view data, size_t offset)
intprocessHtmlTagWrite (std::string_view data, size_t offset, bool doWrite)

Process a HTML tag. More...

intprocessHtmlTag (std::string_view data, size_t offset)
intprocessEmphasis (std::string_view data, size_t offset)
intprocessEmphasis1 (std::string_view data, char c)

process single emphasis More...

intprocessEmphasis2 (std::string_view data, char c)

process double emphasis More...

intprocessEmphasis3 (std::string_view data, char c)

Parsing triple emphasis. More...

intprocessNmdash (std::string_view data, size_t offset)

Process ndash and mdashes. More...

intprocessQuoted (std::string_view data, size_t offset)

Process quoted section "...", can contain one embedded newline. More...

intprocessCodeSpan (std::string_view data, size_t offset)

` parsing a code span (assuming codespan != 0) More...

intprocessSpecialCommand (std::string_view data, size_t offset)
intprocessLink (std::string_view data, size_t offset)
size_tfindEmphasisChar (std::string_view, char c, size_t c_size)

looks for the next emph char, skipping other constructs, and stopping when either it is found, or we are at the end of a paragraph. More...

voidaddStrEscapeUtf8Nbsp (std::string_view data)
voidprocessInline (std::string_view data)
voidwriteMarkdownImage (std::string_view fmt, bool inline_img, bool explicitTitle, const QCString &title, const QCString &content, const QCString &link, const QCString &attributes, const FileDef *fd)
intisHeaderline (std::string_view data, bool allowAdjustLevel)

returns whether the line is a setext-style hdr underline More...

intisAtxHeader (std::string_view data, QCString &header, QCString &id, bool allowAdjustLevel, bool *pIsIdGenerated=nullptr)
voidwriteOneLineHeaderOrRuler (std::string_view data)
voidwriteFencedCodeBlock (std::string_view data, std::string_view lang, size_t blockStart, size_t blockEnd)
size_twriteBlockQuote (std::string_view data)
size_twriteCodeBlock (std::string_view, size_t refIndent)
size_twriteTableBlock (std::string_view data)
QCStringextractTitleId (QCString &title, int level, bool *pIsIdGenerated=nullptr)

Public Member Attributes Index

std::unordered_map< std::string, LinkRef >linkRefs
QCStringfileName
intlineNr = 0
intindentLevel =0
QCStringout
std::array< Action_t, 256 >actions

Definition at line 113 of file markdown.cpp.

Public Member Typedefs

Action_t

using Markdown::Private::Action_t = std::function<int(std::string_view,size_t)>

Definition at line 172 of file markdown.cpp.

172 using Action_t = std::function<int(std::string_view,size_t)>;

Public Constructors

Private()

Markdown::Private::Private (const QCString & fn, int line, int indent)
inline

Definition at line 115 of file markdown.cpp.

115 Private(const QCString &fn,int line,int indent)
116 : fileName(fn), lineNr(line), indentLevel(indent)
117 {
118 // setup callback table for special characters
119 actions[static_cast<unsigned int>('_')] = [this](std::string_view data,size_t offset) { return processEmphasis (data,offset); };
120 actions[static_cast<unsigned int>('*')] = [this](std::string_view data,size_t offset) { return processEmphasis (data,offset); };
121 actions[static_cast<unsigned int>('~')] = [this](std::string_view data,size_t offset) { return processEmphasis (data,offset); };
122 actions[static_cast<unsigned int>('`')] = [this](std::string_view data,size_t offset) { return processCodeSpan (data,offset); };
123 actions[static_cast<unsigned int>('\\')]= [this](std::string_view data,size_t offset) { return processSpecialCommand(data,offset); };
124 actions[static_cast<unsigned int>('@')] = [this](std::string_view data,size_t offset) { return processSpecialCommand(data,offset); };
125 actions[static_cast<unsigned int>('[')] = [this](std::string_view data,size_t offset) { return processLink (data,offset); };
126 actions[static_cast<unsigned int>('!')] = [this](std::string_view data,size_t offset) { return processLink (data,offset); };
127 actions[static_cast<unsigned int>('<')] = [this](std::string_view data,size_t offset) { return processHtmlTag (data,offset); };
128 actions[static_cast<unsigned int>('-')] = [this](std::string_view data,size_t offset) { return processNmdash (data,offset); };
129 actions[static_cast<unsigned int>('"')] = [this](std::string_view data,size_t offset) { return processQuoted (data,offset); };
130 }

Public Member Functions

addStrEscapeUtf8Nbsp()

void Markdown::Private::addStrEscapeUtf8Nbsp (std::string_view data)

Definition at line 149 of file markdown.cpp.

1690{
1691 AUTO_TRACE("{}",Trace::trunc(data));
1692 if (Portable::strnstr(data.data(),g_doxy_nbsp,data.size())==nullptr) // no escape needed -> fast
1693 {
1694 out+=data;
1695 }
1696 else // escape needed -> slow
1697 {
1699 }
1700}

References AUTO_TRACE, g_doxy_nbsp, g_utf8_nbsp, out, Portable::strnstr, substitute and Trace::trunc.

Referenced by processSpecialCommand and writeFencedCodeBlock.

extractTitleId()

QCString Markdown::Private::extractTitleId (QCString & title, int level, bool * pIsIdGenerated=nullptr)

Definition at line 164 of file markdown.cpp.

1992QCString Markdown::Private::extractTitleId(QCString &title, int level, bool *pIsIdGenerated)
1993{
1994 AUTO_TRACE("title={} level={}",Trace::trunc(title),level);
1995 // match e.g. '{#id-b11} ' and capture 'id-b11'
1996 static const reg::Ex r2(R"({#(\a[\w-]*)}\s*$)");
1997 reg::Match match;
1998 std::string ti = title.str();
1999 if (reg::search(ti,match,r2))
2000 {
2001 std::string id = match[1].str();
2002 title = title.left(match.position());
2003 if (AnchorGenerator::instance().reserve(id)>0)
2004 {
2005 warn(fileName, lineNr, "An automatically generated id already has the name '{}'!", id);
2006 }
2007 //printf("found match id='%s' title=%s\n",id.c_str(),qPrint(title));
2008 AUTO_TRACE_EXIT("id={}",id);
2009 return id;
2010 }
2011 if (((level>0) && (level<=Config_getInt(TOC_INCLUDE_HEADINGS))) || (Config_getEnum(MARKDOWN_ID_STYLE)==MARKDOWN_ID_STYLE_t::GITHUB))
2012 {
2014 if (pIsIdGenerated) *pIsIdGenerated=true;
2015 //printf("auto-generated id='%s' title='%s'\n",qPrint(id),qPrint(title));
2016 AUTO_TRACE_EXIT("id={}",id);
2017 return id;
2018 }
2019 //printf("no id found in title '%s'\n",qPrint(title));
2020 return "";
2021}

References AUTO_TRACE, AUTO_TRACE_EXIT, Config_getEnum, Config_getInt, fileName, AnchorGenerator::generate, AnchorGenerator::instance, QCString::left, lineNr, reg::search, QCString::str, Trace::trunc and warn.

Referenced by isAtxHeader and processBlocks.

findEmphasisChar()

size_t Markdown::Private::findEmphasisChar (std::string_view data, char c, size_t c_size)

looks for the next emph char, skipping other constructs, and stopping when either it is found, or we are at the end of a paragraph.

Definition at line 148 of file markdown.cpp.

702size_t Markdown::Private::findEmphasisChar(std::string_view data, char c, size_t c_size)
703{
704 AUTO_TRACE("data='{}' c={} c_size={}",Trace::trunc(data),c,c_size);
705 size_t i = 1;
706 const size_t size = data.size();
707
708 while (i<size)
709 {
710 while (i<size && data[i]!=c &&
711 data[i]!='\\' && data[i]!='@' &&
712 !(data[i]=='/' && data[i-1]=='<') && // html end tag also ends emphasis
713 data[i]!='\n') i++;
714 // avoid overflow (unclosed emph token)
715 if (i==size)
716 {
717 return 0;
718 }
719 //printf("findEmphasisChar: data=[%s] i=%d c=%c\n",data,i,data[i]);
720
721 // not counting escaped chars or characters that are unlikely
722 // to appear as the end of the emphasis char
723 if (ignoreCloseEmphChar(data[i-1],data[i]))
724 {
725 i++;
726 continue;
727 }
728 else
729 {
730 // get length of emphasis token
731 size_t len = 0;
732 while (i+len<size && data[i+len]==c)
733 {
734 len++;
735 }
736
737 if (len>0)
738 {
739 if (len!=c_size || (i+len<size && isIdChar(data[i+len]))) // to prevent touching some_underscore_identifier
740 {
741 i+=len;
742 continue;
743 }
744 AUTO_TRACE_EXIT("result={}",i);
745 return static_cast<int>(i); // found it
746 }
747 }
748
749 // skipping a code span
750 if (data[i]=='`')
751 {
752 int snb=0;
753 while (i<size && data[i]=='`') snb++,i++;
754
755 // find same pattern to end the span
756 int enb=0;
757 while (i<size && enb<snb)
758 {
759 if (data[i]=='`') enb++;
760 if (snb==1 && data[i]=='\'') break; // ` ended by '
761 i++;
762 }
763 }
764 else if (data[i]=='@' || data[i]=='\\')
765 { // skip over blocks that should not be processed
766 QCString endBlockName = isBlockCommand(data.substr(i),i);
767 if (!endBlockName.isEmpty())
768 {
769 i++;
770 size_t l = endBlockName.length();
771 while (i+l<size)
772 {
773 if ((data[i]=='\\' || data[i]=='@') && // command
774 data[i-1]!='\\' && data[i-1]!='@') // not escaped
775 {
776 if (qstrncmp(&data[i+1],endBlockName.data(),l)==0)
777 {
778 break;
779 }
780 }
781 i++;
782 }
783 }
784 else if (i+1<size && isIdChar(data[i+1])) // @cmd, stop processing, see bug 690385
785 {
786 return 0;
787 }
788 else
789 {
790 i++;
791 }
792 }
793 else if (data[i-1]=='<' && data[i]=='/') // html end tag invalidates emphasis
794 {
795 return 0;
796 }
797 else if (data[i]=='\n') // end * or _ at paragraph boundary
798 {
799 i++;
800 while (i<size && data[i]==' ') i++;
801 if (i>=size || data[i]=='\n')
802 {
803 return 0;
804 } // empty line -> paragraph
805 }
806 else // should not get here!
807 {
808 i++;
809 }
810 }
811 return 0;
812}

References AUTO_TRACE, AUTO_TRACE_EXIT, QCString::data, ignoreCloseEmphChar, isBlockCommand, QCString::isEmpty, isIdChar, QCString::length, qstrncmp and Trace::trunc.

Referenced by processEmphasis1, processEmphasis2 and processEmphasis3.

findEndOfLine()

size_t Markdown::Private::findEndOfLine (std::string_view data, size_t offset)

Definition at line 136 of file markdown.cpp.

2978size_t Markdown::Private::findEndOfLine(std::string_view data,size_t offset)
2979{
2980 AUTO_TRACE("data='{}'",Trace::trunc(data));
2981 // find end of the line
2982 const size_t size = data.size();
2983 size_t nb=0, end=offset+1, j=0;
2984 while (end<=size && (j=isNewline(data.substr(end-1)))==0)
2985 {
2986 // while looking for the end of the line we might encounter a block
2987 // that needs to be passed unprocessed.
2988 if ((data[end-1]=='\\' || data[end-1]=='@') && // command
2989 (end<=1 || (data[end-2]!='\\' && data[end-2]!='@')) // not escaped
2990 )
2991 {
2992 QCString endBlockName = isBlockCommand(data.substr(end-1),end-1);
2993 end++;
2994 if (!endBlockName.isEmpty())
2995 {
2996 size_t l = endBlockName.length();
2997 for (;end+l+1<size;end++) // search for end of block marker
2998 {
2999 if ((data[end]=='\\' || data[end]=='@') &&
3000 data[end-1]!='\\' && data[end-1]!='@'
3001 )
3002 {
3003 if (qstrncmp(&data[end+1],endBlockName.data(),l)==0)
3004 {
3005 // found end marker, skip over this block
3006 //printf("feol.block out={%s}\n",qPrint(QCString(data+i).left(end+l+1-i)));
3007 end = end + l + 2;
3008 break;
3009 }
3010 }
3011 }
3012 }
3013 }
3014 else if (nb==0 && data[end-1]=='<' && size>=6 && end+6<size &&
3015 (end<=1 || (data[end-2]!='\\' && data[end-2]!='@'))
3016 )
3017 {
3018 if (tolower(data[end])=='p' && tolower(data[end+1])=='r' &&
3019 tolower(data[end+2])=='e' && (data[end+3]=='>' || data[end+3]==' ')) // <pre> tag
3020 {
3021 // skip part until including </pre>
3022 end = end + processHtmlTagWrite(data.substr(end-1),end-1,false);
3023 break;
3024 }
3025 else
3026 {
3027 end++;
3028 }
3029 }
3030 else if (nb==0 && data[end-1]=='`')
3031 {
3032 while (end<=size && data[end-1]=='`') end++,nb++;
3033 }
3034 else if (nb>0 && data[end-1]=='`')
3035 {
3036 size_t enb=0;
3037 while (end<=size && data[end-1]=='`') end++,enb++;
3038 if (enb==nb) nb=0;
3039 }
3040 else
3041 {
3042 end++;
3043 }
3044 }
3045 if (j>0) end+=j-1;
3046 AUTO_TRACE_EXIT("offset={} end={}",offset,end);
3047 return end;
3048}

References AUTO_TRACE, AUTO_TRACE_EXIT, QCString::data, end, isBlockCommand, QCString::isEmpty, isNewline, QCString::length, processHtmlTagWrite, qstrncmp and Trace::trunc.

Referenced by processBlocks and processQuotations.

isAtxHeader()

int Markdown::Private::isAtxHeader (std::string_view data, QCString & header, QCString & id, bool allowAdjustLevel, bool * pIsIdGenerated=nullptr)

Definition at line 156 of file markdown.cpp.

2024int Markdown::Private::isAtxHeader(std::string_view data,
2025 QCString &header,QCString &id,bool allowAdjustLevel,bool *pIsIdGenerated)
2026{
2027 AUTO_TRACE("data='{}' header={} id={} allowAdjustLevel={}",Trace::trunc(data),Trace::trunc(header),id,allowAdjustLevel);
2028 size_t i = 0;
2029 int level = 0, blanks=0;
2030 const size_t size = data.size();
2031
2032 // find start of header text and determine heading level
2033 while (i<size && data[i]==' ') i++;
2034 if (i>=size || data[i]!='#')
2035 {
2036 return 0;
2037 }
2038 while (i<size && data[i]=='#') i++,level++;
2039 if (level>SectionType::MaxLevel) // too many #'s -> no section
2040 {
2041 return 0;
2042 }
2043 while (i<size && data[i]==' ') i++,blanks++;
2044 if (level==1 && blanks==0)
2045 {
2046 return 0; // special case to prevent #someid seen as a header (see bug 671395)
2047 }
2048
2049 // find end of header text
2050 size_t end=i;
2051 while (end<size && data[end]!='\n') end++;
2052 while (end>i && (data[end-1]=='#' || data[end-1]==' ')) end--;
2053
2054 // store result
2055 header = data.substr(i,end-i);
2056 id = extractTitleId(header, level, pIsIdGenerated);
2057 if (!id.isEmpty()) // strip #'s between title and id
2058 {
2059 int idx=static_cast<int>(header.length())-1;
2060 while (idx>=0 && (header.at(idx)=='#' || header.at(idx)==' ')) idx--;
2061 header=header.left(idx+1);
2062 }
2063
2064 if (allowAdjustLevel && level==1 && indentLevel==-1)
2065 {
2066 // in case we find a `# Section` on a markdown page that started with the same level
2067 // header, we no longer need to artificially decrease the paragraph level.
2068 // So both
2069 // -------------------
2070 // # heading 1 <-- here we set g_indentLevel to -1
2071 // # heading 2 <-- here we set g_indentLevel back to 0 such that this will be a @section
2072 // -------------------
2073 // and
2074 // -------------------
2075 // # heading 1 <-- here we set g_indentLevel to -1
2076 // ## heading 2 <-- here we keep g_indentLevel at -1 such that @subsection will be @section
2077 // -------------------
2078 // will convert to
2079 // -------------------
2080 // @page md_page Heading 1
2081 // @section autotoc_md1 Heading 2
2082 // -------------------
2083
2084 indentLevel=0;
2085 }
2086 int res = level+indentLevel;
2087 AUTO_TRACE_EXIT("result={}",res);
2088 return res;
2089}

References QCString::at, AUTO_TRACE, AUTO_TRACE_EXIT, end, extractTitleId, indentLevel, QCString::left, QCString::length, SectionType::MaxLevel and Trace::trunc.

Referenced by writeOneLineHeaderOrRuler.

isBlockCommand()

QCString Markdown::Private::isBlockCommand (std::string_view data, size_t offset)

Definition at line 134 of file markdown.cpp.

360QCString Markdown::Private::isBlockCommand(std::string_view data,size_t offset)
361{
362 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
363
364 using EndBlockFunc = QCString (*)(const std::string &,bool,char);
365
366 static const auto getEndBlock = [](const std::string &blockName,bool,char) -> QCString
367 {
368 return "end"+blockName;
369 };
370 static const auto getEndCode = [](const std::string &blockName,bool openBracket,char) -> QCString
371 {
372 return openBracket ? QCString("}") : "end"+blockName;
373 };
374 static const auto getEndUml = [](const std::string &/* blockName */,bool,char) -> QCString
375 {
376 return "enduml";
377 };
378 static const auto getEndFormula = [](const std::string &/* blockName */,bool,char nextChar) -> QCString
379 {
380 switch (nextChar)
381 {
382 case '$': return "f$";
383 case '(': return "f)";
384 case '[': return "f]";
385 case '{': return "f}";
386 }
387 return "";
388 };
389
390 // table mapping a block start command to a function that can return the matching end block string
391 static const std::unordered_map<std::string,EndBlockFunc> blockNames =
392 {
393 { "dot", getEndBlock },
394 { "code", getEndCode },
395 { "icode", getEndBlock },
396 { "msc", getEndBlock },
397 { "verbatim", getEndBlock },
398 { "iverbatim", getEndBlock },
399 { "iliteral", getEndBlock },
400 { "latexonly", getEndBlock },
401 { "htmlonly", getEndBlock },
402 { "xmlonly", getEndBlock },
403 { "rtfonly", getEndBlock },
404 { "manonly", getEndBlock },
405 { "docbookonly", getEndBlock },
406 { "startuml", getEndUml },
407 { "f", getEndFormula }
408 };
409
410 const size_t size = data.size();
411 bool openBracket = offset>0 && data.data()[-1]=='{';
412 bool isEscaped = offset>0 && (data.data()[-1]=='\\' || data.data()[-1]=='@');
413 if (isEscaped) return QCString();
414
415 size_t end=1;
416 while (end<size && (data[end]>='a' && data[end]<='z')) end++;
417 if (end==1) return QCString();
418 std::string blockName(data.substr(1,end-1));
419 auto it = blockNames.find(blockName);
420 QCString result;
421 if (it!=blockNames.end()) // there is a function assigned
422 {
423 result = it->second(blockName, openBracket, end<size ? data[end] : 0);
424 }
425 AUTO_TRACE_EXIT("result={}",result);
426 return result;
427}

References AUTO_TRACE, AUTO_TRACE_EXIT, end, QCString::size and Trace::trunc.

Referenced by findEmphasisChar, findEndOfLine, processBlocks and processSpecialCommand.

isHeaderline()

int Markdown::Private::isHeaderline (std::string_view data, bool allowAdjustLevel)

returns whether the line is a setext-style hdr underline

Definition at line 155 of file markdown.cpp.

1805int Markdown::Private::isHeaderline(std::string_view data, bool allowAdjustLevel)
1806{
1807 AUTO_TRACE("data='{}' allowAdjustLevel",Trace::trunc(data),allowAdjustLevel);
1808 size_t i=0, c=0;
1809 const size_t size = data.size();
1810 while (i<size && data[i]==' ') i++;
1811 if (i==size) return 0;
1812
1813 // test of level 1 header
1814 if (data[i]=='=')
1815 {
1816 while (i<size && data[i]=='=') i++,c++;
1817 while (i<size && data[i]==' ') i++;
1818 int level = (c>1 && (i>=size || data[i]=='\n')) ? 1 : 0;
1819 if (allowAdjustLevel && level==1 && indentLevel==-1)
1820 {
1821 // In case a page starts with a header line we use it as title, promoting it to @page.
1822 // We set g_indentLevel to -1 to promoting the other sections if they have a deeper
1823 // nesting level than the page header, i.e. @section..@subsection becomes @page..@section.
1824 // In case a section at the same level is found (@section..@section) however we need
1825 // to undo this (and the result will be @page..@section).
1826 indentLevel=0;
1827 }
1828 AUTO_TRACE_EXIT("result={}",indentLevel+level);
1829 return indentLevel+level;
1830 }
1831 // test of level 2 header
1832 if (data[i]=='-')
1833 {
1834 while (i<size && data[i]=='-') i++,c++;
1835 while (i<size && data[i]==' ') i++;
1836 return (c>1 && (i>=size || data[i]=='\n')) ? indentLevel2 : 0;
1837 }
1838 return 0;
1839}

References AUTO_TRACE, AUTO_TRACE_EXIT, indentLevel and Trace::trunc.

Referenced by processBlocks.

isSpecialCommand()

size_t Markdown::Private::isSpecialCommand (std::string_view data, size_t offset)

Definition at line 135 of file markdown.cpp.

429size_t Markdown::Private::isSpecialCommand(std::string_view data,size_t offset)
430{
431 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
432
433 using EndCmdFunc = size_t (*)(std::string_view,size_t);
434
435 static const auto endOfLine = [](std::string_view data_,size_t offset_) -> size_t
436 {
437 // skip until the end of line (allowing line continuation characters)
438 char lc = 0;
439 char c = 0;
440 while (offset_<data_.size() && ((c=data_[offset_])!='\n' || lc=='\\'))
441 {
442 if (c=='\\') lc='\\'; // last character was a line continuation
443 else if (c!=' ') lc=0; // rest line continuation
444 offset_++;
445 }
446 return offset_;
447 };
448
449 static const auto endOfLabels = [](std::string_view data_,size_t offset_,bool multi_) -> size_t
450 {
451 if (offset_<data_.size() && data_[offset_]==' ') // we expect a space before the label
452 {
453 char c = 0;
454 offset_++;
455 bool done=false;
456 while (!done)
457 {
458 // skip over spaces
459 while (offset_<data_.size() && data_[offset_]==' ')
460 {
461 offset_++;
462 }
463 // skip over label
464 while (offset_<data_.size() && (c=data_[offset_])!=' ' && c!=',' && c!='\\' && c!='@' && c!='\n')
465 {
466 offset_++;
467 }
468 // optionally skip over a comma separated list of labels
469 if (multi_ && offset_<data_.size() && (data_[offset_]==',' || data_[offset_]==' '))
470 {
471 size_t off = offset_;
472 while (off<data_.size() && data_[off]==' ')
473 {
474 off++;
475 }
476 if (off<data_.size() && data_[off]==',')
477 {
478 offset_ = ++off;
479 }
480 else // no next label found
481 {
482 done=true;
483 }
484 }
485 else
486 {
487 done=true;
488 }
489 }
490 return offset_;
491 }
492 return 0;
493 };
494
495 static const auto endOfLabel = [](std::string_view data_,size_t offset_) -> size_t
496 {
497 return endOfLabels(data_,offset_,false);
498 };
499
500 static const auto endOfLabelOpt = [](std::string_view data_,size_t offset_) -> size_t
501 {
502 size_t index=offset_;
503 if (index<data_.size() && data_[index]==' ') // skip over optional spaces
504 {
505 index++;
506 while (index<data_.size() && data_[index]==' ') index++;
507 }
508 if (index<data_.size() && data_[index]=='{') // find matching '}'
509 {
510 index++;
511 char c = 0;
512 while (index<data_.size() && (c=data_[index])!='}' && c!='\\' && c!='@' && c!='\n') index++;
513 if (index==data_.size() || data_[index]!='}') return 0; // invalid option
514 offset_=index+1; // part after {...} is the option
515 }
516 return endOfLabel(data_,offset_);
517 };
518
519 static const auto endOfParam = [](std::string_view data_,size_t offset_) -> size_t
520 {
521 size_t index=offset_;
522 if (index<data_.size() && data_[index]==' ') // skip over optional spaces
523 {
524 index++;
525 while (index<data_.size() && data_[index]==' ') index++;
526 }
527 if (index<data_.size() && data_[index]=='[') // find matching ']'
528 {
529 index++;
530 char c = 0;
531 while (index<data_.size() && (c=data_[index])!=']' && c!='\n') index++;
532 if (index==data_.size() || data_[index]!=']') return 0; // invalid parameter
533 offset_=index+1; // part after [...] is the parameter name
534 }
535 return endOfLabels(data_,offset_,true);
536 };
537
538 static const auto endOfRetVal = [](std::string_view data_,size_t offset_) -> size_t
539 {
540 return endOfLabels(data_,offset_,true);
541 };
542
543 static const auto endOfFuncLike = [](std::string_view data_,size_t offset_,bool allowSpaces) -> size_t
544 {
545 if (offset_<data_.size() && data_[offset_]==' ') // we expect a space before the name
546 {
547 char c=0;
548 offset_++;
549 // skip over spaces
550 while (offset_<data_.size() && data_[offset_]==' ')
551 {
552 offset_++;
553 }
554 // skip over name (and optionally type)
555 while (offset_<data_.size() && (c=data_[offset_])!='\n' && (allowSpaces || c!=' ') && c!='(')
556 {
557 if (literal_at(data_.substr(offset_),"\\ilinebr ")) break;
558 offset_++;
559 }
560 if (c=='(') // find the end of the function
561 {
562 int count=1;
563 offset_++;
564 while (offset_<data_.size() && (c=data_[offset_++]))
565 {
566 if (c=='(') count++;
567 else if (c==')') count--;
568 if (count==0) return offset_;
569 }
570 }
571 return offset_;
572 }
573 return 0;
574 };
575
576 static const auto endOfFunc = [](std::string_view data_,size_t offset_) -> size_t
577 {
578 return endOfFuncLike(data_,offset_,true);
579 };
580
581 static const auto endOfGuard = [](std::string_view data_,size_t offset_) -> size_t
582 {
583 return endOfFuncLike(data_,offset_,false);
584 };
585
586 static const std::unordered_map<std::string,EndCmdFunc> cmdNames =
587 {
588 { "a", endOfLabel },
589 { "addindex", endOfLine },
590 { "addtogroup", endOfLabel },
591 { "anchor", endOfLabel },
592 { "b", endOfLabel },
593 { "c", endOfLabel },
594 { "category", endOfLine },
595 { "cite", endOfLabel },
596 { "class", endOfLine },
597 { "concept", endOfLine },
598 { "copybrief", endOfFunc },
599 { "copydetails", endOfFunc },
600 { "copydoc", endOfFunc },
601 { "def", endOfFunc },
602 { "defgroup", endOfLabel },
603 { "diafile", endOfLine },
604 { "dir", endOfLine },
605 { "dockbookinclude",endOfLine },
606 { "dontinclude", endOfLine },
607 { "dotfile", endOfLine },
608 { "e", endOfLabel },
609 { "elseif", endOfGuard },
610 { "em", endOfLabel },
611 { "emoji", endOfLabel },
612 { "enum", endOfLabel },
613 { "example", endOfLine },
614 { "exception", endOfLine },
615 { "extends", endOfLabel },
616 { "file", endOfLine },
617 { "fn", endOfFunc },
618 { "headerfile", endOfLine },
619 { "htmlinclude", endOfLine },
620 { "ianchor", endOfLabelOpt },
621 { "idlexcept", endOfLine },
622 { "if", endOfGuard },
623 { "ifnot", endOfGuard },
624 { "image", endOfLine },
625 { "implements", endOfLine },
626 { "include", endOfLine },
627 { "includedoc", endOfLine },
628 { "includelineno", endOfLine },
629 { "ingroup", endOfLabel },
630 { "interface", endOfLine },
631 { "latexinclude", endOfLine },
632 { "maninclude", endOfLine },
633 { "memberof", endOfLabel },
634 { "mscfile", endOfLine },
635 { "namespace", endOfLabel },
636 { "noop", endOfLine },
637 { "overload", endOfLine },
638 { "p", endOfLabel },
639 { "package", endOfLabel },
640 { "page", endOfLabel },
641 { "paragraph", endOfLabel },
642 { "param", endOfParam },
643 { "property", endOfLine },
644 { "protocol", endOfLine },
645 { "qualifier", endOfLine },
646 { "ref", endOfLabel },
647 { "refitem", endOfLine },
648 { "related", endOfLabel },
649 { "relatedalso", endOfLabel },
650 { "relates", endOfLabel },
651 { "relatesalso", endOfLabel },
652 { "retval", endOfRetVal},
653 { "rtfinclude", endOfLine },
654 { "section", endOfLabel },
655 { "skip", endOfLine },
656 { "skipline", endOfLine },
657 { "snippet", endOfLine },
658 { "snippetdoc", endOfLine },
659 { "snippetlineno", endOfLine },
660 { "struct", endOfLine },
661 { "subpage", endOfLabel },
662 { "subparagraph", endOfLabel },
663 { "subsubparagraph",endOfLabel },
664 { "subsection", endOfLabel },
665 { "subsubsection", endOfLabel },
666 { "throw", endOfLabel },
667 { "throws", endOfLabel },
668 { "tparam", endOfLabel },
669 { "typedef", endOfLine },
670 { "plantumlfile", endOfLine },
671 { "union", endOfLine },
672 { "until", endOfLine },
673 { "var", endOfLine },
674 { "verbinclude", endOfLine },
675 { "weakgroup", endOfLabel },
676 { "xmlinclude", endOfLine },
677 { "xrefitem", endOfLabel }
678 };
679
680 bool isEscaped = offset>0 && (data.data()[-1]=='\\' || data.data()[-1]=='@');
681 if (isEscaped) return 0;
682
683 const size_t size = data.size();
684 size_t end=1;
685 while (end<size && (data[end]>='a' && data[end]<='z')) end++;
686 if (end==1) return 0;
687 std::string cmdName(data.substr(1,end-1));
688 size_t result=0;
689 auto it = cmdNames.find(cmdName);
690 if (it!=cmdNames.end()) // command with parameters that should be ignored by markdown
691 {
692 // find the end of the parameters
693 result = it->second(data,end);
694 }
695 AUTO_TRACE_EXIT("result={}",result);
696 return result;
697}

References AUTO_TRACE, AUTO_TRACE_EXIT, end, literal_at and Trace::trunc.

Referenced by processSpecialCommand.

processBlocks()

QCString Markdown::Private::processBlocks (std::string_view data, size_t indent)

Definition at line 133 of file markdown.cpp.

3232QCString Markdown::Private::processBlocks(std::string_view data,const size_t indent)
3233{
3234 AUTO_TRACE("data='{}' indent={}",Trace::trunc(data),indent);
3235 out.clear();
3236 size_t pi = std::string::npos;
3237 QCString id,link,title;
3238
3239#if 0 // commented out, since starting with a comment block is probably a usage error
3240 // see also http://stackoverflow.com/q/20478611/784672
3241
3242 // special case when the documentation starts with a code block
3243 // since the first line is skipped when looking for a code block later on.
3244 if (end>codeBlockIndent && isCodeBlock(data,0,end,blockIndent))
3245 {
3246 i=writeCodeBlock(out,data,size,blockIndent);
3247 end=i+1;
3248 pi=-1;
3249 }
3250#endif
3251
3252 size_t currentIndent = indent;
3253 size_t listIndent = indent;
3254 bool insideList = false;
3255 bool newBlock = false;
3256 // process each line
3257 size_t i=0;
3258 while (i<data.size())
3259 {
3260 size_t end = findEndOfLine(data,i);
3261 // line is now found at [i..end)
3262
3263 size_t lineIndent=0;
3264 int level = 0;
3265 while (lineIndent<end && data[i+lineIndent]==' ') lineIndent++;
3266 //printf("** lineIndent=%d line=(%s)\n",lineIndent,qPrint(QCString(data+i).left(end-i)));
3267
3268 if (newBlock)
3269 {
3270 //printf("** end of block\n");
3271 if (insideList && lineIndent<currentIndent) // end of list
3272 {
3273 //printf("** end of list\n");
3274 currentIndent = indent;
3275 insideList = false;
3276 }
3277 newBlock = false;
3278 }
3279
3280 if ((listIndent=isListMarker(data.substr(i,end-i)))) // see if we need to increase the indent level
3281 {
3282 if (listIndent<currentIndent+4)
3283 {
3284 //printf("** start of list\n");
3285 insideList = true;
3286 currentIndent = listIndent;
3287 }
3288 }
3289 else if (isEndOfList(data.substr(i,end-i)))
3290 {
3291 //printf("** end of list\n");
3292 insideList = false;
3293 currentIndent = listIndent;
3294 }
3295 else if (isEmptyLine(data.substr(i,end-i)))
3296 {
3297 //printf("** new block\n");
3298 newBlock = true;
3299 }
3300
3301 //printf("indent=%d listIndent=%d blockIndent=%d\n",indent,listIndent,blockIndent);
3302
3303 //printf("findEndOfLine: pi=%d i=%d end=%d\n",pi,i,end);
3304
3305 if (pi!=std::string::npos)
3306 {
3307 size_t blockStart=0, blockEnd=0, blockOffset=0;
3308 QCString lang;
3309 size_t blockIndent = currentIndent;
3310 size_t ref = 0;
3311 //printf("isHeaderLine(%s)=%d\n",QCString(data+i).left(size-i).data(),level);
3312 QCString endBlockName;
3313 if (data[i]=='@' || data[i]=='\\') endBlockName = isBlockCommand(data.substr(i),i);
3314 if (!endBlockName.isEmpty())
3315 {
3316 // handle previous line
3317 if (isLinkRef(data.substr(pi,i-pi),id,link,title))
3318 {
3319 linkRefs.emplace(id.lower().str(),LinkRef(link,title));
3320 }
3321 else
3322 {
3323 writeOneLineHeaderOrRuler(data.substr(pi,i-pi));
3324 }
3325 out+=data[i];
3326 i++;
3327 size_t l = endBlockName.length();
3328 while (i+l<data.size())
3329 {
3330 if ((data[i]=='\\' || data[i]=='@') && // command
3331 data[i-1]!='\\' && data[i-1]!='@') // not escaped
3332 {
3333 if (qstrncmp(&data[i+1],endBlockName.data(),l)==0)
3334 {
3335 out+=data[i];
3336 out+=endBlockName;
3337 i+=l+1;
3338 break;
3339 }
3340 }
3341 out+=data[i];
3342 i++;
3343 }
3344 }
3345 else if ((level=isHeaderline(data.substr(i),TRUE))>0)
3346 {
3347 //printf("Found header at %d-%d\n",i,end);
3348 while (pi<data.size() && data[pi]==' ') pi++;
3349 QCString header = data.substr(pi,i-pi-1);
3350 id = extractTitleId(header, level);
3351 //printf("header='%s' is='%s'\n",qPrint(header),qPrint(id));
3352 if (!header.isEmpty())
3353 {
3354 if (!id.isEmpty())
3355 {
3356 out+=level==1?"@section ":"@subsection ";
3357 out+=id;
3358 out+=" ";
3359 out+=header;
3360 out+="\n\n";
3361 }
3362 else
3363 {
3364 out+=level==1?"<h1>":"<h2>";
3365 out+=header;
3366 out+=level==1?"\n</h1>\n":"\n</h2>\n";
3367 }
3368 }
3369 else
3370 {
3371 out+="\n<hr>\n";
3372 }
3373 pi=std::string::npos;
3374 i=end;
3375 end=i+1;
3376 continue;
3377 }
3378 else if ((ref=isLinkRef(data.substr(pi),id,link,title)))
3379 {
3380 //printf("found link ref: id='%s' link='%s' title='%s'\n",
3381 // qPrint(id),qPrint(link),qPrint(title));
3382 linkRefs.emplace(id.lower().str(),LinkRef(link,title));
3383 i=ref+pi;
3384 end=i+1;
3385 }
3386 else if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset))
3387 {
3388 //printf("Found FencedCodeBlock lang='%s' start=%d end=%d code={%s}\n",
3389 // qPrint(lang),blockStart,blockEnd,QCString(data+pi+blockStart).left(blockEnd-blockStart).data());
3390 writeFencedCodeBlock(data.substr(pi),lang.view(),blockStart,blockEnd);
3391 i=pi+blockOffset;
3392 pi=std::string::npos;
3393 end=i+1;
3394 continue;
3395 }
3396 else if (isCodeBlock(data.substr(i,end-i),i,blockIndent))
3397 {
3398 // skip previous line (it is empty anyway)
3399 i+=writeCodeBlock(data.substr(i),blockIndent);
3400 pi=std::string::npos;
3401 end=i+1;
3402 continue;
3403 }
3404 else if (isTableBlock(data.substr(pi)))
3405 {
3406 i=pi+writeTableBlock(data.substr(pi));
3407 pi=std::string::npos;
3408 end=i+1;
3409 continue;
3410 }
3411 else
3412 {
3413 writeOneLineHeaderOrRuler(data.substr(pi,i-pi));
3414 }
3415 }
3416 pi=i;
3417 i=end;
3418 }
3419 //printf("last line %d size=%d\n",i,size);
3420 if (pi!=std::string::npos && pi<data.size()) // deal with the last line
3421 {
3422 if (isLinkRef(data.substr(pi),id,link,title))
3423 {
3424 //printf("found link ref: id='%s' link='%s' title='%s'\n",
3425 // qPrint(id),qPrint(link),qPrint(title));
3426 linkRefs.emplace(id.lower().str(),LinkRef(link,title));
3427 }
3428 else
3429 {
3430 writeOneLineHeaderOrRuler(data.substr(pi));
3431 }
3432 }
3433
3434 return out;
3435}

References AUTO_TRACE, codeBlockIndent, QCString::data, end, extractTitleId, findEndOfLine, isBlockCommand, isCodeBlock, QCString::isEmpty, isEmptyLine, isEndOfList, isFencedCodeBlock, isHeaderline, isLinkRef, isListMarker, isTableBlock, QCString::length, linkRefs, out, qstrncmp, TRUE, Trace::trunc, QCString::view, writeCodeBlock, writeFencedCodeBlock, writeOneLineHeaderOrRuler and writeTableBlock.

processCodeSpan()

int Markdown::Private::processCodeSpan (std::string_view data, size_t offset)

` parsing a code span (assuming codespan != 0)

Definition at line 145 of file markdown.cpp.

1629int Markdown::Private::processCodeSpan(std::string_view data,size_t)
1630{
1631 AUTO_TRACE("data='{}'",Trace::trunc(data));
1632 const size_t size = data.size();
1633
1634 /* counting the number of backticks in the delimiter */
1635 size_t nb=0, end=0;
1636 while (nb<size && data[nb]=='`')
1637 {
1638 nb++;
1639 }
1640
1641 /* finding the next delimiter */
1642 size_t i = 0;
1643 char pc = '`';
1644 for (end=nb; end<size && i<nb; end++)
1645 {
1646 if (data[end]=='`')
1647 {
1648 i++;
1649 }
1650 else if (data[end]=='\n')
1651 {
1652 // consecutive newlines
1653 if (pc == '\n') return 0;
1654 pc = '\n';
1655 i = 0;
1656 }
1657 else if (data[end]=='\'' && nb==1 && (end==size-1 || (end+1<size && !isIdChar(data[end+1]))))
1658 { // look for quoted strings like 'some word', but skip strings like `it's cool`
1659 out+="&lsquo;";
1660 out+=data.substr(nb,end-nb);
1661 out+="&rsquo;";
1662 return static_cast<int>(end+1);
1663 }
1664 else
1665 {
1666 if (data[end]!=' ') pc = data[end];
1667 i=0;
1668 }
1669 }
1670 if (i < nb && end >= size)
1671 {
1672 return 0; // no matching delimiter
1673 }
1674
1675 //printf("found code span '%s'\n",qPrint(QCString(data+f_begin).left(f_end-f_begin)));
1676
1677 /* real code span */
1678 if (nb+nb < end)
1679 {
1680 QCString codeFragment = data.substr(nb, end-nb-nb);
1681 out+="<tt>";
1682 out+=escapeSpecialChars(codeFragment);
1683 out+="</tt>";
1684 }
1685 AUTO_TRACE_EXIT("result={}",end);
1686 return static_cast<int>(end);
1687}

References AUTO_TRACE, AUTO_TRACE_EXIT, end, escapeSpecialChars, isIdChar, out and Trace::trunc.

processEmphasis()

int Markdown::Private::processEmphasis (std::string_view data, size_t offset)

Definition at line 139 of file markdown.cpp.

1105int Markdown::Private::processEmphasis(std::string_view data,size_t offset)
1106{
1107 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
1108 const size_t size = data.size();
1109
1110 if ((offset>0 && !isOpenEmphChar(data.data()[-1])) || // invalid char before * or _
1111 (size>1 && data[0]!=data[1] && !(isIdChar(data[1]) || extraChar(data[1]))) || // invalid char after * or _
1112 (size>2 && data[0]==data[1] && !(isIdChar(data[2]) || extraChar(data[2])))) // invalid char after ** or __
1113 {
1114 AUTO_TRACE_EXIT("invalid surrounding characters");
1115 return 0;
1116 }
1117
1118 char c = data[0];
1119 int ret = 0;
1120 if (size>2 && c!='~' && data[1]!=c) // _bla or *bla
1121 {
1122 // whitespace cannot follow an opening emphasis
1123 if (data[1]==' ' || data[1]=='\n' ||
1124 (ret = processEmphasis1(data.substr(1), c)) == 0)
1125 {
1126 return 0;
1127 }
1128 AUTO_TRACE_EXIT("result={}",ret+1);
1129 return ret+1;
1130 }
1131 if (size>3 && data[1]==c && data[2]!=c) // __bla or **bla
1132 {
1133 if (data[2]==' ' || data[2]=='\n' ||
1134 (ret = processEmphasis2(data.substr(2), c)) == 0)
1135 {
1136 return 0;
1137 }
1138 AUTO_TRACE_EXIT("result={}",ret+2);
1139 return ret+2;
1140 }
1141 if (size>4 && c!='~' && data[1]==c && data[2]==c && data[3]!=c) // ___bla or ***bla
1142 {
1143 if (data[3]==' ' || data[3]=='\n' ||
1144 (ret = processEmphasis3(data.substr(3), c)) == 0)
1145 {
1146 return 0;
1147 }
1148 AUTO_TRACE_EXIT("result={}",ret+3);
1149 return ret+3;
1150 }
1151 return 0;
1152}

References AUTO_TRACE, AUTO_TRACE_EXIT, extraChar, isIdChar, isOpenEmphChar, processEmphasis1, processEmphasis2, processEmphasis3 and Trace::trunc.

processEmphasis1()

int Markdown::Private::processEmphasis1 (std::string_view data, char c)

process single emphasis

Definition at line 140 of file markdown.cpp.

815int Markdown::Private::processEmphasis1(std::string_view data, char c)
816{
817 AUTO_TRACE("data='{}' c={}",Trace::trunc(data),c);
818 size_t i = 0;
819 const size_t size = data.size();
820
821 /* skipping one symbol if coming from emph3 */
822 if (size>1 && data[0]==c && data[1]==c) { i=1; }
823
824 while (i<size)
825 {
826 size_t len = findEmphasisChar(data.substr(i), c, 1);
827 if (len==0) { return 0; }
828 i+=len;
829 if (i>=size) { return 0; }
830
831 if (i+1<size && data[i+1]==c)
832 {
833 i++;
834 continue;
835 }
836 if (data[i]==c && data[i-1]!=' ' && data[i-1]!='\n')
837 {
838 out+="<em>";
839 processInline(data.substr(0,i));
840 out+="</em>";
841 AUTO_TRACE_EXIT("result={}",i+1);
842 return static_cast<int>(i+1);
843 }
844 }
845 return 0;
846}

References AUTO_TRACE, AUTO_TRACE_EXIT, findEmphasisChar, out, processInline and Trace::trunc.

Referenced by processEmphasis and processEmphasis3.

processEmphasis2()

int Markdown::Private::processEmphasis2 (std::string_view data, char c)

process double emphasis

Definition at line 141 of file markdown.cpp.

849int Markdown::Private::processEmphasis2(std::string_view data, char c)
850{
851 AUTO_TRACE("data='{}' c={}",Trace::trunc(data),c);
852 size_t i = 0;
853 const size_t size = data.size();
854
855 while (i<size)
856 {
857 size_t len = findEmphasisChar(data.substr(i), c, 2);
858 if (len==0)
859 {
860 return 0;
861 }
862 i += len;
863 if (i+1<size && data[i]==c && data[i+1]==c && i && data[i-1]!=' ' && data[i-1]!='\n')
864 {
865 if (c == '~') out+="<strike>";
866 else out+="<strong>";
867 processInline(data.substr(0,i));
868 if (c == '~') out+="</strike>";
869 else out+="</strong>";
870 AUTO_TRACE_EXIT("result={}",i+2);
871 return static_cast<int>(i+2);
872 }
873 i++;
874 }
875 return 0;
876}

References AUTO_TRACE, AUTO_TRACE_EXIT, findEmphasisChar, out, processInline and Trace::trunc.

Referenced by processEmphasis and processEmphasis3.

processEmphasis3()

int Markdown::Private::processEmphasis3 (std::string_view data, char c)

Parsing triple emphasis.

Finds the first closing tag, and delegates to the other emph

Definition at line 142 of file markdown.cpp.

881int Markdown::Private::processEmphasis3(std::string_view data,char c)
882{
883 AUTO_TRACE("data='{}' c={}",Trace::trunc(data),c);
884 size_t i = 0;
885 const size_t size = data.size();
886
887 while (i<size)
888 {
889 size_t len = findEmphasisChar(data.substr(i), c, 3);
890 if (len==0)
891 {
892 return 0;
893 }
894 i+=len;
895
896 /* skip whitespace preceded symbols */
897 if (data[i]!=c || data[i-1]==' ' || data[i-1]=='\n')
898 {
899 continue;
900 }
901
902 if (i+2<size && data[i+1]==c && data[i+2]==c)
903 {
904 out+="<em><strong>";
905 processInline(data.substr(0,i));
906 out+="</strong></em>";
907 AUTO_TRACE_EXIT("result={}",i+3);
908 return static_cast<int>(i+3);
909 }
910 else if (i+1<size && data[i+1]==c)
911 {
912 // double symbol found, handing over to emph1
913 len = processEmphasis1(std::string_view(data.data()-2, size+2), c);
914 if (len==0)
915 {
916 return 0;
917 }
918 else
919 {
920 AUTO_TRACE_EXIT("result={}",len-2);
921 return static_cast<int>(len - 2);
922 }
923 }
924 else
925 {
926 // single symbol found, handing over to emph2
927 len = processEmphasis2(std::string_view(data.data()-1, size+1), c);
928 if (len==0)
929 {
930 return 0;
931 }
932 else
933 {
934 AUTO_TRACE_EXIT("result={}",len-1);
935 return static_cast<int>(len - 1);
936 }
937 }
938 }
939 return 0;
940}

References AUTO_TRACE, AUTO_TRACE_EXIT, findEmphasisChar, out, processEmphasis1, processEmphasis2, processInline and Trace::trunc.

Referenced by processEmphasis.

processHtmlTag()

int Markdown::Private::processHtmlTag (std::string_view data, size_t offset)

Definition at line 138 of file markdown.cpp.

1099int Markdown::Private::processHtmlTag(std::string_view data,size_t offset)
1100{
1101 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
1102 return processHtmlTagWrite(data,offset,true);
1103}

References AUTO_TRACE, processHtmlTagWrite and Trace::trunc.

processHtmlTagWrite()

int Markdown::Private::processHtmlTagWrite (std::string_view data, size_t offset, bool doWrite)

Process a HTML tag.

Note that

..

are treated specially, in the sense that all code inside is written unprocessed

Definition at line 137 of file markdown.cpp.

1009int Markdown::Private::processHtmlTagWrite(std::string_view data,size_t offset,bool doWrite)
1010{
1011 AUTO_TRACE("data='{}' offset={} doWrite={}",Trace::trunc(data),offset,doWrite);
1012 if (offset>0 && data.data()[-1]=='\\') { return 0; } // escaped <
1013
1014 const size_t size = data.size();
1015
1016 // find the end of the html tag
1017 size_t i=1;
1018 size_t l=0;
1019 // compute length of the tag name
1020 while (i<size && isIdChar(data[i])) i++,l++;
1021 QCString tagName(data.substr(1,i-1));
1022 if (tagName.lower()=="pre") // found <pre> tag
1023 {
1024 bool insideStr=FALSE;
1025 while (i+6<size)
1026 {
1027 char c=data[i];
1028 if (!insideStr && c=='<') // potential start of html tag
1029 {
1030 if (data[i+1]=='/' &&
1031 tolower(data[i+2])=='p' && tolower(data[i+3])=='r' &&
1032 tolower(data[i+4])=='e' && tolower(data[i+5])=='>')
1033 { // found </pre> tag, copy from start to end of tag
1034 if (doWrite) out+=data.substr(0,i+6);
1035 //printf("found <pre>..</pre> [%d..%d]\n",0,i+6);
1036 AUTO_TRACE_EXIT("result={}",i+6);
1037 return static_cast<int>(i+6);
1038 }
1039 }
1040 else if (insideStr && c=='"')
1041 {
1042 if (data[i-1]!='\\') insideStr=FALSE;
1043 }
1044 else if (c=='"')
1045 {
1046 insideStr=TRUE;
1047 }
1048 i++;
1049 }
1050 }
1051 else // some other html tag
1052 {
1053 if (l>0 && i<size)
1054 {
1055 if (data[i]=='/' && i+1<size && data[i+1]=='>') // <bla/>
1056 {
1057 //printf("Found htmlTag={%s}\n",qPrint(QCString(data).left(i+2)));
1058 if (doWrite) out+=data.substr(0,i+2);
1059 AUTO_TRACE_EXIT("result={}",i+2);
1060 return static_cast<int>(i+2);
1061 }
1062 else if (data[i]=='>') // <bla>
1063 {
1064 //printf("Found htmlTag={%s}\n",qPrint(QCString(data).left(i+1)));
1065 if (doWrite) out+=data.substr(0,i+1);
1066 AUTO_TRACE_EXIT("result={}",i+1);
1067 return static_cast<int>(i+1);
1068 }
1069 else if (data[i]==' ') // <bla attr=...
1070 {
1071 i++;
1072 bool insideAttr=FALSE;
1073 while (i<size)
1074 {
1075 if (!insideAttr && data[i]=='"')
1076 {
1077 insideAttr=TRUE;
1078 }
1079 else if (data[i]=='"' && data[i-1]!='\\')
1080 {
1081 insideAttr=FALSE;
1082 }
1083 else if (!insideAttr && data[i]=='>') // found end of tag
1084 {
1085 //printf("Found htmlTag={%s}\n",qPrint(QCString(data).left(i+1)));
1086 if (doWrite) out+=data.substr(0,i+1);
1087 AUTO_TRACE_EXIT("result={}",i+1);
1088 return static_cast<int>(i+1);
1089 }
1090 i++;
1091 }
1092 }
1093 }
1094 }
1095 AUTO_TRACE_EXIT("not a valid html tag");
1096 return 0;
1097}

References AUTO_TRACE, AUTO_TRACE_EXIT, FALSE, isIdChar, QCString::lower, out, TRUE and Trace::trunc.

Referenced by findEndOfLine and processHtmlTag.

processInline()

void Markdown::Private::processInline (std::string_view data)

Definition at line 150 of file markdown.cpp.

1775void Markdown::Private::processInline(std::string_view data)
1776{
1777 AUTO_TRACE("data='{}'",Trace::trunc(data));
1778 size_t i=0;
1779 size_t end=0;
1780 Action_t action;
1781 const size_t size = data.size();
1782 while (i<size)
1783 {
1784 // skip over characters that do not trigger a specific action
1785 while (end<size && ((action=actions[static_cast<uint8_t>(data[end])])==nullptr)) end++;
1786 // and add them to the output
1787 out+=data.substr(i,end-i);
1788 if (end>=size) break;
1789 i=end;
1790 // do the action matching a special character at i
1791 int iend = action(data.substr(i),i);
1792 if (iend<=0) // update end
1793 {
1794 end=i+1-iend;
1795 }
1796 else // skip until end
1797 {
1798 i+=iend;
1799 end=i;
1800 }
1801 }
1802}

References actions, AUTO_TRACE, end, out and Trace::trunc.

Referenced by processEmphasis1, processEmphasis2, processEmphasis3 and processLink.

processLink()

int Markdown::Private::processLink (std::string_view data, size_t offset)

Definition at line 147 of file markdown.cpp.

1197int Markdown::Private::processLink(const std::string_view data,size_t offset)
1198{
1199 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
1200 const size_t size = data.size();
1201 QCString content;
1202 QCString link;
1203 QCString title;
1204 bool isImageLink = FALSE;
1205 bool isImageInline = FALSE;
1206 bool isToc = FALSE;
1207 size_t i=1;
1208 if (data[0]=='!')
1209 {
1210 isImageLink = TRUE;
1211 if (size<2 || data[1]!='[')
1212 {
1213 return 0;
1214 }
1215
1216 // if there is non-whitespace before the ![ within the scope of two new lines, the image
1217 // is considered inlined, i.e. the image is not preceded by an empty line
1218 int numNLsNeeded=2;
1219 int pos = -1;
1220 while (pos>=-static_cast<int>(offset) && numNLsNeeded>0)
1221 {
1222 if (data.data()[pos]=='\n') numNLsNeeded--;
1223 else if (data.data()[pos]!=' ') // found non-whitespace, stop searching
1224 {
1225 isImageInline=true;
1226 break;
1227 }
1228 pos--;
1229 }
1230 // skip '!['
1231 i++;
1232 }
1233 size_t contentStart=i;
1234 int level=1;
1235 int nlTotal=0;
1236 int nl=0;
1237 // find the matching ]
1238 while (i<size)
1239 {
1240 if (data[i-1]=='\\') // skip escaped characters
1241 {
1242 }
1243 else if (data[i]=='[')
1244 {
1245 level++;
1246 }
1247 else if (data[i]==']')
1248 {
1249 level--;
1250 if (level<=0) break;
1251 }
1252 else if (data[i]=='\n')
1253 {
1254 nl++;
1255 if (nl>1) { return 0; } // only allow one newline in the content
1256 }
1257 i++;
1258 }
1259 nlTotal += nl;
1260 nl = 0;
1261 if (i>=size) return 0; // premature end of comment -> no link
1262 size_t contentEnd=i;
1263 content = data.substr(contentStart,contentEnd-contentStart);
1264 //printf("processLink: content={%s}\n",qPrint(content));
1265 if (!isImageLink && content.isEmpty()) { return 0; } // no link text
1266 i++; // skip over ]
1267
1268 bool whiteSpace = false;
1269 // skip whitespace
1270 while (i<size && data[i]==' ') { whiteSpace = true; i++; }
1271 if (i<size && data[i]=='\n') // one newline allowed here
1272 {
1273 whiteSpace = true;
1274 i++;
1275 // skip more whitespace
1276 while (i<size && data[i]==' ') i++;
1277 }
1278 if (whiteSpace && i<size && (data[i]=='(' || data[i]=='[')) return 0;
1279
1280 bool explicitTitle=FALSE;
1281 if (i<size && data[i]=='(') // inline link
1282 {
1283 i++;
1284 while (i<size && data[i]==' ') i++;
1285 bool uriFormat=false;
1286 if (i<size && data[i]=='<') { i++; uriFormat=true; }
1287 size_t linkStart=i;
1288 int braceCount=1;
1289 while (i<size && data[i]!='\'' && data[i]!='"' && braceCount>0)
1290 {
1291 if (data[i]=='\n') // unexpected EOL
1292 {
1293 nl++;
1294 if (nl>1) { return 0; }
1295 }
1296 else if (data[i]=='(')
1297 {
1298 braceCount++;
1299 }
1300 else if (data[i]==')')
1301 {
1302 braceCount--;
1303 }
1304 if (braceCount>0)
1305 {
1306 i++;
1307 }
1308 }
1309 nlTotal += nl;
1310 nl = 0;
1311 if (i>=size || data[i]=='\n') { return 0; }
1312 link = data.substr(linkStart,i-linkStart);
1313 link = link.stripWhiteSpace();
1314 //printf("processLink: link={%s}\n",qPrint(link));
1315 if (link.isEmpty()) { return 0; }
1316 if (uriFormat && link.at(link.length()-1)=='>') link=link.left(link.length()-1);
1317
1318 // optional title
1319 if (data[i]=='\'' || data[i]=='"')
1320 {
1321 char c = data[i];
1322 i++;
1323 size_t titleStart=i;
1324 nl=0;
1325 while (i<size)
1326 {
1327 if (data[i]=='\n')
1328 {
1329 if (nl>1) { return 0; }
1330 nl++;
1331 }
1332 else if (data[i]=='\\') // escaped char in string
1333 {
1334 i++;
1335 }
1336 else if (data[i]==c)
1337 {
1338 i++;
1339 break;
1340 }
1341 i++;
1342 }
1343 if (i>=size)
1344 {
1345 return 0;
1346 }
1347 size_t titleEnd = i-1;
1348 // search back for closing marker
1349 while (titleEnd>titleStart && data[titleEnd]==' ') titleEnd--;
1350 if (data[titleEnd]==c) // found it
1351 {
1352 title = data.substr(titleStart,titleEnd-titleStart);
1353 explicitTitle=TRUE;
1354 while (i<size)
1355 {
1356 if (data[i]==' ')i++; // remove space after the closing quote and the closing bracket
1357 else if (data[i] == ')') break; // the end bracket
1358 else // illegal
1359 {
1360 return 0;
1361 }
1362 }
1363 }
1364 else
1365 {
1366 return 0;
1367 }
1368 }
1369 i++;
1370 }
1371 else if (i<size && data[i]=='[') // reference link
1372 {
1373 i++;
1374 size_t linkStart=i;
1375 nl=0;
1376 // find matching ]
1377 while (i<size && data[i]!=']')
1378 {
1379 if (data[i]=='\n')
1380 {
1381 nl++;
1382 if (nl>1) { return 0; }
1383 }
1384 i++;
1385 }
1386 if (i>=size) { return 0; }
1387 // extract link
1388 link = data.substr(linkStart,i-linkStart);
1389 //printf("processLink: link={%s}\n",qPrint(link));
1390 link = link.stripWhiteSpace();
1391 if (link.isEmpty()) // shortcut link
1392 {
1393 link=content;
1394 }
1395 // lookup reference
1396 QCString link_lower = link.lower();
1397 auto lr_it=linkRefs.find(link_lower.str());
1398 if (lr_it!=linkRefs.end()) // found it
1399 {
1400 link = lr_it->second.link;
1401 title = lr_it->second.title;
1402 //printf("processLink: ref: link={%s} title={%s}\n",qPrint(link),qPrint(title));
1403 }
1404 else // reference not found!
1405 {
1406 //printf("processLink: ref {%s} do not exist\n",link.qPrint(lower()));
1407 return 0;
1408 }
1409 i++;
1410 }
1411 else if (i<size && data[i]!=':' && !content.isEmpty()) // minimal link ref notation [some id]
1412 {
1413 QCString content_lower = content.lower();
1414 auto lr_it = linkRefs.find(content_lower.str());
1415 //printf("processLink: minimal link {%s} lr=%p",qPrint(content),lr);
1416 if (lr_it!=linkRefs.end()) // found it
1417 {
1418 link = lr_it->second.link;
1419 title = lr_it->second.title;
1420 explicitTitle=TRUE;
1421 i=contentEnd;
1422 }
1423 else if (content=="TOC")
1424 {
1425 isToc=TRUE;
1426 i=contentEnd;
1427 }
1428 else
1429 {
1430 return 0;
1431 }
1432 i++;
1433 }
1434 else
1435 {
1436 return 0;
1437 }
1438 nlTotal += nl;
1439
1440 // search for optional image attributes
1441 QCString attributes;
1442 if (isImageLink)
1443 {
1444 size_t j = i;
1445 // skip over whitespace
1446 while (j<size && data[j]==' ') { j++; }
1447 if (j<size && data[j]=='{') // we have attributes
1448 {
1449 i = j;
1450 // skip over '{'
1451 i++;
1452 size_t attributesStart=i;
1453 nl=0;
1454 // find the matching '}'
1455 while (i<size)
1456 {
1457 if (data[i-1]=='\\') // skip escaped characters
1458 {
1459 }
1460 else if (data[i]=='{')
1461 {
1462 level++;
1463 }
1464 else if (data[i]=='}')
1465 {
1466 level--;
1467 if (level<=0) break;
1468 }
1469 else if (data[i]=='\n')
1470 {
1471 nl++;
1472 if (nl>1) { return 0; } // only allow one newline in the content
1473 }
1474 i++;
1475 }
1476 nlTotal += nl;
1477 if (i>=size) return 0; // premature end of comment -> no attributes
1478 size_t attributesEnd=i;
1479 attributes = data.substr(attributesStart,attributesEnd-attributesStart);
1480 i++; // skip over '}'
1481 }
1482 if (!isImageInline)
1483 {
1484 // if there is non-whitespace after the image within the scope of two new lines, the image
1485 // is considered inlined, i.e. the image is not followed by an empty line
1486 int numNLsNeeded=2;
1487 size_t pos = i;
1488 while (pos<size && numNLsNeeded>0)
1489 {
1490 if (data[pos]=='\n') numNLsNeeded--;
1491 else if (data[pos]!=' ') // found non-whitespace, stop searching
1492 {
1493 isImageInline=true;
1494 break;
1495 }
1496 pos++;
1497 }
1498 }
1499 }
1500
1501 if (isToc) // special case for [TOC]
1502 {
1503 int toc_level = Config_getInt(TOC_INCLUDE_HEADINGS);
1504 if (toc_level>=SectionType::MinLevel && toc_level<=SectionType::MaxLevel)
1505 {
1506 out+="@tableofcontents{html:";
1507 out+=QCString().setNum(toc_level);
1508 out+="}";
1509 }
1510 }
1511 else if (isImageLink)
1512 {
1513 bool ambig = false;
1514 FileDef *fd=nullptr;
1515 if (link.find("@ref ")!=-1 || link.find("\\ref ")!=-1 ||
1517 // assume doxygen symbol link or local image link
1518 {
1519 // check if different handling is needed per format
1520 writeMarkdownImage("html", isImageInline, explicitTitle, title, content, link, attributes, fd);
1521 writeMarkdownImage("latex", isImageInline, explicitTitle, title, content, link, attributes, fd);
1522 writeMarkdownImage("rtf", isImageInline, explicitTitle, title, content, link, attributes, fd);
1523 writeMarkdownImage("docbook", isImageInline, explicitTitle, title, content, link, attributes, fd);
1524 writeMarkdownImage("xml", isImageInline, explicitTitle, title, content, link, attributes, fd);
1525 }
1526 else
1527 {
1528 out+="<img src=\"";
1529 out+=link;
1530 out+="\" alt=\"";
1531 out+=content;
1532 out+="\"";
1533 if (!title.isEmpty())
1534 {
1535 out+=" title=\"";
1536 out+=substitute(title.simplifyWhiteSpace(),"\"","&quot;");
1537 out+="\"";
1538 }
1539 out+="/>";
1540 }
1541 }
1542 else
1543 {
1545 int lp=-1;
1546 if ((lp=link.find("@ref "))!=-1 || (lp=link.find("\\ref "))!=-1 || (lang==SrcLangExt::Markdown && !isURL(link)))
1547 // assume doxygen symbol link
1548 {
1549 if (lp==-1) // link to markdown page
1550 {
1551 out+="@ref \"";
1552 if (!(Portable::isAbsolutePath(link) || isURL(link)))
1553 {
1554 FileInfo forg(link.str());
1555 if (forg.exists() && forg.isReadable())
1556 {
1557 link = forg.absFilePath();
1558 }
1559 else if (!(forg.exists() && forg.isReadable()))
1560 {
1561 FileInfo fi(fileName.str());
1562 QCString mdFile = fileName.left(fileName.length()-fi.fileName().length()) + link;
1563 FileInfo fmd(mdFile.str());
1564 if (fmd.exists() && fmd.isReadable())
1565 {
1566 link = fmd.absFilePath().data();
1567 }
1568 }
1569 }
1570 out+=link;
1571 out+="\"";
1572 }
1573 else
1574 {
1575 out+=link;
1576 }
1577 out+=" \"";
1578 if (explicitTitle && !title.isEmpty())
1579 {
1580 out+=substitute(title,"\"","&quot;");
1581 }
1582 else
1583 {
1584 processInline(std::string_view(substitute(content,"\"","&quot;").str()));
1585 }
1586 out+="\"";
1587 }
1588 else if ((lp=link.find('#'))!=-1 || link.find('/')!=-1 || link.find('.')!=-1)
1589 { // file/url link
1590 if (lp==0 || (lp>0 && !isURL(link) && Config_getEnum(MARKDOWN_ID_STYLE)==MARKDOWN_ID_STYLE_t::GITHUB))
1591 {
1592 out+="@ref \"";
1594 out+="\" \"";
1595 out+=substitute(content.simplifyWhiteSpace(),"\"","&quot;");
1596 out+="\"";
1597 }
1598 else
1599 {
1600 out+="<a href=\"";
1601 out+=link;
1602 out+="\"";
1603 for (int ii = 0; ii < nlTotal; ii++) out+="\n";
1604 if (!title.isEmpty())
1605 {
1606 out+=" title=\"";
1607 out+=substitute(title.simplifyWhiteSpace(),"\"","&quot;");
1608 out+="\"";
1609 }
1610 out+=" ";
1612 out+=">";
1613 content = content.simplifyWhiteSpace();
1614 processInline(std::string_view(content.str()));
1615 out+="</a>";
1616 }
1617 }
1618 else // avoid link to e.g. F[x](y)
1619 {
1620 //printf("no link for '%s'\n",qPrint(link));
1621 return 0;
1622 }
1623 }
1624 AUTO_TRACE_EXIT("result={}",i);
1625 return static_cast<int>(i);
1626}

References FileInfo::absFilePath, AnchorGenerator::addPrefixIfNeeded, QCString::at, AUTO_TRACE, AUTO_TRACE_EXIT, Config_getEnum, Config_getInt, FileInfo::exists, externalLinkTarget, FALSE, FileInfo::fileName, fileName, QCString::find, findFileDef, getLanguageFromFileName, Doxygen::imageNameLinkedMap, Portable::isAbsolutePath, QCString::isEmpty, FileInfo::isReadable, isURL, QCString::left, QCString::length, linkRefs, QCString::lower, SectionType::MaxLevel, QCString::mid, SectionType::MinLevel, out, processInline, QCString::setNum, QCString::simplifyWhiteSpace, QCString::str, QCString::stripWhiteSpace, substitute, TRUE, Trace::trunc and writeMarkdownImage.

processNmdash()

int Markdown::Private::processNmdash (std::string_view data, size_t offset)

Process ndash and mdashes.

Definition at line 143 of file markdown.cpp.

943int Markdown::Private::processNmdash(std::string_view data,size_t offset)
944{
945 AUTO_TRACE("data='{}' offset={}",Trace::trunc(data),offset);
946 const size_t size = data.size();
947 // precondition: data[0]=='-'
948 size_t i=1;
949 int count=1;
950 if (i<size && data[i]=='-') // found --
951 {
952 count++,i++;
953 }
954 if (i<size && data[i]=='-') // found ---
955 {
956 count++,i++;
957 }
958 if (i<size && data[i]=='-') // found ----
959 {
960 count++;
961 }
962 if (count>=2 && offset>=2 && literal_at(data.data()-2,"<!"))
963 { AUTO_TRACE_EXIT("result={}",1-count); return 1-count; } // start HTML comment
964 if (count==2 && size > 2 && data[2]=='>')
965 { return 0; } // end HTML comment
966 if (count==3 && size > 3 && data[3]=='>')
967 { return 0; } // end HTML comment
968 if (count==2 && (offset<8 || !literal_at(data.data()-8,"operator"))) // -- => ndash
969 {
970 out+="&ndash;";
971 AUTO_TRACE_EXIT("result=2");
972 return 2;
973 }
974 else if (count==3) // --- => ndash
975 {
976 out+="&mdash;";
977 AUTO_TRACE_EXIT("result=3");
978 return 3;
979 }
980 // not an ndash or mdash
981 return 0;
982}

References AUTO_TRACE, AUTO_TRACE_EXIT, literal_at, out and Trace::trunc.

processQuotations()

QCString Markdown::Private::processQuotations (std::string_view data, size_t refIndent)

Definition at line 132 of file markdown.cpp.

3073QCString Markdown::Private::processQuotations(std::string_view data,size_t refIndent)
3074{
3075 AUTO_TRACE("data='{}' refIndex='{}'",Trace::trunc(data),refIndent);
3076 out.clear();
3077 size_t i=0,end=0;
3078 size_t pi=std::string::npos;
3079 bool newBlock = false;
3080 bool insideList = false;
3081 size_t currentIndent = refIndent;
3082 size_t listIndent = refIndent;
3083 const size_t size = data.size();
3084 QCString lang;
3085 while (i<size)
3086 {
3087 end = findEndOfLine(data,i);
3088 // line is now found at [i..end)
3089
3090 size_t lineIndent=0;
3091 while (lineIndent<end && data[i+lineIndent]==' ') lineIndent++;
3092 //printf("** lineIndent=%d line=(%s)\n",lineIndent,qPrint(QCString(data+i).left(end-i)));
3093
3094 if (newBlock)
3095 {
3096 //printf("** end of block\n");
3097 if (insideList && lineIndent<currentIndent) // end of list
3098 {
3099 //printf("** end of list\n");
3100 currentIndent = refIndent;
3101 insideList = false;
3102 }
3103 newBlock = false;
3104 }
3105
3106 if ((listIndent=isListMarker(data.substr(i,end-i)))) // see if we need to increase the indent level
3107 {
3108 if (listIndent<currentIndent+4)
3109 {
3110 //printf("** start of list\n");
3111 insideList = true;
3112 currentIndent = listIndent;
3113 }
3114 }
3115 else if (isEndOfList(data.substr(i,end-i)))
3116 {
3117 //printf("** end of list\n");
3118 insideList = false;
3119 currentIndent = listIndent;
3120 }
3121 else if (isEmptyLine(data.substr(i,end-i)))
3122 {
3123 //printf("** new block\n");
3124 newBlock = true;
3125 }
3126 //printf("currentIndent=%d listIndent=%d refIndent=%d\n",currentIndent,listIndent,refIndent);
3127
3128 if (pi!=std::string::npos)
3129 {
3130 size_t blockStart=0, blockEnd=0, blockOffset=0;
3131 if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset))
3132 {
3133 auto addSpecialCommand = [&](const QCString &startCmd,const QCString &endCmd)
3134 {
3135 size_t cmdPos = pi+blockStart+1;
3136 QCString pl = data.substr(cmdPos,blockEnd-blockStart-1);
3137 size_t ii = 0;
3138 int nl = 1;
3139 // check for absence of start command, either @start<cmd>, or \\start<cmd>
3140 while (ii<pl.length() && qisspace(pl[ii]))
3141 {
3142 if (pl[ii]=='\n') nl++;
3143 ii++; // skip leading whitespace
3144 }
3145 bool addNewLines = false;
3146 if (ii+startCmd.length()>=pl.length() || // no room for start command
3147 (pl[ii]!='\\' && pl[ii]!='@') || // no @ or \ after whitespace
3148 qstrncmp(pl.data()+ii+1,startCmd.data(),startCmd.length())!=0) // no start command
3149 {
3150 // input: output:
3151 // ----------------------------------------------------
3152 // ```{plantuml} => @startuml
3153 // A->B A->B
3154 // ``` @enduml
3155 // ----------------------------------------------------
3156 pl = "@"+startCmd+"\n" + pl + "@"+endCmd;
3157 addNewLines = false;
3158 }
3159 else // we have a @start... command inside the code block
3160 {
3161 // input: output:
3162 // ----------------------------------------------------
3163 // ```{plantuml} \n
3164 // \n
3165 // @startuml => @startuml
3166 // A->B A->B
3167 // @enduml @enduml
3168 // ``` \n
3169 // ----------------------------------------------------
3170 addNewLines = true;
3171 }
3172 if (addNewLines) for (int j=0;j<nl;j++) out+='\n';
3173 processSpecialCommand(pl.view().substr(ii),ii);
3174 if (addNewLines) out+='\n';
3175 };
3176
3177 if (!Config_getString(PLANTUML_JAR_PATH).isEmpty() && lang=="plantuml")
3178 {
3179 addSpecialCommand("startuml","enduml");
3180 }
3181 else if (Config_getBool(HAVE_DOT) && lang=="dot")
3182 {
3183 addSpecialCommand("dot","enddot");
3184 }
3185 else if (lang=="msc") // msc is built-in
3186 {
3187 addSpecialCommand("msc","endmsc");
3188 }
3189 else // normal code block
3190 {
3191 writeFencedCodeBlock(data.substr(pi),lang.view(),blockStart,blockEnd);
3192 }
3193 i=pi+blockOffset;
3194 pi=std::string::npos;
3195 end=i+1;
3196 continue;
3197 }
3198 else if (isBlockQuote(data.substr(pi,i-pi),currentIndent))
3199 {
3200 i = pi+writeBlockQuote(data.substr(pi));
3201 pi=std::string::npos;
3202 end=i+1;
3203 continue;
3204 }
3205 else
3206 {
3207 //printf("quote out={%s}\n",QCString(data+pi).left(i-pi).data());
3208 out+=data.substr(pi,i-pi);
3209 }
3210 }
3211 pi=i;
3212 i=end;
3213 }
3214 if (pi!=std::string::npos && pi<size) // deal with the last line
3215 {
3216 if (isBlockQuote(data.substr(pi),currentIndent))
3217 {
3218 writeBlockQuote(data.substr(pi));
3219 }
3220 else
3221 {
3222 out+=data.substr(pi);
3223 }
3224 }
3225
3226 //printf("Process quotations\n---- input ----\n%s\n---- output ----\n%s\n------------\n",
3227 // qPrint(s),prv->out.get());
3228
3229 return out;
3230}

References AUTO_TRACE, Config_getBool, Config_getString, QCString::data, end, findEndOfLine, isBlockQuote, isEmptyLine, isEndOfList, isFencedCodeBlock, isListMarker, QCString::length, out, processSpecialCommand, qisspace, qstrncmp, Trace::trunc, QCString::view, writeBlockQuote and writeFencedCodeBlock.

processQuoted()

int Markdown::Private::processQuoted (std::string_view data, size_t offset)

Process quoted section "...", can contain one embedded newline.

Definition at line 144 of file markdown.cpp.

985int Markdown::Private::processQuoted(std::string_view data,size_t)
986{
987 AUTO_TRACE("data='{}'",Trace::trunc(data));
988 const size_t size = data.size();
989 size_t i=1;
990 int nl=0;
991 while (i<size && data[i]!='"' && nl<2)
992 {
993 if (data[i]=='\n') nl++;
994 i++;
995 }
996 if (i<size && data[i]=='"' && nl<2)
997 {
998 out+=data.substr(0,i+1);
999 AUTO_TRACE_EXIT("result={}",i+2);
1000 return static_cast<int>(i+1);
1001 }
1002 // not a quoted section
1003 return 0;
1004}

References AUTO_TRACE, AUTO_TRACE_EXIT, out and Trace::trunc.

processSpecialCommand()

int Markdown::Private::processSpecialCommand (std::string_view data, size_t offset)

Definition at line 146 of file markdown.cpp.

1702int Markdown::Private::processSpecialCommand(std::string_view data, size_t offset)
1703{
1704 AUTO_TRACE("{}",Trace::trunc(data));
1705 const size_t size = data.size();
1706 size_t i=1;
1707 QCString endBlockName = isBlockCommand(data,offset);
1708 if (!endBlockName.isEmpty())
1709 {
1710 AUTO_TRACE_ADD("endBlockName={}",endBlockName);
1711 size_t l = endBlockName.length();
1712 while (i+l<size)
1713 {
1714 if ((data[i]=='\\' || data[i]=='@') && // command
1715 data[i-1]!='\\' && data[i-1]!='@') // not escaped
1716 {
1717 if (qstrncmp(&data[i+1],endBlockName.data(),l)==0)
1718 {
1719 //printf("found end at %d\n",i);
1720 addStrEscapeUtf8Nbsp(data.substr(0,i+1+l));
1721 AUTO_TRACE_EXIT("result={}",i+1+l);
1722 return static_cast<int>(i+1+l);
1723 }
1724 }
1725 i++;
1726 }
1727 }
1728 size_t endPos = isSpecialCommand(data,offset);
1729 if (endPos>0)
1730 {
1731 out+=data.substr(0,endPos);
1732 return static_cast<int>(endPos);
1733 }
1734 if (size>1 && data[0]=='\\') // escaped characters
1735 {
1736 char c=data[1];
1737 if (c=='[' || c==']' || c=='*' || c=='(' || c==')' || c=='`' || c=='_')
1738 {
1739 out+=data[1];
1740 AUTO_TRACE_EXIT("2");
1741 return 2;
1742 }
1743 else if (c=='\\' || c=='@')
1744 {
1745 out+=data.substr(0,2);
1746 AUTO_TRACE_EXIT("2");
1747 return 2;
1748 }
1749 else if (c=='-' && size>3 && data[2]=='-' && data[3]=='-') // \---
1750 {
1751 out+=data.substr(1,3);
1752 AUTO_TRACE_EXIT("2");
1753 return 4;
1754 }
1755 else if (c=='-' && size>2 && data[2]=='-') // \--
1756 {
1757 out+=data.substr(1,2);
1758 AUTO_TRACE_EXIT("3");
1759 return 3;
1760 }
1761 }
1762 else if (size>1 && data[0]=='@') // escaped characters
1763 {
1764 char c=data[1];
1765 if (c=='\\' || c=='@')
1766 {
1767 out+=data.substr(0,2);
1768 AUTO_TRACE_EXIT("2");
1769 return 2;
1770 }
1771 }
1772 return 0;
1773}

References addStrEscapeUtf8Nbsp, AUTO_TRACE, AUTO_TRACE_ADD, AUTO_TRACE_EXIT, QCString::data, isBlockCommand, QCString::isEmpty, isSpecialCommand, QCString::length, out, qstrncmp and Trace::trunc.

Referenced by processQuotations.

writeBlockQuote()

size_t Markdown::Private::writeBlockQuote (std::string_view data)

Definition at line 161 of file markdown.cpp.

2758size_t Markdown::Private::writeBlockQuote(std::string_view data)
2759{
2760 AUTO_TRACE("data='{}'",Trace::trunc(data));
2761 size_t i=0;
2762 int curLevel=0;
2763 size_t end=0;
2764 const size_t size = data.size();
2765 std::string startCmd;
2766 int isGitHubAlert = false;
2767 int isGitHubFirst = false;
2768 while (i<size)
2769 {
2770 // find end of this line
2771 end=i+1;
2772 while (end<=size && data[end-1]!='\n') end++;
2773 size_t j=i;
2774 int level=0;
2775 size_t indent=i;
2776 // compute the quoting level
2777 while (j<end && (data[j]==' ' || data[j]=='>'))
2778 {
2779 if (data[j]=='>') { level++; indent=j+1; }
2780 else if (j>0 && data[j-1]=='>') indent=j+1;
2781 j++;
2782 }
2783 if (indent>0 && j>0 && data[j-1]=='>' &&
2784 !(j==size || data[j]=='\n')) // disqualify last > if not followed by space
2785 {
2786 indent--;
2787 level--;
2788 j--;
2789 }
2790 AUTO_TRACE_ADD("indent={} i={} j={} end={} level={} line={}",indent,i,j,end,level,Trace::trunc(&data[i]));
2791 if (level==0 && j<end-1 && !isListMarker(data.substr(j)) && !isHRuler(data.substr(j)))
2792 {
2793 level = curLevel; // lazy
2794 }
2795 if (level==1)
2796 {
2797 QCString txt = stripWhiteSpace(data.substr(indent,end-indent));
2798 auto it = g_quotationHeaderMap.find(txt.lower().str()); // TODO: in C++20 the std::string can be dropped
2799 if (it != g_quotationHeaderMap.end())
2800 {
2801 isGitHubAlert = true;
2802 isGitHubFirst = true;
2803 startCmd = it->second;
2804 }
2805 }
2806 if (level>curLevel) // quote level increased => add start markers
2807 {
2808 if (level!=1 || !isGitHubAlert) // normal block quote
2809 {
2810 for (int l=curLevel;l<level-1;l++)
2811 {
2812 out+="<blockquote>";
2813 }
2814 out += "<blockquote>&zwj;"; // empty blockquotes are also shown
2815 }
2816 else if (!startCmd.empty()) // GitHub style alert
2817 {
2818 out += startCmd + " ";
2819 }
2820 }
2821 else if (level<curLevel) // quote level decreased => add end markers
2822 {
2823 int decrLevel = curLevel;
2824 if (level==0 && isGitHubAlert)
2825 {
2826 decrLevel--;
2827 }
2828 for (int l=level;l<decrLevel;l++)
2829 {
2830 out += "</blockquote>\\ilinebr ";
2831 }
2832 }
2833 if (level==0)
2834 {
2835 curLevel=0;
2836 break; // end of quote block
2837 }
2838 // copy line without quotation marks
2839 if (curLevel!=0 || !isGitHubAlert)
2840 {
2841 std::string_view txt = data.substr(indent,end-indent);
2842 if (stripWhiteSpace(txt).empty() && !startCmd.empty())
2843 {
2844 if (!isGitHubFirst) out += "<br>";
2845 out += "<br>\n";
2846 }
2847 else
2848 {
2849 out += txt;
2850 }
2851 isGitHubFirst = false;
2852 }
2853 else // GitHub alert section
2854 {
2855 out+= "\n";
2856 }
2857 curLevel=level;
2858 // proceed with next line
2859 i=end;
2860 }
2861 // end of comment within blockquote => add end markers
2862 if (isGitHubAlert) // GitHub alert doesn't have a blockquote
2863 {
2864 curLevel--;
2865 }
2866 for (int l=0;l<curLevel;l++)
2867 {
2868 out+="</blockquote>";
2869 }
2870 AUTO_TRACE_EXIT("i={}",i);
2871 return i;
2872}

References AUTO_TRACE, AUTO_TRACE_ADD, AUTO_TRACE_EXIT, decrLevel, end, g_quotationHeaderMap, isHRuler, isListMarker, QCString::lower, out, QCString::str, stripWhiteSpace and Trace::trunc.

Referenced by processQuotations.

writeCodeBlock()

size_t Markdown::Private::writeCodeBlock (std::string_view data, size_t refIndent)

Definition at line 162 of file markdown.cpp.

2910size_t Markdown::Private::writeCodeBlock(std::string_view data,size_t refIndent)
2911{
2912 AUTO_TRACE("data='{}' refIndent={}",Trace::trunc(data),refIndent);
2913 const size_t size = data.size();
2914 size_t i=0;
2915 // no need for \ilinebr here as the previous line was empty and was skipped
2916 out+="@iverbatim\n";
2917 int emptyLines=0;
2918 std::string location;
2919 while (i<size)
2920 {
2921 // find end of this line
2922 size_t end=i+1;
2923 while (end<=size && data[end-1]!='\n') end++;
2924 size_t j=i;
2925 size_t indent=0;
2926 while (j<end && data[j]==' ') j++,indent++;
2927 //printf("j=%d end=%d indent=%d refIndent=%d tabSize=%d data={%s}\n",
2928 // j,end,indent,refIndent,Config_getInt(TAB_SIZE),qPrint(QCString(data+i).left(end-i-1)));
2929 if (j==end-1) // empty line
2930 {
2931 emptyLines++;
2932 i=end;
2933 }
2934 else if (indent>=refIndent+codeBlockIndent) // enough indent to continue the code block
2935 {
2936 while (emptyLines>0) // write skipped empty lines
2937 {
2938 // add empty line
2939 out+="\n";
2940 emptyLines--;
2941 }
2942 // add code line minus the indent
2943 size_t offset = i+refIndent+codeBlockIndent;
2944 std::string lineLoc;
2945 if (skipOverFileAndLineCommands(data,codeBlockIndent,offset,lineLoc))
2946 {
2947 location = lineLoc;
2948 }
2949 out+=data.substr(offset,end-offset);
2950 i=end;
2951 }
2952 else // end of code block
2953 {
2954 break;
2955 }
2956 }
2957 out+="@endiverbatim";
2958 if (!location.empty())
2959 {
2960 out+=location;
2961 }
2962 else
2963 {
2964 out+="\\ilinebr ";
2965 }
2966 while (emptyLines>0) // write skipped empty lines
2967 {
2968 // add empty line
2969 out+="\n";
2970 emptyLines--;
2971 }
2972 AUTO_TRACE_EXIT("i={}",i);
2973 return i;
2974}

References AUTO_TRACE, AUTO_TRACE_EXIT, codeBlockIndent, end, out, skipOverFileAndLineCommands and Trace::trunc.

Referenced by processBlocks.

writeFencedCodeBlock()

void Markdown::Private::writeFencedCodeBlock (std::string_view data, std::string_view lang, size_t blockStart, size_t blockEnd)

Definition at line 159 of file markdown.cpp.

3050void Markdown::Private::writeFencedCodeBlock(std::string_view data,std::string_view lang,
3051 size_t blockStart,size_t blockEnd)
3052{
3053 AUTO_TRACE("data='{}' lang={} blockStart={} blockEnd={}",Trace::trunc(data),lang,blockStart,blockEnd);
3054 if (!lang.empty() && lang[0]=='.') lang=lang.substr(1);
3055 const size_t size=data.size();
3056 size_t i=0;
3057 while (i<size && (data[i]==' ' || data[i]=='\t'))
3058 {
3059 out+=data[i++];
3060 blockStart--;
3061 blockEnd--;
3062 }
3063 out+="@icode";
3064 if (!lang.empty())
3065 {
3066 out+="{"+lang+"}";
3067 }
3068 out+=" ";
3069 addStrEscapeUtf8Nbsp(data.substr(blockStart+i,blockEnd-blockStart));
3070 out+="@endicode ";
3071}

References addStrEscapeUtf8Nbsp, AUTO_TRACE, out and Trace::trunc.

Referenced by processBlocks and processQuotations.

writeMarkdownImage()

void Markdown::Private::writeMarkdownImage (std::string_view fmt, bool inline_img, bool explicitTitle, const QCString & title, const QCString & content, const QCString & link, const QCString & attributes, const FileDef * fd)

Definition at line 151 of file markdown.cpp.

1155 std::string_view fmt, bool inline_img, bool explicitTitle,
1156 const QCString &title, const QCString &content,
1157 const QCString &link, const QCString &attrs,
1158 const FileDef *fd)
1159{
1160 AUTO_TRACE("fmt={} inline_img={} explicitTitle={} title={} content={} link={} attrs={}",
1161 fmt,inline_img,explicitTitle,Trace::trunc(title),Trace::trunc(content),link,attrs);
1162 QCString attributes = getFilteredImageAttributes(fmt, attrs);
1163 out+="@image";
1164 if (inline_img)
1165 {
1166 out+="{inline}";
1167 }
1168 out+=" ";
1169 out+=fmt;
1170 out+=" ";
1171 out+=link.mid(fd ? 0 : 5);
1172 if (!explicitTitle && !content.isEmpty())
1173 {
1174 out+=" \"";
1175 out+=escapeDoubleQuotes(content);
1176 out+="\"";
1177 }
1178 else if ((content.isEmpty() || explicitTitle) && !title.isEmpty())
1179 {
1180 out+=" \"";
1181 out+=escapeDoubleQuotes(title);
1182 out+="\"";
1183 }
1184 else
1185 {
1186 out+=" ";// so the line break will not be part of the image name
1187 }
1188 if (!attributes.isEmpty())
1189 {
1190 out+=" ";
1191 out+=attributes;
1192 out+=" ";
1193 }
1194 out+="\\ilinebr ";
1195}

References AUTO_TRACE, escapeDoubleQuotes, getFilteredImageAttributes, QCString::isEmpty, QCString::mid, out and Trace::trunc.

Referenced by processLink.

writeOneLineHeaderOrRuler()

void Markdown::Private::writeOneLineHeaderOrRuler (std::string_view data)

Definition at line 158 of file markdown.cpp.

2699{
2700 AUTO_TRACE("data='{}'",Trace::trunc(data));
2701 int level=0;
2702 QCString header;
2703 QCString id;
2704 if (isHRuler(data))
2705 {
2706 out+="<hr>\n";
2707 }
2708 else if ((level=isAtxHeader(data,header,id,TRUE)))
2709 {
2710 QCString hTag;
2711 if (!id.isEmpty())
2712 {
2713 switch (level)
2714 {
2715 case SectionType::Section: out+="@section "; break;
2716 case SectionType::Subsection: out+="@subsection "; break;
2717 case SectionType::Subsubsection: out+="@subsubsection "; break;
2718 case SectionType::Paragraph: out+="@paragraph "; break;
2719 case SectionType::Subparagraph: out+="@subparagraph "; break;
2720 case SectionType::Subsubparagraph: out+="@subsubparagraph "; break;
2721 }
2722 out+=id;
2723 out+=" ";
2724 out+=header;
2725 out+="\n";
2726 }
2727 else
2728 {
2729 hTag.sprintf("h%d",level);
2730 out+="<"+hTag+">";
2731 out+=header;
2732 out+="</"+hTag+">\n";
2733 }
2734 }
2735 else if (data.size()>0) // nothing interesting -> just output the line
2736 {
2737 size_t tmpSize = data.size();
2738 if (data[data.size()-1] == '\n') tmpSize--;
2739 out+=data.substr(0,tmpSize);
2740
2741 if (hasLineBreak(data))
2742 {
2743 out+="\\ilinebr<br>";
2744 }
2745 if (tmpSize != data.size()) out+='\n';
2746 }
2747}

References AUTO_TRACE, hasLineBreak, isAtxHeader, isHRuler, out, SectionType::Paragraph, SectionType::Section, QCString::sprintf, SectionType::Subparagraph, SectionType::Subsection, SectionType::Subsubparagraph, SectionType::Subsubsection, TRUE and Trace::trunc.

Referenced by processBlocks.

writeTableBlock()

size_t Markdown::Private::writeTableBlock (std::string_view data)

Definition at line 163 of file markdown.cpp.

2479size_t Markdown::Private::writeTableBlock(std::string_view data)
2480{
2481 AUTO_TRACE("data='{}'",Trace::trunc(data));
2482 const size_t size = data.size();
2483
2484 size_t columns=0, start=0, end=0;
2485 size_t i = findTableColumns(data,start,end,columns);
2486 size_t headerStart = start;
2487 size_t headerEnd = end;
2488
2489 // read cell alignments
2490 size_t cc = 0;
2491 size_t ret = findTableColumns(data.substr(i),start,end,cc);
2492 size_t k=0;
2493 std::vector<int> columnAlignment(columns);
2494
2495 bool leftMarker=false, rightMarker=false, startFound=false;
2496 size_t j=start+i;
2497 while (j<=end+i)
2498 {
2499 if (!startFound)
2500 {
2501 if (data[j]==':') { leftMarker=TRUE; startFound=TRUE; }
2502 if (data[j]=='-') startFound=TRUE;
2503 //printf(" data[%d]=%c startFound=%d\n",j,data[j],startFound);
2504 }
2505 if (data[j]=='-') rightMarker=FALSE;
2506 else if (data[j]==':') rightMarker=TRUE;
2507 if (j<=end+i && (data[j]=='|' && (j==0 || data[j-1]!='\\')))
2508 {
2509 if (k<columns)
2510 {
2511 columnAlignment[k] = markersToAlignment(leftMarker,rightMarker);
2512 //printf("column[%d] alignment=%d\n",k,columnAlignment[k]);
2513 leftMarker=FALSE;
2514 rightMarker=FALSE;
2515 startFound=FALSE;
2516 }
2517 k++;
2518 }
2519 j++;
2520 }
2521 if (k<columns)
2522 {
2523 columnAlignment[k] = markersToAlignment(leftMarker,rightMarker);
2524 //printf("column[%d] alignment=%d\n",k,columnAlignment[k]);
2525 }
2526 // proceed to next line
2527 i+=ret;
2528
2529 // Store the table cell information by row then column. This
2530 // allows us to handle row spanning.
2531 std::vector<std::vector<TableCell> > tableContents;
2532
2533 size_t m = headerStart;
2534 std::vector<TableCell> headerContents(columns);
2535 for (k=0;k<columns;k++)
2536 {
2537 while (m<=headerEnd && (data[m]!='|' || (m>0 && data[m-1]=='\\')))
2538 {
2539 headerContents[k].cellText += data[m++];
2540 }
2541 m++;
2542 // do the column span test before stripping white space
2543 // || is spanning columns, | | is not
2544 headerContents[k].colSpan = headerContents[k].cellText.isEmpty();
2545 headerContents[k].cellText = headerContents[k].cellText.stripWhiteSpace();
2546 }
2547 tableContents.push_back(headerContents);
2548
2549 // write table cells
2550 while (i<size)
2551 {
2552 ret = findTableColumns(data.substr(i),start,end,cc);
2553 if (cc!=columns) break; // end of table
2554
2555 j=start+i;
2556 k=0;
2557 std::vector<TableCell> rowContents(columns);
2558 while (j<=end+i)
2559 {
2560 if (j<=end+i && (data[j]=='|' && (j==0 || data[j-1]!='\\')))
2561 {
2562 // do the column span test before stripping white space
2563 // || is spanning columns, | | is not
2564 rowContents[k].colSpan = rowContents[k].cellText.isEmpty();
2565 rowContents[k].cellText = rowContents[k].cellText.stripWhiteSpace();
2566 k++;
2567 } // if (j<=end+i && (data[j]=='|' && (j==0 || data[j-1]!='\\')))
2568 else
2569 {
2570 rowContents[k].cellText += data[j];
2571 } // else { if (j<=end+i && (data[j]=='|' && (j==0 || data[j-1]!='\\'))) }
2572 j++;
2573 } // while (j<=end+i)
2574 // do the column span test before stripping white space
2575 // || is spanning columns, | | is not
2576 rowContents[k].colSpan = rowContents[k].cellText.isEmpty();
2577 rowContents[k].cellText = rowContents[k].cellText.stripWhiteSpace();
2578 tableContents.push_back(rowContents);
2579
2580 // proceed to next line
2581 i+=ret;
2582 }
2583
2584 out+="<table class=\"markdownTable\">";
2585 QCString cellTag("th"), cellClass("class=\"markdownTableHead");
2586 for (size_t row = 0; row < tableContents.size(); row++)
2587 {
2588 if (row)
2589 {
2590 if (row % 2)
2591 {
2592 out+="\n<tr class=\"markdownTableRowOdd\">";
2593 }
2594 else
2595 {
2596 out+="\n<tr class=\"markdownTableRowEven\">";
2597 }
2598 }
2599 else
2600 {
2601 out+="\n <tr class=\"markdownTableHead\">";
2602 }
2603 for (size_t c = 0; c < columns; c++)
2604 {
2605 // save the cell text for use after column span computation
2606 QCString cellText(tableContents[row][c].cellText);
2607
2608 // Row span handling. Spanning rows will contain a caret ('^').
2609 // If the current cell contains just a caret, this is part of an
2610 // earlier row's span and the cell should not be added to the
2611 // output.
2612 if (tableContents[row][c].cellText == "^")
2613 {
2614 continue;
2615 }
2616 if (tableContents[row][c].colSpan)
2617 {
2618 int cr = static_cast<int>(c);
2619 while ( cr >= 0 && tableContents[row][cr].colSpan)
2620 {
2621 cr--;
2622 };
2623 if (cr >= 0 && tableContents[row][cr].cellText == "^") continue;
2624 }
2625 size_t rowSpan = 1, spanRow = row+1;
2626 while ((spanRow < tableContents.size()) &&
2627 (tableContents[spanRow][c].cellText == "^"))
2628 {
2629 spanRow++;
2630 rowSpan++;
2631 }
2632
2633 out+=" <" + cellTag + " " + cellClass;
2634 // use appropriate alignment style
2635 switch (columnAlignment[c])
2636 {
2637 case AlignLeft: out+="Left\""; break;
2638 case AlignRight: out+="Right\""; break;
2639 case AlignCenter: out+="Center\""; break;
2640 case AlignNone: out+="None\""; break;
2641 }
2642
2643 if (rowSpan > 1)
2644 {
2645 QCString spanStr;
2646 spanStr.setNum(rowSpan);
2647 out+=" rowspan=\"" + spanStr + "\"";
2648 }
2649 // Column span handling, assumes that column spans will have
2650 // empty strings, which would indicate the sequence "||", used
2651 // to signify spanning columns.
2652 size_t colSpan = 1;
2653 while ((c+1 < columns) && tableContents[row][c+1].colSpan)
2654 {
2655 c++;
2656 colSpan++;
2657 }
2658 if (colSpan > 1)
2659 {
2660 QCString spanStr;
2661 spanStr.setNum(colSpan);
2662 out+=" colspan=\"" + spanStr + "\"";
2663 }
2664 // need at least one space on either side of the cell text in
2665 // order for doxygen to do other formatting
2666 out+="> " + cellText + " \\ilinebr </" + cellTag + ">";
2667 }
2668 cellTag = "td";
2669 cellClass = "class=\"markdownTableBody";
2670 out+=" </tr>";
2671 }
2672 out+="</table>\n";
2673
2674 AUTO_TRACE_EXIT("i={}",i);
2675 return i;
2676}

References AlignCenter, AlignLeft, AlignNone, AlignRight, AUTO_TRACE, AUTO_TRACE_EXIT, end, FALSE, findTableColumns, markersToAlignment, out, QCString::setNum, TRUE and Trace::trunc.

Referenced by processBlocks.

Public Member Attributes

actions

std::array<Action_t,256> Markdown::Private::actions

Definition at line 179 of file markdown.cpp.

179 std::array<Action_t,256> actions;

Referenced by processInline.

fileName

QCString Markdown::Private::fileName

Definition at line 175 of file markdown.cpp.

Referenced by extractTitleId and processLink.

indentLevel

int Markdown::Private::indentLevel =0

Definition at line 177 of file markdown.cpp.

177 int indentLevel=0; // 0 is outside markdown, -1=page level

Referenced by isAtxHeader and isHeaderline.

lineNr

int Markdown::Private::lineNr = 0

Definition at line 176 of file markdown.cpp.

176 int lineNr = 0;

Referenced by extractTitleId.

linkRefs

std::unordered_map<std::string,LinkRef> Markdown::Private::linkRefs

Definition at line 174 of file markdown.cpp.

174 std::unordered_map<std::string,LinkRef> linkRefs;

Referenced by processBlocks and processLink.

out


The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus by Doxygen 1.14.0.