Doxygen
markdown.h
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2015 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef MARKDOWN_H
17 #define MARKDOWN_H
18 
19 #include <functional>
20 
21 #include "qcstring.h"
22 #include "parserintf.h"
23 #include "growbuf.h"
24 
25 class Entry;
26 
27 /** processes string \a s and converts markdown into doxygen/html commands. */
28 //QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &s);
30 
31 /// Helper class to process markdown formatted text
32 class Markdown
33 {
34  public:
35  Markdown(const QCString &fileName,int lineNr,int indentLevel=0);
36  QCString process(const QCString &input, int &startNewlines, bool fromParseInput = false);
37  QCString extractPageTitle(QCString &docs,QCString &id,int &prepend);
38  void setIndentLevel(int level) { m_indentLevel = level; }
39 
40  private:
41  QCString detab(const QCString &s,int &refIndent);
42  QCString processQuotations(const QCString &s,int refIndent);
43  QCString processBlocks(const QCString &s,int indent);
44  QCString isBlockCommand(const char *data,int offset,int size);
45  void findEndOfLine(const char *data,int size,int &pi,int&i,int &end);
46  int processHtmlTagWrite(const char *data,int offset,int size,bool doWrite);
47  int processHtmlTag(const char *data,int offset,int size);
48  int processEmphasis(const char *data,int offset,int size);
49  int processEmphasis1(const char *data, int size, char c);
50  int processEmphasis2(const char *data, int size, char c);
51  int processEmphasis3(const char *data, int size, char c);
52  int processNmdash(const char *data,int off,int size);
53  int processQuoted(const char *data,int,int size);
54  int processCodeSpan(const char *data, int /*offset*/, int size);
55  void addStrEscapeUtf8Nbsp(const char *s,int len);
56  int processSpecialCommand(const char *data, int offset, int size);
57  int processLink(const char *data,int,int size);
58  int findEmphasisChar(const char *data, int size, char c, int c_size);
59  void processInline(const char *data,int size);
60  void writeMarkdownImage(const char *fmt, bool explicitTitle,
61  const QCString &title, const QCString &content,
62  const QCString &link, const FileDef *fd);
63  int isHeaderline(const char *data, int size, bool allowAdjustLevel);
64  int isAtxHeader(const char *data,int size,
65  QCString &header,QCString &id,bool allowAdjustLevel);
66  void writeOneLineHeaderOrRuler(const char *data,int size);
67  void writeFencedCodeBlock(const char *data,const char *lng,
68  int blockStart,int blockEnd);
69  int writeBlockQuote(const char *data,int size);
70  int writeCodeBlock(const char *data,int size,int refIndent);
71  int writeTableBlock(const char *data,int size);
72 
73  private:
74  struct LinkRef
75  {
76  LinkRef(const QCString &l,const QCString &t) : link(l), title(t) {}
79  };
80  using Action_t = std::function<int(const char *,int,int)>;
81 
82  std::unordered_map<std::string,LinkRef> m_linkRefs;
84  int m_lineNr = 0;
85  int m_indentLevel=0; // 0 is outside markdown, -1=page level
88 };
89 
90 
92 {
93  public:
95  virtual ~MarkdownOutlineParser();
96  void parseInput(const QCString &fileName,
97  const char *fileBuf,
98  const std::shared_ptr<Entry> &root,
99  ClangTUParser *clangParser);
100  bool needsPreprocessing(const QCString &) const { return FALSE; }
101  void parsePrototype(const QCString &text);
102  private:
103  struct Private;
104  std::unique_ptr<Private> p;
105 };
106 
107 
108 #endif
Markdown::writeOneLineHeaderOrRuler
void writeOneLineHeaderOrRuler(const char *data, int size)
Definition: markdown.cpp:2266
MarkdownOutlineParser::needsPreprocessing
bool needsPreprocessing(const QCString &) const
Returns TRUE if the language identified by extension needs the C preprocessor to be run before feed t...
Definition: markdown.h:100
Markdown::isAtxHeader
int isAtxHeader(const char *data, int size, QCString &header, QCString &id, bool allowAdjustLevel)
Definition: markdown.cpp:1618
Markdown::process
QCString process(const QCString &input, int &startNewlines, bool fromParseInput=false)
Definition: markdown.cpp:3002
Markdown::isHeaderline
int isHeaderline(const char *data, int size, bool allowAdjustLevel)
returns whether the line is a setext-style hdr underline
Definition: markdown.cpp:1401
Markdown::writeTableBlock
int writeTableBlock(const char *data, int size)
Definition: markdown.cpp:2046
markdownFileNameToId
QCString markdownFileNameToId(const QCString &fileName)
processes string s and converts markdown into doxygen/html commands.
Definition: markdown.cpp:3053
Markdown::processHtmlTagWrite
int processHtmlTagWrite(const char *data, int offset, int size, bool doWrite)
Process a HTML tag.
Definition: markdown.cpp:737
Markdown::processEmphasis1
int processEmphasis1(const char *data, int size, char c)
process single emphasis
Definition: markdown.cpp:539
MarkdownOutlineParser::p
std::unique_ptr< Private > p
Definition: markdown.h:103
Markdown::findEndOfLine
void findEndOfLine(const char *data, int size, int &pi, int &i, int &end)
Definition: markdown.cpp:2438
Markdown::processBlocks
QCString processBlocks(const QCString &s, int indent)
Definition: markdown.cpp:2634
growbuf.h
Markdown::extractPageTitle
QCString extractPageTitle(QCString &docs, QCString &id, int &prepend)
Definition: markdown.cpp:2881
Markdown::Action_t
std::function< int(const char *, int, int)> Action_t
Definition: markdown.h:80
MarkdownOutlineParser::~MarkdownOutlineParser
virtual ~MarkdownOutlineParser()
Definition: markdown.cpp:3085
Markdown::isBlockCommand
QCString isBlockCommand(const char *data, int offset, int size)
Definition: markdown.cpp:364
qcstring.h
MarkdownOutlineParser::Private
Definition: markdown.cpp:3076
MarkdownOutlineParser::MarkdownOutlineParser
MarkdownOutlineParser()
Definition: markdown.cpp:3081
GrowBuf
Class representing a string buffer optimised for growing.
Definition: growbuf.h:12
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
Markdown::processEmphasis
int processEmphasis(const char *data, int offset, int size)
Definition: markdown.cpp:833
Markdown::setIndentLevel
void setIndentLevel(int level)
Definition: markdown.h:38
Markdown::m_lineNr
int m_lineNr
Definition: markdown.h:84
Markdown::m_linkRefs
std::unordered_map< std::string, LinkRef > m_linkRefs
Definition: markdown.h:82
Markdown::processNmdash
int processNmdash(const char *data, int off, int size)
Process ndash and mdashes
Definition: markdown.cpp:673
Markdown::processQuotations
QCString processQuotations(const QCString &s, int refIndent)
Definition: markdown.cpp:2533
Markdown::processCodeSpan
int processCodeSpan(const char *data, int, int size)
'‘’ parsing a code span (assuming codespan != 0)
Definition: markdown.cpp:1234
Markdown::writeFencedCodeBlock
void writeFencedCodeBlock(const char *data, const char *lng, int blockStart, int blockEnd)
Definition: markdown.cpp:2512
MarkdownOutlineParser::parsePrototype
void parsePrototype(const QCString &text)
Callback function called by the comment block scanner.
Definition: markdown.cpp:3175
Markdown::processSpecialCommand
int processSpecialCommand(const char *data, int offset, int size)
Definition: markdown.cpp:1325
parserintf.h
Markdown::detab
QCString detab(const QCString &s, int &refIndent)
Definition: markdown.cpp:2932
Markdown::processInline
void processInline(const char *data, int size)
Definition: markdown.cpp:1376
Markdown::Markdown
Markdown(const QCString &fileName, int lineNr, int indentLevel=0)
Definition: markdown.cpp:207
Markdown::writeBlockQuote
int writeBlockQuote(const char *data, int size)
Definition: markdown.cpp:2323
Markdown::findEmphasisChar
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,...
Definition: markdown.cpp:431
MarkdownOutlineParser::parseInput
void parseInput(const QCString &fileName, const char *fileBuf, const std::shared_ptr< Entry > &root, ClangTUParser *clangParser)
Parses a single input file with the goal to build an Entry tree.
Definition: markdown.cpp:3089
Markdown::m_fileName
QCString m_fileName
Definition: markdown.h:83
Markdown::writeCodeBlock
int writeCodeBlock(const char *data, int size, int refIndent)
Definition: markdown.cpp:2384
MarkdownOutlineParser
Definition: markdown.h:91
Markdown::processQuoted
int processQuoted(const char *data, int, int size)
Process quoted section "...", can contain one embedded newline
Definition: markdown.cpp:713
Markdown::processEmphasis2
int processEmphasis2(const char *data, int size, char c)
process double emphasis
Definition: markdown.cpp:573
Entry::fileName
QCString fileName
file this entry was extracted from
Definition: entry.h:290
Markdown::m_actions
Markdown::Action_t m_actions[256]
Definition: markdown.h:87
Entry
Represents an unstructured piece of information, about an entity found in the sources.
Definition: entry.h:61
Markdown::addStrEscapeUtf8Nbsp
void addStrEscapeUtf8Nbsp(const char *s, int len)
Definition: markdown.cpp:1312
Markdown
Helper class to process markdown formatted text
Definition: markdown.h:32
OutlineParserInterface
Abstract interface for outline parsers.
Definition: parserintf.h:42
Markdown::m_out
GrowBuf m_out
Definition: markdown.h:86
Markdown::m_indentLevel
int m_indentLevel
Definition: markdown.h:85
ClangTUParser
Clang parser object for a single translation unit, which consists of a source file and the directly o...
Definition: clangparser.h:21
FileDef
A model of a file symbol.
Definition: filedef.h:73
Markdown::processLink
int processLink(const char *data, int, int size)
Definition: markdown.cpp:909
Markdown::writeMarkdownImage
void writeMarkdownImage(const char *fmt, bool explicitTitle, const QCString &title, const QCString &content, const QCString &link, const FileDef *fd)
Definition: markdown.cpp:882
Markdown::processHtmlTag
int processHtmlTag(const char *data, int offset, int size)
Definition: markdown.cpp:827
Markdown::processEmphasis3
int processEmphasis3(const char *data, int size, char c)
Parsing triple emphasis.
Definition: markdown.cpp:608
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108