Helper class to process markdown formatted text
更多...
#include <markdown.h>
|
using | Action_t = std::function< int(const char *, int, int)> |
|
|
QCString | detab (const QCString &s, int &refIndent) |
|
QCString | processQuotations (const QCString &s, int refIndent) |
|
QCString | processBlocks (const QCString &s, int indent) |
|
QCString | isBlockCommand (const char *data, int offset, int size) |
|
void | findEndOfLine (const char *data, int size, int &pi, int &i, int &end) |
|
int | processHtmlTagWrite (const char *data, int offset, int size, bool doWrite) |
| Process a HTML tag. 更多...
|
|
int | processHtmlTag (const char *data, int offset, int size) |
|
int | processEmphasis (const char *data, int offset, int size) |
|
int | processEmphasis1 (const char *data, int size, char c) |
| process single emphasis 更多...
|
|
int | processEmphasis2 (const char *data, int size, char c) |
| process double emphasis 更多...
|
|
int | processEmphasis3 (const char *data, int size, char c) |
| Parsing triple emphasis. 更多...
|
|
int | processNmdash (const char *data, int off, int size) |
| Process ndash and mdashes 更多...
|
|
int | processQuoted (const char *data, int, int size) |
| Process quoted section "...", can contain one embedded newline 更多...
|
|
int | processCodeSpan (const char *data, int, int size) |
| '‘’ parsing a code span (assuming codespan != 0) 更多...
|
|
void | addStrEscapeUtf8Nbsp (const char *s, int len) |
|
int | processSpecialCommand (const char *data, int offset, int size) |
|
int | processLink (const char *data, int, int size) |
|
int | findEmphasisChar (const char *data, int size, char c, int 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. 更多...
|
|
void | processInline (const char *data, int size) |
|
void | writeMarkdownImage (const char *fmt, bool explicitTitle, const QCString &title, const QCString &content, const QCString &link, const FileDef *fd) |
|
int | isHeaderline (const char *data, int size, bool allowAdjustLevel) |
| returns whether the line is a setext-style hdr underline 更多...
|
|
int | isAtxHeader (const char *data, int size, QCString &header, QCString &id, bool allowAdjustLevel) |
|
void | writeOneLineHeaderOrRuler (const char *data, int size) |
|
void | writeFencedCodeBlock (const char *data, const char *lng, int blockStart, int blockEnd) |
|
int | writeBlockQuote (const char *data, int size) |
|
int | writeCodeBlock (const char *data, int size, int refIndent) |
|
int | writeTableBlock (const char *data, int size) |
|
Helper class to process markdown formatted text
在文件 markdown.h 第 32 行定义.
◆ Action_t
◆ Markdown()
Markdown::Markdown |
( |
const QCString & |
fileName, |
|
|
int |
lineNr, |
|
|
int |
indentLevel = 0 |
|
) |
| |
◆ addStrEscapeUtf8Nbsp()
void Markdown::addStrEscapeUtf8Nbsp |
( |
const char * |
s, |
|
|
int |
len |
|
) |
| |
|
private |
◆ detab()
在文件 markdown.cpp 第 2932 行定义.
2939 const char *data = s.
data();
2942 const int maxIndent=1000000;
2943 int minIndent=maxIndent;
2946 signed char c = (
signed char)data[i++];
2951 int stop = tabSize - (col%tabSize);
2978 for (
int j=0;j<bytes-1 && c;j++)
2990 if (col<minIndent) minIndent=col;
2994 if (minIndent!=maxIndent) refIndent=minIndent;
else refIndent=0;
引用了 GrowBuf::addChar(), GrowBuf::addStr(), GrowBuf::clear(), Config_getInt, QCString::data(), g_doxy_nsbp, GrowBuf::get(), getUTF8CharNumBytes(), isUTF8NonBreakableSpace(), QCString::length(), m_out, GrowBuf::reserve() , 以及 TRACE.
被这些函数引用 process().
◆ extractPageTitle()
◆ findEmphasisChar()
int Markdown::findEmphasisChar |
( |
const char * |
data, |
|
|
int |
size, |
|
|
char |
c, |
|
|
int |
c_size |
|
) |
| |
|
private |
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.
在文件 markdown.cpp 第 431 行定义.
438 while (i<size && data[i]!=c && data[i]!=
'`' &&
439 data[i]!=
'\\' && data[i]!=
'@' &&
440 !(data[i]==
'/' && data[i-1]==
'<') &&
455 while (i+len<size && data[i+len]==c)
462 if (len!=c_size || (i<size-len &&
isIdChar(i+len)))
476 while (i<size && data[i]==
'`') snb++,i++;
480 while (i<size && enb<snb)
482 if (data[i]==
'`') enb++;
483 if (snb==1 && data[i]==
'\'')
break;
487 else if (data[i]==
'@' || data[i]==
'\\')
493 int l = endBlockName.
length();
496 if ((data[i]==
'\\' || data[i]==
'@') &&
497 data[i-1]!=
'\\' && data[i-1]!=
'@')
517 else if (data[i-1]==
'<' && data[i]==
'/')
522 else if (data[i]==
'\n')
525 while (i<size && data[i]==
' ') i++;
526 if (i>=size || data[i]==
'\n') {
TRACE_RESULT(0);
return 0; }
引用了 QCString::data(), ignoreCloseEmphChar, isBlockCommand(), QCString::isEmpty(), isIdChar, QCString::length(), qstrncmp(), TRACE , 以及 TRACE_RESULT.
被这些函数引用 processEmphasis1(), processEmphasis2() , 以及 processEmphasis3().
◆ findEndOfLine()
void Markdown::findEndOfLine |
( |
const char * |
data, |
|
|
int |
size, |
|
|
int & |
pi, |
|
|
int & |
i, |
|
|
int & |
end |
|
) |
| |
|
private |
在文件 markdown.cpp 第 2438 行定义.
2451 if ((data[
end-1]==
'\\' || data[
end-1]==
'@') &&
2452 (
end<=1 || (data[
end-2]!=
'\\' && data[
end-2]!=
'@'))
2459 int l = endBlockName.
length();
2460 for (;
end<size-l-1;
end++)
2462 if ((data[
end]==
'\\' || data[
end]==
'@') &&
2463 data[
end-1]!=
'\\' && data[
end-1]!=
'@'
2477 else if (nb==0 && data[
end-1]==
'<' &&
end<size-6 &&
2478 (
end<=1 || (data[
end-2]!=
'\\' && data[
end-2]!=
'@'))
2481 if (tolower(data[
end])==
'p' && tolower(data[
end+1])==
'r' &&
2482 tolower(data[
end+2])==
'e' && (data[
end+3]==
'>' || data[
end+3]==
' '))
2493 else if (nb==0 && data[
end-1]==
'`')
2495 while (
end<=size && data[
end-1]==
'`')
end++,nb++;
2497 else if (nb>0 && data[
end-1]==
'`')
2500 while (
end<=size && data[
end-1]==
'`')
end++,enb++;
引用了 QCString::data(), end(), isBlockCommand(), QCString::isEmpty(), isNewline(), QCString::length(), processHtmlTagWrite(), qstrncmp() , 以及 TRACE.
被这些函数引用 processBlocks() , 以及 processQuotations().
◆ isAtxHeader()
int Markdown::isAtxHeader |
( |
const char * |
data, |
|
|
int |
size, |
|
|
QCString & |
header, |
|
|
QCString & |
id, |
|
|
bool |
allowAdjustLevel |
|
) |
| |
|
private |
在文件 markdown.cpp 第 1618 行定义.
1623 int level = 0, blanks=0;
1626 while (i<size && data[i]==
' ') i++;
1627 if (i>=size || data[i]!=
'#')
1632 while (i<size && level<6 && data[i]==
'#') i++,level++;
1633 while (i<size && data[i]==
' ') i++,blanks++;
1634 if (level==1 && blanks==0)
1642 while (
end<size && data[
end]!=
'\n')
end++;
1643 while (
end>i && (data[
end-1]==
'#' || data[
end-1]==
' '))
end--;
1651 while (i>=0 && (header.
at(i)==
'#' || header.
at(i)==
' ')) i--;
1652 header=header.
left(i+1);
引用了 QCString::at(), convertStringFragment(), end(), extractTitleId(), QCString::left(), QCString::length(), m_indentLevel, TRACE , 以及 TRACE_RESULT.
被这些函数引用 extractPageTitle() , 以及 writeOneLineHeaderOrRuler().
◆ isBlockCommand()
QCString Markdown::isBlockCommand |
( |
const char * |
data, |
|
|
int |
offset, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 364 行定义.
367 bool openBracket = offset>0 && data[-1]==
'{';
368 bool isEscaped = offset>0 && (data[-1]==
'\\' || data[-1]==
'@');
372 while (
end<size && (data[
end]>=
'a' && data[
end]<=
'z'))
end++;
376 if (blockName==
"code" && openBracket)
381 else if (blockName==
"dot" ||
384 blockName==
"verbatim" ||
385 blockName==
"latexonly" ||
386 blockName==
"htmlonly" ||
387 blockName==
"xmlonly" ||
388 blockName==
"rtfonly" ||
389 blockName==
"manonly" ||
390 blockName==
"docbookonly"
397 else if (blockName==
"startuml")
402 else if (blockName==
"f" &&
end<size)
409 else if (data[
end]==
'(')
414 else if (data[
end]==
'[')
419 else if (data[
end]==
'{')
引用了 convertStringFragment(), end(), TRACE , 以及 TRACE_RESULT.
被这些函数引用 findEmphasisChar(), findEndOfLine(), processBlocks() , 以及 processSpecialCommand().
◆ isHeaderline()
int Markdown::isHeaderline |
( |
const char * |
data, |
|
|
int |
size, |
|
|
bool |
allowAdjustLevel |
|
) |
| |
|
private |
returns whether the line is a setext-style hdr underline
在文件 markdown.cpp 第 1401 行定义.
1405 while (i<size && data[i]==
' ') i++;
1410 while (i<size && data[i]==
'=') i++,c++;
1411 while (i<size && data[i]==
' ') i++;
1412 int level = (c>1 && (i>=size || data[i]==
'\n')) ? 1 : 0;
1428 while (i<size && data[i]==
'-') i++,c++;
1429 while (i<size && data[i]==
' ') i++;
1430 return (c>1 && (i>=size || data[i]==
'\n')) ?
m_indentLevel+2 : 0;
引用了 m_indentLevel, TRACE , 以及 TRACE_RESULT.
被这些函数引用 extractPageTitle() , 以及 processBlocks().
◆ process()
QCString Markdown::process |
( |
const QCString & |
input, |
|
|
int & |
startNewlines, |
|
|
bool |
fromParseInput = false |
|
) |
| |
在文件 markdown.cpp 第 3002 行定义.
3004 if (input.
isEmpty())
return input;
3009 if (s.
at(s.
length()-1)!=
'\n') s +=
"\n";
3010 s =
detab(s,refIndent);
3036 const char *p = result.
data();
3039 while (*p==
' ') p++;
3040 while (*p==
'\n') {startNewlines++;p++;};
3043 if (p>result.
data())
3046 result = result.
mid(
static_cast<int>(p-result.
data()));
引用了 GrowBuf::addChar(), QCString::at(), GrowBuf::clear(), QCString::data(), detab(), g_doxy_nsbp, GrowBuf::get(), QCString::isEmpty(), QCString::length(), m_out, Debug::Markdown, QCString::mid(), Debug::print(), processBlocks(), processInline(), processQuotations(), qPrint(), qstrncmp() , 以及 substitute().
被这些函数引用 VHDLOutlineParser::handleCommentBlock(), DocPara::handleInclude() , 以及 MarkdownOutlineParser::parseInput().
◆ processBlocks()
在文件 markdown.cpp 第 2634 行定义.
2638 const char *data = s.
data();
2640 int i=0,
end=0,pi=-1,ref,level;
2642 int blockIndent = indent;
2647 while (
end<=size && data[
end-1]!=
'\n')
2649 if (data[
end-1]==
' ') sp++;
2653 #if 0 // commented m_out, since starting with a comment block is probably a usage error
2666 int currentIndent = indent;
2667 int listIndent = indent;
2668 bool insideList =
false;
2669 bool newBlock =
false;
2677 while (lineIndent<
end && data[i+lineIndent]==
' ') lineIndent++;
2683 if (insideList && lineIndent<currentIndent)
2686 currentIndent = indent;
2687 blockIndent = indent;
2695 if (listIndent<currentIndent+4)
2699 currentIndent = listIndent;
2700 blockIndent = listIndent;
2707 currentIndent = listIndent;
2708 blockIndent = listIndent;
2722 int blockStart,blockEnd,blockOffset;
2724 blockIndent = currentIndent;
2727 if (data[i]==
'@' || data[i]==
'\\') endBlockName =
isBlockCommand(data+i,i,size-i);
2731 if (
isLinkRef(data+pi,i-pi,
id,link,title))
2733 m_linkRefs.insert({
id.lower().str(),LinkRef(link,title)});
2741 int l = endBlockName.
length();
2744 if ((data[i]==
'\\' || data[i]==
'@') &&
2745 data[i-1]!=
'\\' && data[i-1]!=
'@')
2763 while (pi<size && data[pi]==
' ') pi++;
2772 m_out.
addStr(level==1?
"@section ":
"@subsection ");
2794 else if ((ref=
isLinkRef(data+pi,size-pi,
id,link,title)))
2798 m_linkRefs.insert({
id.lower().str(),LinkRef(link,title)});
2803 else if (
isFencedCodeBlock(data+pi,size-pi,currentIndent,lang,blockStart,blockEnd,blockOffset))
2837 if (pi!=-1 && pi<size)
2839 if (
isLinkRef(data+pi,size-pi,
id,link,title))
2843 m_linkRefs.insert({
id.lower().str(),LinkRef(link,title)});
引用了 GrowBuf::addChar(), GrowBuf::addStr(), GrowBuf::clear(), codeBlockIndent, convertStringFragment(), QCString::data(), end(), extractTitleId(), findEndOfLine(), GrowBuf::get(), isBlockCommand(), isCodeBlock(), QCString::isEmpty(), isEmptyLine(), isEndOfList(), isFencedCodeBlock(), isHeaderline(), isLinkRef(), isListMarker(), isTableBlock(), QCString::length(), m_linkRefs, m_out, qstrncmp(), TRACE, TRUE, writeCodeBlock(), writeFencedCodeBlock(), writeOneLineHeaderOrRuler() , 以及 writeTableBlock().
被这些函数引用 process().
◆ processCodeSpan()
int Markdown::processCodeSpan |
( |
const char * |
data, |
|
|
int |
, |
|
|
int |
size |
|
) |
| |
|
private |
'‘’ parsing a code span (assuming codespan != 0)
在文件 markdown.cpp 第 1234 行定义.
1237 int end, nb = 0, i, f_begin, f_end;
1240 while (nb<size && data[nb]==
'`')
1248 for (
end=nb;
end<size && i<nb && nl<2;
end++)
1254 else if (data[
end]==
'\n')
1273 if (i < nb && end >= size)
1286 while (f_begin <
end && data[f_begin]==
' ')
1291 while (f_end > nb && data[f_end-1]==
' ')
1299 if (f_begin < f_end)
引用了 GrowBuf::addStr(), convertStringFragment(), end(), escapeSpecialChars(), isIdChar, m_out, TRACE , 以及 TRACE_RESULT.
被这些函数引用 Markdown().
◆ processEmphasis()
int Markdown::processEmphasis |
( |
const char * |
data, |
|
|
int |
offset, |
|
|
int |
size |
|
) |
| |
|
private |
◆ processEmphasis1()
int Markdown::processEmphasis1 |
( |
const char * |
data, |
|
|
int |
size, |
|
|
char |
c |
|
) |
| |
|
private |
◆ processEmphasis2()
int Markdown::processEmphasis2 |
( |
const char * |
data, |
|
|
int |
size, |
|
|
char |
c |
|
) |
| |
|
private |
◆ processEmphasis3()
int Markdown::processEmphasis3 |
( |
const char * |
data, |
|
|
int |
size, |
|
|
char |
c |
|
) |
| |
|
private |
◆ processHtmlTag()
int Markdown::processHtmlTag |
( |
const char * |
data, |
|
|
int |
offset, |
|
|
int |
size |
|
) |
| |
|
private |
◆ processHtmlTagWrite()
int Markdown::processHtmlTagWrite |
( |
const char * |
data, |
|
|
int |
offset, |
|
|
int |
size, |
|
|
bool |
doWrite |
|
) |
| |
|
private |
Process a HTML tag.
Note that
..
are treated specially, in the sense that all code inside is written unprocessed
在文件 markdown.cpp 第 737 行定义.
740 if (offset>0 && data[-1]==
'\\') {
TRACE_RESULT(0);
return 0; }
746 while (i<size &&
isIdChar(i)) i++,l++;
749 if (tagName.
lower()==
"pre")
751 bool insideStr=
FALSE;
755 if (!insideStr && c==
'<')
757 if (data[i+1]==
'/' &&
758 tolower(data[i+2])==
'p' && tolower(data[i+3])==
'r' &&
759 tolower(data[i+4])==
'e' && tolower(data[i+5])==
'>')
767 else if (insideStr && c==
'"')
769 if (data[i-1]!=
'\\') insideStr=
FALSE;
782 if (data[i]==
'/' && i<size-1 && data[i+1]==
'>')
789 else if (data[i]==
'>')
796 else if (data[i]==
' ')
799 bool insideAttr=
FALSE;
802 if (!insideAttr && data[i]==
'"')
806 else if (data[i]==
'"' && data[i-1]!=
'\\')
810 else if (!insideAttr && data[i]==
'>')
引用了 GrowBuf::addStr(), convertStringFragment(), FALSE, isIdChar, QCString::lower(), m_out, TRACE, TRACE_RESULT , 以及 TRUE.
被这些函数引用 findEndOfLine() , 以及 processHtmlTag().
◆ processInline()
void Markdown::processInline |
( |
const char * |
data, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 1376 行定义.
1385 if (
end>=size)
break;
1387 end = action(data+i,i,size-i);
引用了 GrowBuf::addStr(), end(), m_actions, m_out , 以及 TRACE.
被这些函数引用 process(), processEmphasis1(), processEmphasis2(), processEmphasis3() , 以及 processLink().
◆ processLink()
int Markdown::processLink |
( |
const char * |
data, |
|
|
int |
, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 909 行定义.
915 int contentStart,contentEnd,linkStart,titleStart,titleEnd;
916 bool isImageLink =
FALSE;
922 if (size<2 || data[1]!=
'[')
939 else if (data[i]==
'[')
943 else if (data[i]==
']')
948 else if (data[i]==
'\n')
957 if (i>=size)
return 0;
965 while (i<size && data[i]==
' ') i++;
966 if (i<size && data[i]==
'\n')
971 while (i<size && data[i]==
' ') i++;
976 bool explicitTitle=
FALSE;
977 if (i<size && data[i]==
'(')
980 while (i<size && data[i]==
' ') i++;
981 bool uriFormat=
false;
982 if (i<size && data[i]==
'<') { i++; uriFormat=
true; }
985 while (i<size && data[i]!=
'\'' && data[i]!=
'"' && braceCount>0)
992 else if (data[i]==
'(')
996 else if (data[i]==
')')
1007 if (i>=size || data[i]==
'\n') {
TRACE_RESULT(0);
return 0; }
1015 if (data[i]==
'\'' || data[i]==
'"')
1021 while (i<size && data[i]!=
')')
1037 while (titleEnd>titleStart && data[titleEnd]==
' ') titleEnd--;
1038 if (data[titleEnd]==c)
1051 else if (i<size && data[i]==
'[')
1057 while (i<size && data[i]!=
']')
1080 link = lr_it->second.link;
1081 title = lr_it->second.title;
1092 else if (i<size && data[i]!=
':' && !content.
isEmpty())
1099 link = lr_it->second.link;
1100 title = lr_it->second.title;
1104 else if (content==
"TOC")
1126 if (toc_level > 0 && toc_level <=5)
1133 else if (isImageLink)
1137 if (link.
find(
"@ref ")!=-1 || link.
find(
"\\ref ")!=-1 ||
1175 if (forg.exists() && forg.isReadable())
1177 link = forg.absFilePath();
1179 else if (!(forg.exists() && forg.isReadable()))
1184 if (fmd.exists() && fmd.isReadable())
1186 link = fmd.absFilePath().
data();
1193 if (explicitTitle && !title.
isEmpty())
1203 else if (link.
find(
'/')!=-1 || link.
find(
'.')!=-1 || link.
find(
'#')!=-1)
1208 for (
int ii = 0; ii < nlTotal; ii++)
m_out.
addStr(
"\n");
引用了 FileInfo::absFilePath(), GrowBuf::addStr(), QCString::at(), Config_getInt, convertStringFragment(), QCString::data(), FileInfo::exists(), externalLinkTarget(), FALSE, FileInfo::fileName(), QCString::find(), findFileDef(), getLanguageFromFileName(), Doxygen::imageNameLinkedMap, Portable::isAbsolutePath(), QCString::isEmpty(), FileInfo::isReadable(), isURL(), QCString::left(), QCString::length(), QCString::lower(), m_fileName, m_linkRefs, m_out, processInline(), QCString::simplifyWhiteSpace(), SrcLangExt_Markdown, QCString::str(), QCString::stripWhiteSpace(), substitute(), TRACE, TRACE_RESULT, TRUE , 以及 writeMarkdownImage().
被这些函数引用 Markdown().
◆ processNmdash()
int Markdown::processNmdash |
( |
const char * |
data, |
|
|
int |
off, |
|
|
int |
size |
|
) |
| |
|
private |
◆ processQuotations()
在文件 markdown.cpp 第 2533 行定义.
2537 const char *data = s.
data();
2539 int i=0,
end=0,pi=-1;
2540 int blockStart,blockEnd,blockOffset;
2541 bool newBlock =
false;
2542 bool insideList =
false;
2543 int currentIndent = refIndent;
2544 int listIndent = refIndent;
2552 while (lineIndent<
end && data[i+lineIndent]==
' ') lineIndent++;
2558 if (insideList && lineIndent<currentIndent)
2561 currentIndent = refIndent;
2569 if (listIndent<currentIndent+4)
2573 currentIndent = listIndent;
2580 currentIndent = listIndent;
2591 if (
isFencedCodeBlock(data+pi,size-pi,currentIndent,lang,blockStart,blockEnd,blockOffset))
2615 if (pi!=-1 && pi<size)
引用了 GrowBuf::addChar(), GrowBuf::addStr(), GrowBuf::clear(), QCString::data(), end(), findEndOfLine(), GrowBuf::get(), isBlockQuote(), isEmptyLine(), isEndOfList(), isFencedCodeBlock(), isListMarker(), QCString::length(), m_out, TRACE, writeBlockQuote() , 以及 writeFencedCodeBlock().
被这些函数引用 process().
◆ processQuoted()
int Markdown::processQuoted |
( |
const char * |
data, |
|
|
int |
, |
|
|
int |
size |
|
) |
| |
|
private |
◆ processSpecialCommand()
int Markdown::processSpecialCommand |
( |
const char * |
data, |
|
|
int |
offset, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 1325 行定义.
1333 int l = endBlockName.
length();
1336 if ((data[i]==
'\\' || data[i]==
'@') &&
1337 data[i-1]!=
'\\' && data[i-1]!=
'@')
1350 if (size>1 && data[0]==
'\\')
1353 if (c==
'[' || c==
']' || c==
'*' || c==
'!' || c==
'(' || c==
')' || c==
'`' || c==
'_')
1359 else if (c==
'-' && size>3 && data[2]==
'-' && data[3]==
'-')
1365 else if (c==
'-' && size>2 && data[2]==
'-')
引用了 GrowBuf::addChar(), GrowBuf::addStr(), addStrEscapeUtf8Nbsp(), QCString::data(), isBlockCommand(), QCString::isEmpty(), QCString::length(), m_out, qPrint(), qstrncmp(), TRACE, TRACE_MORE , 以及 TRACE_RESULT.
被这些函数引用 Markdown().
◆ setIndentLevel()
void Markdown::setIndentLevel |
( |
int |
level | ) |
|
|
inline |
◆ writeBlockQuote()
int Markdown::writeBlockQuote |
( |
const char * |
data, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 2323 行定义.
2334 while (
end<=size && data[
end-1]!=
'\n')
end++;
2339 while (j<
end && (data[j]==
' ' || data[j]==
'>'))
2341 if (data[j]==
'>') { level++; indent=j+1; }
2342 else if (j>0 && data[j-1]==
'>') indent=j+1;
2345 if (j>0 && data[j-1]==
'>' &&
2346 !(j==size || data[j]==
'\n'))
2352 if (!level && data[j-1]!=
'\n') level=curLevel;
2355 for (l=curLevel;l<level-1;l++)
2361 else if (level<curLevel)
2363 for (l=level;l<curLevel;l++)
2369 if (level==0)
break;
2376 for (l=0;l<curLevel;l++)
引用了 GrowBuf::addStr(), end(), m_out, TRACE , 以及 TRACE_RESULT.
被这些函数引用 processQuotations().
◆ writeCodeBlock()
int Markdown::writeCodeBlock |
( |
const char * |
data, |
|
|
int |
size, |
|
|
int |
refIndent |
|
) |
| |
|
private |
◆ writeFencedCodeBlock()
void Markdown::writeFencedCodeBlock |
( |
const char * |
data, |
|
|
const char * |
lng, |
|
|
int |
blockStart, |
|
|
int |
blockEnd |
|
) |
| |
|
private |
◆ writeMarkdownImage()
void Markdown::writeMarkdownImage |
( |
const char * |
fmt, |
|
|
bool |
explicitTitle, |
|
|
const QCString & |
title, |
|
|
const QCString & |
content, |
|
|
const QCString & |
link, |
|
|
const FileDef * |
fd |
|
) |
| |
|
private |
◆ writeOneLineHeaderOrRuler()
void Markdown::writeOneLineHeaderOrRuler |
( |
const char * |
data, |
|
|
int |
size |
|
) |
| |
|
private |
◆ writeTableBlock()
int Markdown::writeTableBlock |
( |
const char * |
data, |
|
|
int |
size |
|
) |
| |
|
private |
在文件 markdown.cpp 第 2046 行定义.
2050 int columns,start,
end,cc;
2054 int headerStart = start;
2055 int headerEnd =
end;
2060 std::vector<int> columnAlignment(columns);
2063 bool startFound=
FALSE;
2069 if (data[j]==
':') { leftMarker=
TRUE; startFound=
TRUE; }
2070 if (data[j]==
'-') startFound=
TRUE;
2073 if (data[j]==
'-') rightMarker=
FALSE;
2074 else if (data[j]==
':') rightMarker=
TRUE;
2075 if (j<=
end+i && (data[j]==
'|' && (j==0 || data[j-1]!=
'\\')))
2099 std::vector<std::vector<TableCell> > tableContents;
2102 std::vector<TableCell> headerContents(columns);
2103 for (k=0;k<columns;k++)
2105 while (m<=headerEnd && (data[m]!=
'|' || (m>0 && data[m-1]==
'\\')))
2107 headerContents[k].cellText += data[m++];
2112 headerContents[k].colSpan = headerContents[k].cellText.isEmpty();
2113 headerContents[k].cellText = headerContents[k].cellText.stripWhiteSpace();
2115 tableContents.push_back(headerContents);
2121 if (cc!=columns)
break;
2125 std::vector<TableCell> rowContents(columns);
2128 if (j<=
end+i && (data[j]==
'|' && (j==0 || data[j-1]!=
'\\')))
2132 rowContents[k].colSpan = rowContents[k].cellText.isEmpty();
2133 rowContents[k].cellText = rowContents[k].cellText.stripWhiteSpace();
2138 rowContents[k].cellText += data[j];
2144 rowContents[k].colSpan = rowContents[k].cellText.isEmpty();
2145 rowContents[k].cellText = rowContents[k].cellText.stripWhiteSpace();
2146 tableContents.push_back(rowContents);
2153 QCString cellTag(
"th"), cellClass(
"class=\"markdownTableHead");
2154 for (
unsigned row = 0; row < tableContents.size(); row++)
2160 m_out.
addStr(
"\n<tr class=\"markdownTableRowOdd\">");
2164 m_out.
addStr(
"\n<tr class=\"markdownTableRowEven\">");
2169 m_out.
addStr(
"\n <tr class=\"markdownTableHead\">");
2171 for (
int c = 0; c < columns; c++)
2174 QCString cellText(tableContents[row][c].cellText);
2180 if (tableContents[row][c].cellText ==
"^")
2184 if (tableContents[row][c].colSpan)
2187 while ( cr >= 0 && tableContents[row][cr].colSpan)
2191 if (cr >= 0 && tableContents[row][cr].cellText ==
"^")
continue;
2193 unsigned rowSpan = 1, spanRow = row+1;
2194 while ((spanRow < tableContents.size()) &&
2195 (tableContents[spanRow][c].cellText ==
"^"))
2203 switch (columnAlignment[c])
2220 unsigned colSpan = 1;
2221 while ((c < columns-1) && tableContents[row][c+1].colSpan)
2234 m_out.
addStr(
"> " + cellText +
" \\ilinebr </" + cellTag +
">");
2237 cellClass =
"class=\"markdownTableBody";
引用了 GrowBuf::addStr(), AlignCenter, AlignLeft, AlignNone, AlignRight, end(), FALSE, findTableColumns(), m_out, markersToAlignment(), QCString::setNum(), TRACE, TRACE_RESULT , 以及 TRUE.
被这些函数引用 processBlocks().
◆ m_actions
◆ m_fileName
◆ m_indentLevel
int Markdown::m_indentLevel =0 |
|
private |
◆ m_lineNr
int Markdown::m_lineNr = 0 |
|
private |
◆ m_linkRefs
std::unordered_map<std::string,LinkRef> Markdown::m_linkRefs |
|
private |
◆ m_out
在文件 markdown.h 第 86 行定义.
被这些函数引用 addStrEscapeUtf8Nbsp(), detab(), process(), processBlocks(), processCodeSpan(), processEmphasis1(), processEmphasis2(), processEmphasis3(), processHtmlTagWrite(), processInline(), processLink(), processNmdash(), processQuotations(), processQuoted(), processSpecialCommand(), writeBlockQuote(), writeCodeBlock(), writeFencedCodeBlock(), writeMarkdownImage(), writeOneLineHeaderOrRuler() , 以及 writeTableBlock().
该类的文档由以下文件生成:
void writeOneLineHeaderOrRuler(const char *data, int size)
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
static int isLinkRef(const char *data, int size, QCString &refid, QCString &link, QCString &title)
returns end of the link ref if this is indeed a link reference.
int isAtxHeader(const char *data, int size, QCString &header, QCString &id, bool allowAdjustLevel)
static FileNameLinkedMap * imageNameLinkedMap
int isHeaderline(const char *data, int size, bool allowAdjustLevel)
returns whether the line is a setext-style hdr underline
int writeTableBlock(const char *data, int size)
uint length() const
Returns the length of the string, not counting the 0-terminator.
int processHtmlTagWrite(const char *data, int offset, int size, bool doWrite)
Process a HTML tag.
int processEmphasis1(const char *data, int size, char c)
process single emphasis
bool isEmpty() const
Returns TRUE iff the string is empty
void findEndOfLine(const char *data, int size, int &pi, int &i, int &end)
QCString processBlocks(const QCString &s, int indent)
uint size() const
Returns the length of the string, not counting the 0-terminator.
SrcLangExt
Language as given by extension
std::function< int(const char *, int, int)> Action_t
static int isListMarker(const char *data, int size)
char & at(size_t i)
Returns a reference to the character at index i.
QCString isBlockCommand(const char *data, int offset, int size)
void addStr(const QCString &s)
int find(char c, int index=0, bool cs=TRUE) const
bool isURL(const QCString &url)
Checks whether the given url starts with a supported protocol
int qstrncmp(const char *str1, const char *str2, size_t len)
static bool hasLineBreak(const char *data, int size)
DirIterator end(const DirIterator &) noexcept
int processEmphasis(const char *data, int offset, int size)
const char * strnstr(const char *haystack, const char *needle, size_t haystack_len)
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
#define Config_getInt(name)
static QCString escapeDoubleQuotes(const QCString &s)
QCString left(size_t len) const
std::unordered_map< std::string, LinkRef > m_linkRefs
int processNmdash(const char *data, int off, int size)
Process ndash and mdashes
const int codeBlockIndent
QCString processQuotations(const QCString &s, int refIndent)
static void print(DebugMask mask, int prio, const char *fmt,...)
int processCodeSpan(const char *data, int, int size)
'‘’ parsing a code span (assuming codespan != 0)
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
static QCString escapeSpecialChars(const QCString &s)
void writeFencedCodeBlock(const char *data, const char *lng, int blockStart, int blockEnd)
static Alignment markersToAlignment(bool leftMarker, bool rightMarker)
helper function to convert presence of left and/or right alignment markers to a alignment value
int isNewline(const char *data)
int findTableColumns(const char *data, int size, int &start, int &end, int &columns)
Finds the location of the table's contains in the string data.
int processSpecialCommand(const char *data, int offset, int size)
static bool isFencedCodeBlock(const char *data, int size, int refIndent, QCString &lang, int &start, int &end, int &offset)
QCString detab(const QCString &s, int &refIndent)
void processInline(const char *data, int size)
int writeBlockQuote(const char *data, int size)
static bool isEmptyLine(const char *data, int size)
int findEmphasisChar(const char *data, int size, char c, int c_size)
looks for the next emph char, skipping other constructs, and stopping when either it is found,...
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
static bool isEndOfList(const char *data, int size)
int writeCodeBlock(const char *data, int size, int refIndent)
int processQuoted(const char *data, int, int size)
Process quoted section "...", can contain one embedded newline
int processEmphasis2(const char *data, int size, char c)
process double emphasis
QCString externalLinkTarget(const bool parent)
QCString & setNum(short n)
uint8_t getUTF8CharNumBytes(char c)
Returns the number of bytes making up a single UTF8 character given the first byte in the sequence.
Markdown::Action_t m_actions[256]
const uchar g_utf8_nbsp[3]
int isUTF8NonBreakableSpace(const char *input)
Check if the first character pointed at by input is a non-breakable whitespace character.
bool isBlockQuote(const char *data, int size, int indent)
returns TRUE if this line starts a block quote
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
void addStrEscapeUtf8Nbsp(const char *s, int len)
#define isOpenEmphChar(i)
Minimal replacement for QFileInfo.
const char * qPrint(const char *s)
static bool isTableBlock(const char *data, int size)
Returns TRUE iff data points to the start of a table block
static QCString extractTitleId(QCString &title, int level)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
A model of a file symbol.
static bool isHRuler(const char *data, int size)
int processLink(const char *data, int, int size)
bool isAbsolutePath(const QCString &fileName)
void writeMarkdownImage(const char *fmt, bool explicitTitle, const QCString &title, const QCString &content, const QCString &link, const FileDef *fd)
static void convertStringFragment(QCString &result, const char *data, int size)
#define ignoreCloseEmphChar(i)
static bool isCodeBlock(const char *data, int offset, int size, int &indent)
QCString & sprintf(const char *format,...)
int processHtmlTag(const char *data, int offset, int size)
int processEmphasis3(const char *data, int size, char c)
Parsing triple emphasis.
This is an alternative implementation of QCString.