summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2016-05-16 10:33:19 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2016-05-16 10:33:19 (GMT)
commit42c7d88ffc11651d1fb6b997fd23cc938bce4a39 (patch)
treeef5d37b9346a8830e8b901c824ecf38fa6cc634a /src
parentec1ef7b4971540bbe042b16d7ebd3f2a0e0e57f1 (diff)
downloadDoxygen-42c7d88ffc11651d1fb6b997fd23cc938bce4a39.zip
Doxygen-42c7d88ffc11651d1fb6b997fd23cc938bce4a39.tar.gz
Doxygen-42c7d88ffc11651d1fb6b997fd23cc938bce4a39.tar.bz2
Bug 765692 - Using `@page` to add title to Markdown file generates surplus empty page.
Diffstat (limited to 'src')
-rw-r--r--src/markdown.cpp57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index a071857..5b0ede9 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -838,7 +838,7 @@ static int processLink(GrowBuf &out,const char *data,int,int size)
out.addStr("@image html ");
out.addStr(link.mid(fd ? 0 : 5));
if (!explicitTitle && !content.isEmpty())
- {
+ {
out.addStr(" \"");
out.addStr(content);
out.addStr("\"");
@@ -2198,6 +2198,26 @@ static QCString processBlocks(const QCString &s,int indent)
return out.get();
}
+/** returns TRUE if input string docs starts with \@page or \@mainpage command */
+static bool isExplicitPage(const QCString &docs)
+{
+ int i=0;
+ const char *data = docs.data();
+ int size=docs.size();
+ while (i<size && (data[i]==' ' || data[i]=='\n'))
+ {
+ i++;
+ }
+ if (i<size+1 &&
+ (data[i]=='\\' || data[i]=='@') &&
+ (qstrncmp(&data[i+1],"page ",5)==0 || qstrncmp(&data[i+1],"mainpage",8)==0)
+ )
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
static QCString extractPageTitle(QCString &docs,QCString &id)
{
int ln=0;
@@ -2371,23 +2391,26 @@ void MarkdownFileParser::parseInput(const char *fileName,
QCString fn = QFileInfo(fileName).fileName().utf8();
static QCString mdfileAsMainPage = Config_getString(USE_MDFILE_AS_MAINPAGE);
if (id.isEmpty()) id = markdownFileNameToId(fileName);
- if (!mdfileAsMainPage.isEmpty() &&
- (fn==mdfileAsMainPage || // name reference
- QFileInfo(fileName).absFilePath()==
- QFileInfo(mdfileAsMainPage).absFilePath()) // file reference with path
- )
- {
- docs.prepend("@mainpage "+title+"\n");
- }
- else if (id=="mainpage" || id=="index")
+ if (!isExplicitPage(docs))
{
- if (title.isEmpty()) title = titleFn;
- docs.prepend("@mainpage "+title+"\n");
- }
- else
- {
- if (title.isEmpty()) title = titleFn;
- docs.prepend("@page "+id+" "+title+"\n");
+ if (!mdfileAsMainPage.isEmpty() &&
+ (fn==mdfileAsMainPage || // name reference
+ QFileInfo(fileName).absFilePath()==
+ QFileInfo(mdfileAsMainPage).absFilePath()) // file reference with path
+ )
+ {
+ docs.prepend("@mainpage "+title+"\n");
+ }
+ else if (id=="mainpage" || id=="index")
+ {
+ if (title.isEmpty()) title = titleFn;
+ docs.prepend("@mainpage "+title+"\n");
+ }
+ else
+ {
+ if (title.isEmpty()) title = titleFn;
+ docs.prepend("@page "+id+" "+title+"\n");
+ }
}
int lineNr=1;
int position=0;