summaryrefslogtreecommitdiffstats
path: root/src/markdown.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/markdown.h')
-rw-r--r--src/markdown.h88
1 files changed, 68 insertions, 20 deletions
diff --git a/src/markdown.h b/src/markdown.h
index bc1e9bb..1210967 100644
--- a/src/markdown.h
+++ b/src/markdown.h
@@ -3,8 +3,8 @@
* 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
+ * 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.
*
@@ -16,39 +16,87 @@
#ifndef MARKDOWN_H
#define MARKDOWN_H
+#include <functional>
+
#include <qcstring.h>
#include "parserintf.h"
+#include "growbuf.h"
class Entry;
/** processes string \a s and converts markdown into doxygen/html commands. */
-QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &s);
+//QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &s);
QCString markdownFileNameToId(const QCString &fileName);
-/** Performs markdown processing for a comment block if markdown processing is enabled.
- * @param[in] comment A string representing the actual comment block.
- * Note that leading *'s should already be stripped from the comment block.
- * @param[in] fileName The name of the file in which the comment is found.
- * Mainly used for producing warnings.
- * @param[in] lineNr The line number at which the comment block was found.
- * @returns The processed comment block
- */
-QCString processMarkdownForCommentBlock(const QCString &comment,
- const QCString &fileName,
- int lineNr);
+/// Helper class to process markdown formatted text
+class Markdown
+{
+ public:
+ Markdown(const char *fileName,int lineNr,int indentLevel=0);
+ QCString process(const QCString &input, int &startNewlines);
+ QCString extractPageTitle(QCString &docs,QCString &id);
+ void setIndentLevel(int level) { m_indentLevel = level; }
+
+ private:
+ 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);
+ 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);
+ int processEmphasis2(const char *data, int size, char c);
+ int processEmphasis3(const char *data, int size, char c);
+ int processNmdash(const char *data,int off,int size);
+ int processQuoted(const char *data,int,int size);
+ int processCodeSpan(const char *data, int /*offset*/, int size);
+ 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);
+ 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);
+ 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);
+
+ private:
+ struct LinkRef
+ {
+ LinkRef(const char *l,const char *t) : link(l), title(t) {}
+ QCString link;
+ QCString title;
+ };
+ using Action_t = std::function<int(const char *,int,int)>;
+
+ std::unordered_map<std::string,LinkRef> m_linkRefs;
+ QCString m_fileName;
+ int m_lineNr = 0;
+ int m_indentLevel=0; // 0 is outside markdown, -1=page level
+ GrowBuf m_out;
+ Markdown::Action_t m_actions[256];
+};
+
class MarkdownOutlineParser : public OutlineParserInterface
{
public:
MarkdownOutlineParser();
virtual ~MarkdownOutlineParser();
- void startTranslationUnit(const char *) {}
- void finishTranslationUnit() {}
- void parseInput(const char *fileName,
- const char *fileBuf,
+ void parseInput(const char *fileName,
+ const char *fileBuf,
const std::shared_ptr<Entry> &root,
- bool sameTranslationUnit,
- QStrList &filesInSameTranslationUnit);
+ ClangTUParser *clangParser);
bool needsPreprocessing(const QCString &) const { return FALSE; }
void parsePrototype(const char *text);
private: