From 6bb9ee4fee7eb850594f89638a492b0c2f60a68d Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 13 Oct 2013 16:55:47 +0200 Subject: Allow @ref to unlabeled markdown page by name, i.e. @ref mypage.md --- doc/markdown.doc | 6 ++++++ src/docparser.cpp | 6 ++++++ src/markdown.cpp | 16 ++++++++++------ src/markdown.h | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doc/markdown.doc b/doc/markdown.doc index afd1add..9f70a52 100644 --- a/doc/markdown.doc +++ b/doc/markdown.doc @@ -445,6 +445,12 @@ when processed by doxygen: Documentation that will appear on the main page +If a page has a label you can link to it using \ref cmdref "\@ref" as +is shown above. To refer to a markdown page without +such label you can simple use the file name of the page, e.g. + + See [the other page](@ref other.md) for more info. + \subsection md_html_blocks Treatment of HTML blocks Markdown is quite strict in the way it processes block-level HTML: diff --git a/src/docparser.cpp b/src/docparser.cpp index 9bb80ac..4a18b4e 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -52,6 +52,7 @@ #include "formula.h" #include "config.h" #include "growbuf.h" +#include "markdown.h" // debug off #define DBG(x) do {} while(0) @@ -2417,8 +2418,13 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) : QCString anchor; //printf("DocRef::DocRef(target=%s,context=%s)\n",target.data(),context.data()); ASSERT(!target.isEmpty()); + SrcLangExt lang = getLanguageFromFileName(target); m_relPath = g_relPath; SectionInfo *sec = Doxygen::sectionDict->find(target); + if (sec==0 && lang==SrcLangExt_Markdown) // lookup as markdown file + { + sec = Doxygen::sectionDict->find(markdownFileNameToId(target)); + } if (sec) // ref to section or anchor { PageDef *pd = 0; diff --git a/src/markdown.cpp b/src/markdown.cpp index 9d2876b..19c9187 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -2249,6 +2249,15 @@ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input //--------------------------------------------------------------------------- +QCString markdownFileNameToId(const QCString &fileName) +{ + QCString baseFn = stripFromPath(QFileInfo(fileName).absFilePath().utf8()); + int i = baseFn.findRev('.'); + if (i!=-1) baseFn = baseFn.left(i); + QCString baseName = substitute(substitute(baseFn," ","_"),"/","_"); + return "md_"+baseName; +} + void MarkdownFileParser::parseInput(const char *fileName, const char *fileBuf, Entry *root, @@ -2270,15 +2279,10 @@ void MarkdownFileParser::parseInput(const char *fileName, QCString docs = output.data(); QCString id; QCString title=extractPageTitle(docs,id).stripWhiteSpace(); - //g_correctSectionLevel = !title.isEmpty(); - QCString baseFn = stripFromPath(QFileInfo(fileName).absFilePath().utf8()); - int i = baseFn.findRev('.'); - if (i!=-1) baseFn = baseFn.left(i); QCString titleFn = QFileInfo(fileName).baseName().utf8(); QCString fn = QFileInfo(fileName).fileName().utf8(); - QCString baseName = substitute(substitute(baseFn," ","_"),"/","_"); static QCString mdfileAsMainPage = Config_getString("USE_MDFILE_AS_MAINPAGE"); - if (id.isEmpty()) id = "md_"+baseName; + if (id.isEmpty()) id = markdownFileNameToId(fileName); if (title.isEmpty()) title = titleFn; if (fn==mdfileAsMainPage) { diff --git a/src/markdown.h b/src/markdown.h index 99d59f0..d3a845e 100644 --- a/src/markdown.h +++ b/src/markdown.h @@ -23,6 +23,7 @@ class Entry; /** processes string \a s and converts markdown into doxygen/html commands. */ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &s); +QCString markdownFileNameToId(const QCString &fileName); class MarkdownFileParser : public ParserInterface { -- cgit v0.12