Doxygen
markdown.cpp 文件参考
#include <stdio.h>
#include <unordered_map>
#include <functional>
#include <atomic>
#include "markdown.h"
#include "growbuf.h"
#include "debug.h"
#include "util.h"
#include "doxygen.h"
#include "commentscan.h"
#include "entry.h"
#include "commentcnv.h"
#include "config.h"
#include "section.h"
#include "message.h"
#include "portable.h"
#include "regex.h"
#include "fileinfo.h"
#include "utf8.h"
+ markdown.cpp 的引用(Include)关系图:

浏览源代码.

class  Trace
 
struct  TableCell
 
struct  MarkdownOutlineParser::Private
 

宏定义

#define ENABLE_TRACING
 
#define IOSTREAM   stdout
 
#define DATA_BUFSIZE   20
 
#define PRETTY_FUNC   __PRETTY_FUNCTION__
 
#define TRACE(data)   Trace trace_(PRETTY_FUNC,data);
 
#define TRACE_MORE(...)   trace_.trace(__VA_ARGS__);
 
#define TRACE_RESULT(v)   trace_.setResult(v);
 
#define isIdChar(i)
 
#define extraChar(i)
 
#define isOpenEmphChar(i)
 
#define ignoreCloseEmphChar(i)
 
#define isLiTag(i)
 

枚举

enum  Alignment { AlignNone, AlignLeft, AlignCenter, AlignRight }
 

函数

int isNewline (const char *data)
 
static QCString escapeDoubleQuotes (const QCString &s)
 
static QCString escapeSpecialChars (const QCString &s)
 
static void convertStringFragment (QCString &result, const char *data, int size)
 
static Alignment markersToAlignment (bool leftMarker, bool rightMarker)
 helper function to convert presence of left and/or right alignment markers to a alignment value 更多...
 
bool isBlockQuote (const char *data, int size, int indent)
 returns TRUE if this line starts a block quote 更多...
 
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. 更多...
 
static bool isHRuler (const char *data, int size)
 
static QCString extractTitleId (QCString &title, int level)
 
static bool isEmptyLine (const char *data, int size)
 
static int computeIndentExcludingListMarkers (const char *data, int size)
 
static int isListMarker (const char *data, int size)
 
static bool isEndOfList (const char *data, int size)
 
static bool isFencedCodeBlock (const char *data, int size, int refIndent, QCString &lang, int &start, int &end, int &offset)
 
static bool isCodeBlock (const char *data, int offset, int size, int &indent)
 
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. 更多...
 
static bool isTableBlock (const char *data, int size)
 Returns TRUE iff data points to the start of a table block 更多...
 
static bool hasLineBreak (const char *data, int size)
 
static bool isExplicitPage (const QCString &docs)
 returns TRUE if input string docs starts with @page or @mainpage command 更多...
 
QCString markdownFileNameToId (const QCString &fileName)
 processes string s and converts markdown into doxygen/html commands. 更多...
 

变量

const uchar g_utf8_nbsp [3] = { 0xc2, 0xa0, 0}
 
const char * g_doxy_nsbp = "&_doxy_nbsp;"
 
const int codeBlockIndent = 4
 

宏定义说明

◆ DATA_BUFSIZE

#define DATA_BUFSIZE   20

在文件 markdown.cpp62 行定义.

◆ ENABLE_TRACING

#define ENABLE_TRACING

在文件 markdown.cpp57 行定义.

◆ extraChar

#define extraChar (   i)
值:
(data[i]=='-' || data[i]=='+' || data[i]=='!' || \
data[i]=='?' || data[i]=='$' || data[i]=='@' || \
data[i]=='&' || data[i]=='*' || data[i]=='%')

在文件 markdown.cpp180 行定义.

◆ ignoreCloseEmphChar

#define ignoreCloseEmphChar (   i)
值:
(data[i]=='(' || data[i]=='{' || data[i]=='[' || (data[i]=='<' && data[i+1]!='/') || \
data[i]=='\\' || \
data[i]=='@')

在文件 markdown.cpp193 行定义.

◆ IOSTREAM

#define IOSTREAM   stdout

在文件 markdown.cpp61 行定义.

◆ isIdChar

#define isIdChar (   i)
值:
((data[i]>='a' && data[i]<='z') || \
(data[i]>='A' && data[i]<='Z') || \
(data[i]>='0' && data[i]<='9') || \
(((unsigned char)data[i])>=0x80))

在文件 markdown.cpp174 行定义.

◆ isLiTag

#define isLiTag (   i)
值:
(data[(i)]=='<' && \
(data[(i)+1]=='l' || data[(i)+1]=='L') && \
(data[(i)+2]=='i' || data[(i)+2]=='I') && \
(data[(i)+3]=='>'))

在文件 markdown.cpp1696 行定义.

◆ isOpenEmphChar

#define isOpenEmphChar (   i)
值:
(data[i]=='\n' || data[i]==' ' || data[i]=='\'' || data[i]=='<' || \
data[i]=='>' || data[i]=='{' || data[i]=='(' || data[i]=='[' || \
data[i]==',' || data[i]==':' || data[i]==';')

在文件 markdown.cpp186 行定义.

◆ PRETTY_FUNC

#define PRETTY_FUNC   __PRETTY_FUNCTION__

在文件 markdown.cpp66 行定义.

◆ TRACE

#define TRACE (   data)    Trace trace_(PRETTY_FUNC,data);

在文件 markdown.cpp162 行定义.

◆ TRACE_MORE

#define TRACE_MORE (   ...)    trace_.trace(__VA_ARGS__);

在文件 markdown.cpp163 行定义.

◆ TRACE_RESULT

#define TRACE_RESULT (   v)    trace_.setResult(v);

在文件 markdown.cpp164 行定义.

枚举类型说明

◆ Alignment

enum Alignment
枚举值
AlignNone 
AlignLeft 
AlignCenter 
AlignRight 

在文件 markdown.cpp226 行定义.

函数说明

◆ computeIndentExcludingListMarkers()

static int computeIndentExcludingListMarkers ( const char *  data,
int  size 
)
static

在文件 markdown.cpp1704 行定义.

1705 {
1706  TRACE(data);
1707  int i=0;
1708  int indent=0;
1709  bool isDigit=FALSE;
1710  bool isLi=FALSE;
1711  bool listMarkerSkipped=FALSE;
1712  while (i<size &&
1713  (data[i]==' ' || // space
1714  (!listMarkerSkipped && // first list marker
1715  (data[i]=='+' || data[i]=='-' || data[i]=='*' || // unordered list char
1716  (data[i]=='#' && i>0 && data[i-1]=='-') || // -# item
1717  (isDigit=(data[i]>='1' && data[i]<='9')) || // ordered list marker?
1718  (isLi=(i<size-3 && isLiTag(i))) // <li> tag
1719  )
1720  )
1721  )
1722  )
1723  {
1724  if (isDigit) // skip over ordered list marker '10. '
1725  {
1726  int j=i+1;
1727  while (j<size && ((data[j]>='0' && data[j]<='9') || data[j]=='.'))
1728  {
1729  if (data[j]=='.') // should be end of the list marker
1730  {
1731  if (j<size-1 && data[j+1]==' ') // valid list marker
1732  {
1733  listMarkerSkipped=TRUE;
1734  indent+=j+1-i;
1735  i=j+1;
1736  break;
1737  }
1738  else // not a list marker
1739  {
1740  break;
1741  }
1742  }
1743  j++;
1744  }
1745  }
1746  else if (isLi)
1747  {
1748  i+=3; // skip over <li>
1749  indent+=3;
1750  listMarkerSkipped=TRUE;
1751  }
1752  else if (data[i]=='-' && i<size-2 && data[i+1]=='#' && data[i+2]==' ')
1753  { // case "-# "
1754  listMarkerSkipped=TRUE; // only a single list marker is accepted
1755  i++; // skip over #
1756  indent++;
1757  }
1758  else if (data[i]!=' ' && i<size-1 && data[i+1]==' ')
1759  { // case "- " or "+ " or "* "
1760  listMarkerSkipped=TRUE; // only a single list marker is accepted
1761  }
1762  if (data[i]!=' ' && !listMarkerSkipped)
1763  { // end of indent
1764  break;
1765  }
1766  indent++,i++;
1767  }
1768  //printf("{%s}->%d\n",QCString(data).qPrint(left(size)),indent);
1769  TRACE_RESULT(indent);
1770  return indent;
1771 }

引用了 FALSE, isLiTag, TRACE, TRACE_RESULT , 以及 TRUE.

被这些函数引用 isCodeBlock() , 以及 isListMarker().

◆ convertStringFragment()

static void convertStringFragment ( QCString result,
const char *  data,
int  size 
)
static

在文件 markdown.cpp312 行定义.

313 {
314  TRACE(result);
315  if (size<0) size=0;
316  result = QCString(data,(uint)size);
317  TRACE_RESULT(result);
318 }

引用了 TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::extractPageTitle(), Markdown::isAtxHeader(), Markdown::isBlockCommand(), isFencedCodeBlock(), isLinkRef(), Markdown::processBlocks(), Markdown::processCodeSpan(), Markdown::processHtmlTagWrite() , 以及 Markdown::processLink().

◆ escapeDoubleQuotes()

static QCString escapeDoubleQuotes ( const QCString s)
static

在文件 markdown.cpp249 行定义.

250 {
251  TRACE(s);
252  if (s.isEmpty()) return s;
253  GrowBuf growBuf;
254  const char *p=s.data();
255  char c,pc='\0';
256  while ((c=*p++))
257  {
258  switch (c)
259  {
260  case '"': if (pc!='\\') { growBuf.addChar('\\'); } growBuf.addChar(c); break;
261  default: growBuf.addChar(c); break;
262  }
263  pc=c;
264  }
265  growBuf.addChar(0);
266  TRACE_RESULT(growBuf.get());
267  return growBuf.get();
268 }

引用了 GrowBuf::addChar(), QCString::data(), GrowBuf::get(), QCString::isEmpty(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::writeMarkdownImage().

◆ escapeSpecialChars()

static QCString escapeSpecialChars ( const QCString s)
static

在文件 markdown.cpp270 行定义.

271 {
272  TRACE(s);
273  if (s.isEmpty()) return s;
274  bool insideQuote=FALSE;
275  GrowBuf growBuf;
276  const char *p=s.data();
277  char c,pc='\0';
278  while ((c=*p++))
279  {
280  switch (c)
281  {
282  case '"': if (pc!='\\') { insideQuote=!insideQuote; } growBuf.addChar(c); break;
283  case '<':
284  case '>': if (!insideQuote)
285  {
286  growBuf.addChar('\\');
287  growBuf.addChar(c);
288  if ((p[0] == ':') && (p[1] == ':'))
289  {
290  growBuf.addChar('\\');
291  growBuf.addChar(':');
292  p++;
293  }
294  }
295  else
296  {
297  growBuf.addChar(c);
298  }
299  break;
300  case '\\': if (!insideQuote) { growBuf.addChar('\\'); } growBuf.addChar('\\'); break;
301  case '@': if (!insideQuote) { growBuf.addChar('\\'); } growBuf.addChar('@'); break;
302  case '#': if (!insideQuote) { growBuf.addChar('\\'); } growBuf.addChar('#'); break;
303  default: growBuf.addChar(c); break;
304  }
305  pc=c;
306  }
307  growBuf.addChar(0);
308  TRACE_RESULT(growBuf.get());
309  return growBuf.get();
310 }

引用了 GrowBuf::addChar(), QCString::data(), FALSE, GrowBuf::get(), QCString::isEmpty(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processCodeSpan().

◆ extractTitleId()

static QCString extractTitleId ( QCString title,
int  level 
)
static

在文件 markdown.cpp1589 行定义.

1590 {
1591  TRACE(title);
1592  // match e.g. '{#id-b11} ' and capture 'id-b11'
1593  static const reg::Ex r2(R"({#(\a[\w-]*)}\s*$)");
1594  reg::Match match;
1595  std::string ti = title.str();
1596  if (reg::search(ti,match,r2))
1597  {
1598  std::string id = match[1].str();
1599  title = title.left((int)match.position());
1600  //printf("found match id='%s' title=%s\n",id.c_str(),qPrint(title));
1601  TRACE_RESULT(QCString(id));
1602  return QCString(id);
1603  }
1604  if ((level > 0) && (level <= Config_getInt(TOC_INCLUDE_HEADINGS)))
1605  {
1606  static AtomicInt autoId { 0 };
1607  QCString id;
1608  id.sprintf("autotoc_md%d",autoId++);
1609  //printf("auto-generated id='%s' title='%s'\n",qPrint(id),qPrint(title));
1610  TRACE_RESULT(id);
1611  return id;
1612  }
1613  //printf("no id found in title '%s'\n",qPrint(title));
1614  return "";
1615 }

引用了 AtomicInt, Config_getInt, QCString::left(), reg::match(), reg::search(), QCString::sprintf(), QCString::str(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::extractPageTitle(), Markdown::isAtxHeader() , 以及 Markdown::processBlocks().

◆ findTableColumns()

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.

Only one line will be inspected.

参数
[in]datapointer to the string buffer.
[in]sizethe size of the buffer.
[out]startoffset of the first character of the table content
[out]endoffset of the last character of the table content
[out]columnsnumber of table columns found
返回
The offset until the next line in the buffer.

在文件 markdown.cpp1958 行定义.

1959 {
1960  TRACE(data);
1961  int i=0,n=0;
1962  int eol;
1963  // find start character of the table line
1964  while (i<size && data[i]==' ') i++;
1965  if (i<size && data[i]=='|' && data[i]!='\n') i++,n++; // leading | does not count
1966  start = i;
1967 
1968  // find end character of the table line
1969  //while (i<size && data[i]!='\n') i++;
1970  //eol=i+1;
1971  int j = 0;
1972  while (i<size && (j = isNewline(data + i))==0) i++;
1973  eol=i+j;
1974 
1975  i--;
1976  while (i>0 && data[i]==' ') i--;
1977  if (i>0 && data[i-1]!='\\' && data[i]=='|') i--,n++; // trailing or escaped | does not count
1978  end = i;
1979 
1980  // count columns between start and end
1981  columns=0;
1982  if (end>start)
1983  {
1984  i=start;
1985  while (i<=end) // look for more column markers
1986  {
1987  if (data[i]=='|' && (i==0 || data[i-1]!='\\')) columns++;
1988  if (columns==1) columns++; // first | make a non-table into a two column table
1989  i++;
1990  }
1991  }
1992  if (n==2 && columns==0) // table row has | ... |
1993  {
1994  columns++;
1995  }
1996  //printf("findTableColumns(start=%d,end=%d,columns=%d) eol=%d\n",
1997  // start,end,columns,eol);
1998  TRACE_RESULT(eol);
1999  return eol;
2000 }

引用了 end(), eol, isNewline(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 isTableBlock() , 以及 Markdown::writeTableBlock().

◆ hasLineBreak()

static bool hasLineBreak ( const char *  data,
int  size 
)
static

在文件 markdown.cpp2247 行定义.

2248 {
2249  TRACE(data);
2250  int i=0;
2251  int j=0;
2252  // search for end of line and also check if it is not a completely blank
2253  while (i<size && data[i]!='\n')
2254  {
2255  if (data[i]!=' ' && data[i]!='\t') j++; // some non whitespace
2256  i++;
2257  }
2258  if (i>=size) { TRACE_RESULT(0); return 0; } // empty line
2259  if (i<2) { TRACE_RESULT(0); return 0; } // not long enough
2260  bool res = (j>0 && data[i-1]==' ' && data[i-2]==' '); // non blank line with at two spaces at the end
2261  TRACE_RESULT(res);
2262  return res;
2263 }

引用了 TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::writeOneLineHeaderOrRuler().

◆ isBlockQuote()

bool isBlockQuote ( const char *  data,
int  size,
int  indent 
)

returns TRUE if this line starts a block quote

在文件 markdown.cpp1437 行定义.

1438 {
1439  TRACE(data);
1440  int i = 0;
1441  while (i<size && data[i]==' ') i++;
1442  if (i<indent+codeBlockIndent) // could be a quotation
1443  {
1444  // count >'s and skip spaces
1445  int level=0;
1446  while (i<size && (data[i]=='>' || data[i]==' '))
1447  {
1448  if (data[i]=='>') level++;
1449  i++;
1450  }
1451  // last characters should be a space or newline,
1452  // so a line starting with >= does not match, but only when level equals 1
1453  bool res = (level>0 && i<size && ((data[i-1]==' ') || data[i]=='\n')) || (level > 1);
1454  TRACE_RESULT(res);
1455  return res;
1456  }
1457  else // too much indentation -> code block
1458  {
1460  return FALSE;
1461  }
1462  //return i<size && data[i]=='>' && i<indent+codeBlockIndent;
1463 }

引用了 codeBlockIndent, FALSE, TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processQuotations().

◆ isCodeBlock()

static bool isCodeBlock ( const char *  data,
int  offset,
int  size,
int &  indent 
)
static

在文件 markdown.cpp1868 行定义.

1869 {
1870  TRACE(data);
1871  //printf("<isCodeBlock(offset=%d,size=%d,indent=%d)\n",offset,size,indent);
1872  // determine the indent of this line
1873  int i=0;
1874  int indent0=0;
1875  while (i<size && data[i]==' ') indent0++,i++;
1876 
1877  if (indent0<codeBlockIndent)
1878  {
1879  //printf(">isCodeBlock: line is not indented enough %d<4\n",indent0);
1881  return FALSE;
1882  }
1883  if (indent0>=size || data[indent0]=='\n') // empty line does not start a code block
1884  {
1885  //printf("only spaces at the end of a comment block\n");
1887  return FALSE;
1888  }
1889 
1890  i=offset;
1891  int nl=0;
1892  int nl_pos[3];
1893  // search back 3 lines and remember the start of lines -1 and -2
1894  while (i>0 && nl<3)
1895  {
1896  int j = i-offset-1;
1897  int nl_size = isNewline(data+j);
1898  if (nl_size>0)
1899  {
1900  nl_pos[nl++]=j+nl_size;
1901  }
1902  i--;
1903  }
1904 
1905  // if there are only 2 preceding lines, then line -2 starts at -offset
1906  if (i==0 && nl==2) nl_pos[nl++]=-offset;
1907  //printf(" nl=%d\n",nl);
1908 
1909  if (nl==3) // we have at least 2 preceding lines
1910  {
1911  //printf(" positions: nl_pos=[%d,%d,%d] line[-2]='%s' line[-1]='%s'\n",
1912  // nl_pos[0],nl_pos[1],nl_pos[2],
1913  // qPrint(QCString(data+nl_pos[1]).left(nl_pos[0]-nl_pos[1]-1)),
1914  // qPrint(QCString(data+nl_pos[2]).left(nl_pos[1]-nl_pos[2]-1)));
1915 
1916  // check that line -1 is empty
1917  if (!isEmptyLine(data+nl_pos[1],nl_pos[0]-nl_pos[1]-1))
1918  {
1920  return FALSE;
1921  }
1922 
1923  // determine the indent of line -2
1924  indent=std::max(indent,computeIndentExcludingListMarkers(data+nl_pos[2],nl_pos[1]-nl_pos[2]));
1925 
1926  //printf(">isCodeBlock local_indent %d>=%d+%d=%d\n",
1927  // indent0,indent,codeBlockIndent,indent0>=indent+codeBlockIndent);
1928  // if the difference is >4 spaces -> code block
1929  bool res = indent0>=indent+codeBlockIndent;
1930  TRACE_RESULT(res);
1931  return res;
1932  }
1933  else // not enough lines to determine the relative indent, use global indent
1934  {
1935  // check that line -1 is empty
1936  if (nl==1 && !isEmptyLine(data-offset,offset-1))
1937  {
1939  return FALSE;
1940  }
1941  //printf(">isCodeBlock global indent %d>=%d+4=%d nl=%d\n",
1942  // indent0,indent,indent0>=indent+4,nl);
1943  bool res = indent0>=indent+codeBlockIndent;
1944  TRACE_RESULT(res);
1945  return res;
1946  }
1947 }

引用了 codeBlockIndent, computeIndentExcludingListMarkers(), FALSE, isEmptyLine(), isNewline(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processBlocks().

◆ isEmptyLine()

static bool isEmptyLine ( const char *  data,
int  size 
)
static

在文件 markdown.cpp1682 行定义.

1683 {
1684  TRACE(data);
1685  int i=0;
1686  while (i<size)
1687  {
1688  if (data[i]=='\n') { TRACE_RESULT(TRUE); return TRUE; }
1689  if (data[i]!=' ') { TRACE_RESULT(FALSE); return FALSE; }
1690  i++;
1691  }
1692  TRACE_RESULT(TRUE);
1693  return TRUE;
1694 }

引用了 FALSE, TRACE, TRACE_RESULT , 以及 TRUE.

被这些函数引用 isCodeBlock(), Markdown::processBlocks() , 以及 Markdown::processQuotations().

◆ isEndOfList()

static bool isEndOfList ( const char *  data,
int  size 
)
static

在文件 markdown.cpp1784 行定义.

1785 {
1786  TRACE(data);
1787  int dots=0;
1788  int i=0;
1789  // end of list marker is an otherwise empty line with a dot.
1790  while (i<size)
1791  {
1792  if (data[i]=='.')
1793  {
1794  dots++;
1795  }
1796  else if (data[i]=='\n')
1797  {
1798  break;
1799  }
1800  else if (data[i]!=' ' && data[i]!='\t') // bail out if the line is not empty
1801  {
1803  return FALSE;
1804  }
1805  i++;
1806  }
1807  TRACE_RESULT(dots==1);
1808  return dots==1;
1809 }

引用了 FALSE, TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processBlocks() , 以及 Markdown::processQuotations().

◆ isExplicitPage()

static bool isExplicitPage ( const QCString docs)
static

returns TRUE if input string docs starts with @page or @mainpage command

在文件 markdown.cpp2856 行定义.

2857 {
2858  TRACE(docs);
2859  int i=0;
2860  const char *data = docs.data();
2861  if (data)
2862  {
2863  int size=docs.size();
2864  while (i<size && (data[i]==' ' || data[i]=='\n'))
2865  {
2866  i++;
2867  }
2868  if (i<size+1 &&
2869  (data[i]=='\\' || data[i]=='@') &&
2870  (qstrncmp(&data[i+1],"page ",5)==0 || qstrncmp(&data[i+1],"mainpage",8)==0)
2871  )
2872  {
2873  TRACE_RESULT(TRUE);
2874  return TRUE;
2875  }
2876  }
2878  return FALSE;
2879 }

引用了 QCString::data(), FALSE, qstrncmp(), QCString::size(), TRACE, TRACE_RESULT , 以及 TRUE.

被这些函数引用 MarkdownOutlineParser::parseInput().

◆ isFencedCodeBlock()

static bool isFencedCodeBlock ( const char *  data,
int  size,
int  refIndent,
QCString lang,
int &  start,
int &  end,
int &  offset 
)
static

在文件 markdown.cpp1811 行定义.

1813 {
1814  TRACE(data);
1815  // rules: at least 3 ~~~, end of the block same amount of ~~~'s, otherwise
1816  // return FALSE
1817  int i=0;
1818  int indent=0;
1819  int startTildes=0;
1820  while (i<size && data[i]==' ') indent++,i++;
1821  if (indent>=refIndent+4)
1822  {
1823  //printf("content is part of code block: indent=%d refIndent=%d\n",indent,refIndent);
1825  return FALSE;
1826  } // part of code block
1827  char tildaChar='~';
1828  if (i<size && data[i]=='`') tildaChar='`';
1829  while (i<size && data[i]==tildaChar) startTildes++,i++;
1830  if (startTildes<3)
1831  {
1832  //printf("no fence marker found #tildes=%d\n",startTildes);
1834  return FALSE;
1835  } // not enough tildes
1836  if (i<size && data[i]=='{') i++; // skip over optional {
1837  int startLang=i;
1838  while (i<size && (data[i]!='\n' && data[i]!='}' && data[i]!=' ')) i++;
1839  convertStringFragment(lang,data+startLang,i-startLang);
1840  while (i<size && data[i]!='\n') i++; // proceed to the end of the line
1841  start=i;
1842  while (i<size)
1843  {
1844  if (data[i]==tildaChar)
1845  {
1846  end=i;
1847  int endTildes=0;
1848  while (i<size && data[i]==tildaChar) endTildes++,i++;
1849  while (i<size && data[i]==' ') i++;
1850  if (i==size || data[i]=='\n')
1851  {
1852  if (endTildes==startTildes)
1853  {
1854  offset=i;
1855  //printf("found end marker at offset %d\n",offset);
1856  TRACE_RESULT(TRUE);
1857  return TRUE;
1858  }
1859  }
1860  }
1861  i++;
1862  }
1863  //printf("no end marker found!\n");
1865  return FALSE;
1866 }

引用了 convertStringFragment(), end(), FALSE, TRACE, TRACE_RESULT , 以及 TRUE.

被这些函数引用 Markdown::processBlocks() , 以及 Markdown::processQuotations().

◆ isHRuler()

static bool isHRuler ( const char *  data,
int  size 
)
static

在文件 markdown.cpp1559 行定义.

1560 {
1561  TRACE(data);
1562  int i=0;
1563  if (size>0 && data[size-1]=='\n') size--; // ignore newline character
1564  while (i<size && data[i]==' ') i++;
1565  if (i>=size) { TRACE_RESULT(FALSE); return FALSE; } // empty line
1566  char c=data[i];
1567  if (c!='*' && c!='-' && c!='_')
1568  {
1569  TRACE_RESULT(FALSE); return FALSE; // not a hrule character
1570  }
1571  int n=0;
1572  while (i<size)
1573  {
1574  if (data[i]==c)
1575  {
1576  n++; // count rule character
1577  }
1578  else if (data[i]!=' ')
1579  {
1581  return FALSE; // line contains non hruler characters
1582  }
1583  i++;
1584  }
1585  TRACE_RESULT(n>=3);
1586  return n>=3; // at least 3 characters needed for a hruler
1587 }

引用了 FALSE, TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::writeOneLineHeaderOrRuler().

◆ isLinkRef()

static int isLinkRef ( const char *  data,
int  size,
QCString refid,
QCString link,
QCString title 
)
static

returns end of the link ref if this is indeed a link reference.

在文件 markdown.cpp1466 行定义.

1468 {
1469  TRACE(data);
1470  //printf("isLinkRef data={%s}\n",data);
1471  // format: start with [some text]:
1472  int i = 0;
1473  while (i<size && data[i]==' ') i++;
1474  if (i>=size || data[i]!='[') { TRACE_RESULT(0); return 0; }
1475  i++;
1476  int refIdStart=i;
1477  while (i<size && data[i]!='\n' && data[i]!=']') i++;
1478  if (i>=size || data[i]!=']') { TRACE_RESULT(0); return 0; }
1479  convertStringFragment(refid,data+refIdStart,i-refIdStart);
1480  if (refid.isEmpty()) { TRACE_RESULT(0); return 0; }
1481  //printf(" isLinkRef: found refid='%s'\n",qPrint(refid));
1482  i++;
1483  if (i>=size || data[i]!=':') { TRACE_RESULT(0); return 0; }
1484  i++;
1485 
1486  // format: whitespace* \n? whitespace* (<url> | url)
1487  while (i<size && data[i]==' ') i++;
1488  if (i<size && data[i]=='\n')
1489  {
1490  i++;
1491  while (i<size && data[i]==' ') i++;
1492  }
1493  if (i>=size) { TRACE_RESULT(0); return 0; }
1494 
1495  if (i<size && data[i]=='<') i++;
1496  int linkStart=i;
1497  while (i<size && data[i]!=' ' && data[i]!='\n') i++;
1498  int linkEnd=i;
1499  if (i<size && data[i]=='>') i++;
1500  if (linkStart==linkEnd) { TRACE_RESULT(0); return 0; } // empty link
1501  convertStringFragment(link,data+linkStart,linkEnd-linkStart);
1502  //printf(" isLinkRef: found link='%s'\n",qPrint(link));
1503  if (link=="@ref" || link=="\\ref")
1504  {
1505  int argStart=i;
1506  while (i<size && data[i]!='\n' && data[i]!='"') i++;
1507  QCString refArg;
1508  convertStringFragment(refArg,data+argStart,i-argStart);
1509  link+=refArg;
1510  }
1511 
1512  title.resize(0);
1513 
1514  // format: (whitespace* \n? whitespace* ( 'title' | "title" | (title) ))?
1515  int eol=0;
1516  while (i<size && data[i]==' ') i++;
1517  if (i<size && data[i]=='\n')
1518  {
1519  eol=i;
1520  i++;
1521  while (i<size && data[i]==' ') i++;
1522  }
1523  if (i>=size)
1524  {
1525  //printf("end of isLinkRef while looking for title! i=%d\n",i);
1526  TRACE_RESULT(i);
1527  return i; // end of buffer while looking for the optional title
1528  }
1529 
1530  char c = data[i];
1531  if (c=='\'' || c=='"' || c=='(') // optional title present?
1532  {
1533  //printf(" start of title found! char='%c'\n",c);
1534  i++;
1535  if (c=='(') c=')'; // replace c by end character
1536  int titleStart=i;
1537  // search for end of the line
1538  while (i<size && data[i]!='\n') i++;
1539  eol = i;
1540 
1541  // search back to matching character
1542  int end=i-1;
1543  while (end>titleStart && data[end]!=c) end--;
1544  if (end>titleStart)
1545  {
1546  convertStringFragment(title,data+titleStart,end-titleStart);
1547  }
1548  //printf(" title found: '%s'\n",qPrint(title));
1549  }
1550  while (i<size && data[i]==' ') i++;
1551  //printf("end of isLinkRef: i=%d size=%d data[i]='%c' eol=%d\n",
1552  // i,size,data[i],eol);
1553  if (i>=size) { TRACE_RESULT(i); return i; } // end of buffer while ref id was found
1554  else if (eol) { TRACE_RESULT(eol); return eol; } // end of line while ref id was found
1555  TRACE_RESULT(0);
1556  return 0; // invalid link ref
1557 }

引用了 convertStringFragment(), end(), eol, QCString::isEmpty(), QCString::resize(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processBlocks().

◆ isListMarker()

static int isListMarker ( const char *  data,
int  size 
)
static

在文件 markdown.cpp1773 行定义.

1774 {
1775  TRACE(data);
1776  int normalIndent = 0;
1777  while (normalIndent<size && data[normalIndent]==' ') normalIndent++;
1778  int listIndent = computeIndentExcludingListMarkers(data,size);
1779  int result = listIndent>normalIndent ? listIndent : 0;
1780  TRACE_RESULT(result);
1781  return result;
1782 }

引用了 computeIndentExcludingListMarkers(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processBlocks() , 以及 Markdown::processQuotations().

◆ isNewline()

int isNewline ( const char *  data)
inline

在文件 markdown.cpp239 行定义.

240 {
241  // normal newline
242  if (data[0] == '\n') return 1;
243  // artificial new line from ^^ in ALIASES
244  if (data[0] == '\\' && qstrncmp(data+1,"ilinebr ",7)==0) return data[8]==' ' ? 9 : 8;
245  return 0;
246 }

引用了 qstrncmp().

被这些函数引用 Markdown::findEndOfLine(), findTableColumns() , 以及 isCodeBlock().

◆ isTableBlock()

static bool isTableBlock ( const char *  data,
int  size 
)
static

Returns TRUE iff data points to the start of a table block

在文件 markdown.cpp2003 行定义.

2004 {
2005  TRACE(data);
2006  int cc0,start,end;
2007 
2008  // the first line should have at least two columns separated by '|'
2009  int i = findTableColumns(data,size,start,end,cc0);
2010  if (i>=size || cc0<1)
2011  {
2012  //printf("isTableBlock: no |'s in the header\n");
2014  return FALSE;
2015  }
2016 
2017  int cc1;
2018  int ret = findTableColumns(data+i,size-i,start,end,cc1);
2019  int j=i+start;
2020  // separator line should consist of |, - and : and spaces only
2021  while (j<=end+i)
2022  {
2023  if (data[j]!=':' && data[j]!='-' && data[j]!='|' && data[j]!=' ')
2024  {
2025  //printf("isTableBlock: invalid character '%c'\n",data[j]);
2027  return FALSE; // invalid characters in table separator
2028  }
2029  j++;
2030  }
2031  if (cc1!=cc0) // number of columns should be same as previous line
2032  {
2034  return FALSE;
2035  }
2036 
2037  i+=ret; // goto next line
2038  int cc2;
2039  findTableColumns(data+i,size-i,start,end,cc2);
2040 
2041  //printf("isTableBlock: %d\n",cc1==cc2);
2042  TRACE_RESULT(cc1==cc2);
2043  return cc1==cc2;
2044 }

引用了 end(), FALSE, findTableColumns(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 Markdown::processBlocks().

◆ markdownFileNameToId()

QCString markdownFileNameToId ( const QCString fileName)

processes string s and converts markdown into doxygen/html commands.

在文件 markdown.cpp3053 行定义.

3054 {
3055  TRACE(fileName);
3056  std::string absFileName = FileInfo(fileName.str()).absFilePath();
3057  QCString baseFn = stripFromPath(absFileName.c_str());
3058  int i = baseFn.findRev('.');
3059  if (i!=-1) baseFn = baseFn.left(i);
3060  QCString baseName = baseFn;
3061  char *p = baseName.rawData();
3062  char c;
3063  while ((c=*p))
3064  {
3065  if (!isId(c)) *p='_'; // escape characters that do not yield an identifier by underscores
3066  p++;
3067  }
3068  //printf("markdownFileNameToId(%s)=md_%s\n",qPrint(fileName),qPrint(baseName));
3069  QCString res = "md_"+baseName;
3070  TRACE_RESULT(res);
3071  return res;
3072 }

引用了 FileInfo::absFilePath(), QCString::findRev(), isId(), QCString::left(), QCString::rawData(), QCString::str(), stripFromPath(), TRACE , 以及 TRACE_RESULT.

被这些函数引用 DocRef::DocRef(), DocSecRefItem::parse() , 以及 MarkdownOutlineParser::parseInput().

◆ markersToAlignment()

static Alignment markersToAlignment ( bool  leftMarker,
bool  rightMarker 
)
static

helper function to convert presence of left and/or right alignment markers to a alignment value

在文件 markdown.cpp323 行定义.

324 {
325  //printf("markerToAlignment(%d,%d)\n",leftMarker,rightMarker);
326  if (leftMarker && rightMarker)
327  {
328  return AlignCenter;
329  }
330  else if (leftMarker)
331  {
332  return AlignLeft;
333  }
334  else if (rightMarker)
335  {
336  return AlignRight;
337  }
338  else
339  {
340  return AlignNone;
341  }
342 }

引用了 AlignCenter, AlignLeft, AlignNone , 以及 AlignRight.

被这些函数引用 Markdown::writeTableBlock().

变量说明

◆ codeBlockIndent

const int codeBlockIndent = 4

在文件 markdown.cpp233 行定义.

被这些函数引用 isBlockQuote(), isCodeBlock(), Markdown::processBlocks() , 以及 Markdown::writeCodeBlock().

◆ g_doxy_nsbp

const char* g_doxy_nsbp = "&_doxy_nbsp;"

在文件 markdown.cpp232 行定义.

被这些函数引用 Markdown::addStrEscapeUtf8Nbsp(), Markdown::detab() , 以及 Markdown::process().

◆ g_utf8_nbsp

const uchar g_utf8_nbsp[3] = { 0xc2, 0xa0, 0}

在文件 markdown.cpp231 行定义.

被这些函数引用 Markdown::addStrEscapeUtf8Nbsp().

computeIndentExcludingListMarkers
static int computeIndentExcludingListMarkers(const char *data, int size)
Definition: markdown.cpp:1704
TRACE
#define TRACE(data)
Definition: markdown.cpp:162
AlignLeft
@ AlignLeft
Definition: markdown.cpp:226
QCString::rawData
char * rawData()
Returns a writable pointer to the data.
Definition: qcstring.h:157
GrowBuf::get
char * get()
Definition: growbuf.h:94
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
reg::match
bool match(const std::string &str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition: regex.cpp:729
QCString::size
uint size() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:150
AtomicInt
#define AtomicInt
Definition: doxygen.h:28
eol
#define eol
The end of line string for this machine.
Definition: ParseException.h:86
QCString::str
std::string str() const
Definition: qcstring.h:442
qstrncmp
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition: qcstring.h:91
GrowBuf::addChar
void addChar(char c)
Definition: growbuf.h:54
GrowBuf
Class representing a string buffer optimised for growing.
Definition: growbuf.h:12
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
isLiTag
#define isLiTag(i)
Definition: markdown.cpp:1696
uint
unsigned uint
Definition: qcstring.h:40
AlignNone
@ AlignNone
Definition: markdown.cpp:226
Config_getInt
#define Config_getInt(name)
Definition: config.h:34
isId
bool isId(int c)
Definition: util.h:172
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
codeBlockIndent
const int codeBlockIndent
Definition: markdown.cpp:233
AlignCenter
@ AlignCenter
Definition: markdown.cpp:226
isNewline
int isNewline(const char *data)
Definition: markdown.cpp:239
findTableColumns
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.
Definition: markdown.cpp:1958
isEmptyLine
static bool isEmptyLine(const char *data, int size)
Definition: markdown.cpp:1682
reg::Match
Object representing the matching results.
Definition: regex.h:163
TRUE
#define TRUE
Definition: qcstring.h:36
reg::Ex
Class representing a regular expression.
Definition: regex.h:48
FileInfo
Minimal replacement for QFileInfo.
Definition: fileinfo.h:22
FileInfo::absFilePath
std::string absFilePath() const
Definition: fileinfo.cpp:101
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
stripFromPath
static QCString stripFromPath(const QCString &path, const StringVector &l)
Definition: util.cpp:292
reg::search
bool search(const std::string &str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition: regex.cpp:718
convertStringFragment
static void convertStringFragment(QCString &result, const char *data, int size)
Definition: markdown.cpp:312
AlignRight
@ AlignRight
Definition: markdown.cpp:226
QCString::resize
bool resize(size_t newlen)
Resizes the string to hold newlen characters (this value should also count the 0-terminator).
Definition: qcstring.h:164
QCString::sprintf
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:24
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108
TRACE_RESULT
#define TRACE_RESULT(v)
Definition: markdown.cpp:164