doxygen  1.8.18
About: Doxygen is a source code documentation generator tool for C++, C, Objective-C, C#, PHP, Java, Python, IDL (diverse flavors), Fortran, VHDL, Tcl, and to some extent D. Different output formats are supported.
  Fossies Dox: doxygen-1.8.18.src.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

markdown.cpp File Reference
#include <stdio.h>
#include <qglobal.h>
#include <qregexp.h>
#include <qfileinfo.h>
#include <qdict.h>
#include <qvector.h>
#include "markdown.h"
#include "growbuf.h"
#include "debug.h"
#include "util.h"
#include "doxygen.h"
#include "commentscan.h"
#include "entry.h"
#include "bufstr.h"
#include "commentcnv.h"
#include "config.h"
#include "section.h"
#include "message.h"
#include "portable.h"
+ Include dependency graph for markdown.cpp:

Go to the source code of this file.

Classes

struct  LinkRef
 
struct  TableCell
 
struct  MarkdownOutlineParser::Private
 

Macros

#define isIdChar(i)
 Copyright (C) 1997-2015 by Dimitri van Heesch. More...
 
#define extraChar(i)
 
#define isOpenEmphChar(i)
 
#define ignoreCloseEmphChar(i)
 
#define isLiTag(i)
 

Typedefs

typedef int(* action_t) (GrowBuf &out, const char *data, int offset, int size)
 

Enumerations

enum  Alignment { AlignNone, AlignLeft, AlignCenter, AlignRight }
 

Functions

static void processInline (GrowBuf &out, const char *data, int size)
 
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 More...
 
static QCString isBlockCommand (const char *data, int offset, int size)
 
static 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. More...
 
static int processEmphasis1 (GrowBuf &out, const char *data, int size, char c)
 process single emphasis More...
 
static int processEmphasis2 (GrowBuf &out, const char *data, int size, char c)
 process double emphasis More...
 
static int processEmphasis3 (GrowBuf &out, const char *data, int size, char c)
 Parsing triple emphasis. More...
 
static int processNmdash (GrowBuf &out, const char *data, int off, int size)
 Process ndash and mdashes. More...
 
static int processQuoted (GrowBuf &out, const char *data, int, int size)
 Process quoted section "...", can contain one embedded newline. More...
 
static int processHtmlTagWrite (GrowBuf &out, const char *data, int offset, int size, bool doWrite)
 Process a HTML tag. More...
 
static int processHtmlTag (GrowBuf &out, const char *data, int offset, int size)
 
static int processEmphasis (GrowBuf &out, const char *data, int offset, int size)
 
static void writeMarkdownImage (GrowBuf &out, const char *fmt, bool explicitTitle, QCString title, QCString content, QCString link, FileDef *fd)
 
static int processLink (GrowBuf &out, const char *data, int, int size)
 
static int processCodeSpan (GrowBuf &out, const char *data, int, int size)
 '‘’ parsing a code span (assuming codespan != 0) More...
 
static void addStrEscapeUtf8Nbsp (GrowBuf &out, const char *s, int len)
 
static int processSpecialCommand (GrowBuf &out, const char *data, int offset, int size)
 
static int isHeaderline (const char *data, int size, bool allowAdjustLevel)
 returns whether the line is a setext-style hdr underline More...
 
static bool isBlockQuote (const char *data, int size, int indent)
 returns TRUE if this line starts a block quote More...
 
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. More...
 
static int isHRuler (const char *data, int size)
 
static QCString extractTitleId (QCString &title, int level)
 
static int isAtxHeader (const char *data, int size, QCString &header, QCString &id, bool allowAdjustLevel)
 
static int isEmptyLine (const char *data, int size)
 
static int computeIndentExcludingListMarkers (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. More...
 
static bool isTableBlock (const char *data, int size)
 Returns TRUE iff data points to the start of a table block. More...
 
static int writeTableBlock (GrowBuf &out, const char *data, int size)
 
static int hasLineBreak (const char *data, int size)
 
void writeOneLineHeaderOrRuler (GrowBuf &out, const char *data, int size)
 
static int writeBlockQuote (GrowBuf &out, const char *data, int size)
 
static int writeCodeBlock (GrowBuf &out, const char *data, int size, int refIndent)
 
static void findEndOfLine (GrowBuf &out, const char *data, int size, int &pi, int &i, int &end)
 
static void writeFencedCodeBlock (GrowBuf &out, const char *data, const char *lng, int blockStart, int blockEnd)
 
static QCString processQuotations (const QCString &s, int refIndent)
 
static QCString processBlocks (const QCString &s, int indent)
 
static bool isExplicitPage (const QCString &docs)
 returns TRUE if input string docs starts with @page or @mainpage command More...
 
static QCString extractPageTitle (QCString &docs, QCString &id)
 
static QCString detab (const QCString &s, int &refIndent)
 
QCString processMarkdown (const QCString &fileName, const int lineNr, Entry *e, const QCString &input)
 processes string s and converts markdown into doxygen/html commands. More...
 
QCString markdownFileNameToId (const QCString &fileName)
 
QCString processMarkdownForCommentBlock (const QCString &comment, const QCString &fileName, int lineNr)
 Performs markdown processing for a comment block if markdown processing is enabled. More...
 

Variables

static QDict< LinkRefg_linkRefs (257)
 
static action_t g_actions [256]
 
static Entryg_current
 
static QCString g_fileName
 
static int g_lineNr
 
static int g_indentLevel =0
 
static const uchar g_utf8_nbsp [3] = { 0xc2, 0xa0, 0}
 
static const char * g_doxy_nsbp = "&_doxy_nbsp;"
 
const int codeBlockIndent = 4
 

Macro Definition Documentation

◆ extraChar

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

Definition at line 66 of file markdown.cpp.

◆ ignoreCloseEmphChar

#define ignoreCloseEmphChar (   i)
Value:
(data[i]=='(' || data[i]=='{' || data[i]=='[' || data[i]=='<' || \
data[i]=='\\' || \
data[i]=='@')

Definition at line 79 of file markdown.cpp.

◆ isIdChar

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

Copyright (C) 1997-2015 by Dimitri van Heesch.

Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. See the GNU General Public License for more details.

Documents produced by Doxygen are derivative works derived from the input used in their production; they are not affected by this license.

Definition at line 60 of file markdown.cpp.

◆ isLiTag

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

Definition at line 1398 of file markdown.cpp.

◆ isOpenEmphChar

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

Definition at line 72 of file markdown.cpp.

Typedef Documentation

◆ action_t

typedef int(* action_t) (GrowBuf &out, const char *data, int offset, int size)

Definition at line 99 of file markdown.cpp.

Enumeration Type Documentation

◆ Alignment

enum Alignment
Enumerator
AlignNone 
AlignLeft 
AlignCenter 
AlignRight 

Definition at line 101 of file markdown.cpp.

Function Documentation

◆ addStrEscapeUtf8Nbsp()

static void addStrEscapeUtf8Nbsp ( GrowBuf out,
const char *  s,
int  len 
)
static

◆ computeIndentExcludingListMarkers()

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

Definition at line 1405 of file markdown.cpp.

References data, FALSE, isLiTag, and TRUE.

Referenced by isCodeBlock().

◆ convertStringFragment()

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

◆ detab()

static QCString detab ( const QCString s,
int &  refIndent 
)
static

◆ escapeSpecialChars()

static QCString escapeSpecialChars ( const QCString s)
static

Definition at line 121 of file markdown.cpp.

References GrowBuf::addChar(), FALSE, GrowBuf::get(), and QCString::isEmpty().

Referenced by processCodeSpan().

◆ extractPageTitle()

◆ extractTitleId()

static QCString extractTitleId ( QCString title,
int  level 
)
static

◆ findEmphasisChar()

static int findEmphasisChar ( const char *  data,
int  size,
char  c,
int  c_size 
)
static

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 251 of file markdown.cpp.

References data, ignoreCloseEmphChar, isBlockCommand(), QCString::isEmpty(), isIdChar, languages::l, QCString::length(), and qstrncmp().

Referenced by processEmphasis1(), processEmphasis2(), and processEmphasis3().

◆ findEndOfLine()

static void findEndOfLine ( GrowBuf out,
const char *  data,
int  size,
int &  pi,
int &  i,
int &  end 
)
static

◆ 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.

Parameters
[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
Returns
The offset until the next line in the buffer.

Definition at line 1587 of file markdown.cpp.

References data, and eol.

Referenced by isTableBlock(), and writeTableBlock().

◆ hasLineBreak()

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

Definition at line 1942 of file markdown.cpp.

References data.

Referenced by writeOneLineHeaderOrRuler().

◆ isAtxHeader()

static int isAtxHeader ( const char *  data,
int  size,
QCString header,
QCString id,
bool  allowAdjustLevel 
)
static

◆ isBlockCommand()

static QCString isBlockCommand ( const char *  data,
int  offset,
int  size 
)
static

Definition at line 197 of file markdown.cpp.

References convertStringFragment(), and data.

Referenced by findEmphasisChar(), findEndOfLine(), and processSpecialCommand().

◆ isBlockQuote()

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

returns TRUE if this line starts a block quote

Definition at line 1158 of file markdown.cpp.

References codeBlockIndent, data, and FALSE.

Referenced by processQuotations().

◆ isCodeBlock()

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

Definition at line 1511 of file markdown.cpp.

References codeBlockIndent, computeIndentExcludingListMarkers(), data, FALSE, and isEmptyLine().

Referenced by processBlocks().

◆ isEmptyLine()

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

Definition at line 1385 of file markdown.cpp.

References data, FALSE, and TRUE.

Referenced by isCodeBlock().

◆ isExplicitPage()

static bool isExplicitPage ( const QCString docs)
static

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

Definition at line 2401 of file markdown.cpp.

References data, QCString::data(), FALSE, qstrncmp(), QCString::size(), and TRUE.

Referenced by MarkdownOutlineParser::parseInput().

◆ isFencedCodeBlock()

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

Definition at line 1472 of file markdown.cpp.

References convertStringFragment(), data, and FALSE.

Referenced by processBlocks(), and processQuotations().

◆ isHeaderline()

static int isHeaderline ( const char *  data,
int  size,
bool  allowAdjustLevel 
)
static

returns whether the line is a setext-style hdr underline

Definition at line 1125 of file markdown.cpp.

References data, and g_indentLevel.

Referenced by extractPageTitle(), and processBlocks().

◆ isHRuler()

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

Definition at line 1273 of file markdown.cpp.

References data.

Referenced by 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.

Definition at line 1183 of file markdown.cpp.

References convertStringFragment(), data, eol, QCString::isEmpty(), and QCString::resize().

Referenced by processBlocks().

◆ isTableBlock()

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

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

Definition at line 1626 of file markdown.cpp.

References data, FALSE, and findTableColumns().

Referenced by processBlocks().

◆ markdownFileNameToId()

QCString markdownFileNameToId ( const QCString fileName)

◆ 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

Definition at line 157 of file markdown.cpp.

References AlignCenter, AlignLeft, AlignNone, and AlignRight.

Referenced by writeTableBlock().

◆ processBlocks()

◆ processCodeSpan()

static int processCodeSpan ( GrowBuf out,
const char *  data,
int  ,
int  size 
)
static

'‘’ parsing a code span (assuming codespan != 0)

Definition at line 971 of file markdown.cpp.

References GrowBuf::addStr(), convertStringFragment(), data, escapeSpecialChars(), and isIdChar.

Referenced by processMarkdown().

◆ processEmphasis()

static int processEmphasis ( GrowBuf out,
const char *  data,
int  offset,
int  size 
)
static

◆ processEmphasis1()

static int processEmphasis1 ( GrowBuf out,
const char *  data,
int  size,
char  c 
)
static

process single emphasis

Definition at line 349 of file markdown.cpp.

References GrowBuf::addStr(), data, findEmphasisChar(), and processInline().

Referenced by processEmphasis(), and processEmphasis3().

◆ processEmphasis2()

static int processEmphasis2 ( GrowBuf out,
const char *  data,
int  size,
char  c 
)
static

process double emphasis

Definition at line 380 of file markdown.cpp.

References GrowBuf::addStr(), data, findEmphasisChar(), and processInline().

Referenced by processEmphasis(), and processEmphasis3().

◆ processEmphasis3()

static int processEmphasis3 ( GrowBuf out,
const char *  data,
int  size,
char  c 
)
static

Parsing triple emphasis.

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

Definition at line 411 of file markdown.cpp.

References GrowBuf::addStr(), data, findEmphasisChar(), processEmphasis1(), processEmphasis2(), and processInline().

Referenced by processEmphasis().

◆ processHtmlTag()

static int processHtmlTag ( GrowBuf out,
const char *  data,
int  offset,
int  size 
)
static

Definition at line 606 of file markdown.cpp.

References data, and processHtmlTagWrite().

Referenced by processMarkdown().

◆ processHtmlTagWrite()

static int processHtmlTagWrite ( GrowBuf out,
const char *  data,
int  offset,
int  size,
bool  doWrite 
)
static

Process a HTML tag.

Note that

..

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

Definition at line 523 of file markdown.cpp.

References GrowBuf::addStr(), convertStringFragment(), data, FALSE, isIdChar, languages::l, QCString::lower(), and TRUE.

Referenced by findEndOfLine(), and processHtmlTag().

◆ processInline()

static void processInline ( GrowBuf out,
const char *  data,
int  size 
)
static

◆ processLink()

◆ processMarkdown()

◆ processMarkdownForCommentBlock()

QCString processMarkdownForCommentBlock ( const QCString comment,
const QCString fileName,
int  lineNr 
)

Performs markdown processing for a comment block if markdown processing is enabled.

Parameters
[in]commentA string representing the actual comment block. Note that leading *'s should already be stripped from the comment block.
[in]fileNameThe name of the file in which the comment is found. Mainly used for producing warnings.
[in]lineNrThe line number at which the comment block was found.
Returns
The processed comment block

Definition at line 2600 of file markdown.cpp.

References comment, QCString::data(), Doxygen::markdownSupport, QCString::mid(), processMarkdown(), and qstrncmp().

Referenced by VHDLOutlineParser::handleCommentBlock(), and MarkdownOutlineParser::parseInput().

◆ processNmdash()

static int processNmdash ( GrowBuf out,
const char *  data,
int  off,
int  size 
)
static

Process ndash and mdashes.

Definition at line 468 of file markdown.cpp.

References GrowBuf::addStr(), data, and qstrncmp().

Referenced by processMarkdown().

◆ processQuotations()

static QCString processQuotations ( const QCString s,
int  refIndent 
)
static

◆ processQuoted()

static int processQuoted ( GrowBuf out,
const char *  data,
int  ,
int  size 
)
static

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

Definition at line 502 of file markdown.cpp.

References GrowBuf::addStr(), and data.

Referenced by processMarkdown().

◆ processSpecialCommand()

static int processSpecialCommand ( GrowBuf out,
const char *  data,
int  offset,
int  size 
)
static

◆ writeBlockQuote()

static int writeBlockQuote ( GrowBuf out,
const char *  data,
int  size 
)
static

Definition at line 2010 of file markdown.cpp.

References GrowBuf::addStr(), data, and languages::l.

Referenced by processQuotations().

◆ writeCodeBlock()

static int writeCodeBlock ( GrowBuf out,
const char *  data,
int  size,
int  refIndent 
)
static

Definition at line 2066 of file markdown.cpp.

References GrowBuf::addStr(), codeBlockIndent, and data.

Referenced by processBlocks().

◆ writeFencedCodeBlock()

static void writeFencedCodeBlock ( GrowBuf out,
const char *  data,
const char *  lng,
int  blockStart,
int  blockEnd 
)
static

◆ writeMarkdownImage()

static void writeMarkdownImage ( GrowBuf out,
const char *  fmt,
bool  explicitTitle,
QCString  title,
QCString  content,
QCString  link,
FileDef fd 
)
static

Definition at line 653 of file markdown.cpp.

References GrowBuf::addStr(), QCString::isEmpty(), and QCString::mid().

Referenced by processLink().

◆ writeOneLineHeaderOrRuler()

void writeOneLineHeaderOrRuler ( GrowBuf out,
const char *  data,
int  size 
)

Definition at line 1958 of file markdown.cpp.

References GrowBuf::addStr(), data, hasLineBreak(), isAtxHeader(), isHRuler(), QCString::sprintf(), and TRUE.

Referenced by processBlocks().

◆ writeTableBlock()

Variable Documentation

◆ codeBlockIndent

const int codeBlockIndent = 4

Definition at line 116 of file markdown.cpp.

Referenced by isBlockQuote(), isCodeBlock(), processBlocks(), and writeCodeBlock().

◆ g_actions

action_t g_actions[256]
static

Definition at line 107 of file markdown.cpp.

Referenced by processInline(), and processMarkdown().

◆ g_current

Entry* g_current
static

Definition at line 108 of file markdown.cpp.

Referenced by processMarkdown().

◆ g_doxy_nsbp

const char* g_doxy_nsbp = "&_doxy_nbsp;"
static

Definition at line 113 of file markdown.cpp.

Referenced by addStrEscapeUtf8Nbsp(), detab(), and processMarkdown().

◆ g_fileName

QCString g_fileName
static

Definition at line 109 of file markdown.cpp.

Referenced by processLink(), and processMarkdown().

◆ g_indentLevel

int g_indentLevel =0
static

Definition at line 111 of file markdown.cpp.

Referenced by isAtxHeader(), isHeaderline(), and MarkdownOutlineParser::parseInput().

◆ g_lineNr

int g_lineNr
static

Definition at line 110 of file markdown.cpp.

Referenced by processMarkdown().

◆ g_linkRefs

QDict<LinkRef> g_linkRefs(257)
static

◆ g_utf8_nbsp

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

Definition at line 112 of file markdown.cpp.

Referenced by addStrEscapeUtf8Nbsp().

data
const char *const void * data
Definition: iconv.h:120