Commit 6bb9ee4f authored by Dimitri van Heesch's avatar Dimitri van Heesch

Allow @ref to unlabeled markdown page by name, i.e. @ref mypage.md

parent 57f1a23a
...@@ -445,6 +445,12 @@ when processed by doxygen: ...@@ -445,6 +445,12 @@ when processed by doxygen:
Documentation that will appear on the main page 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 \subsection md_html_blocks Treatment of HTML blocks
Markdown is quite strict in the way it processes block-level HTML: Markdown is quite strict in the way it processes block-level HTML:
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "formula.h" #include "formula.h"
#include "config.h" #include "config.h"
#include "growbuf.h" #include "growbuf.h"
#include "markdown.h"
// debug off // debug off
#define DBG(x) do {} while(0) #define DBG(x) do {} while(0)
...@@ -2417,8 +2418,13 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) : ...@@ -2417,8 +2418,13 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) :
QCString anchor; QCString anchor;
//printf("DocRef::DocRef(target=%s,context=%s)\n",target.data(),context.data()); //printf("DocRef::DocRef(target=%s,context=%s)\n",target.data(),context.data());
ASSERT(!target.isEmpty()); ASSERT(!target.isEmpty());
SrcLangExt lang = getLanguageFromFileName(target);
m_relPath = g_relPath; m_relPath = g_relPath;
SectionInfo *sec = Doxygen::sectionDict->find(target); 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 if (sec) // ref to section or anchor
{ {
PageDef *pd = 0; PageDef *pd = 0;
......
...@@ -2249,6 +2249,15 @@ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input ...@@ -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, void MarkdownFileParser::parseInput(const char *fileName,
const char *fileBuf, const char *fileBuf,
Entry *root, Entry *root,
...@@ -2270,15 +2279,10 @@ void MarkdownFileParser::parseInput(const char *fileName, ...@@ -2270,15 +2279,10 @@ void MarkdownFileParser::parseInput(const char *fileName,
QCString docs = output.data(); QCString docs = output.data();
QCString id; QCString id;
QCString title=extractPageTitle(docs,id).stripWhiteSpace(); 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 titleFn = QFileInfo(fileName).baseName().utf8();
QCString fn = QFileInfo(fileName).fileName().utf8(); QCString fn = QFileInfo(fileName).fileName().utf8();
QCString baseName = substitute(substitute(baseFn," ","_"),"/","_");
static QCString mdfileAsMainPage = Config_getString("USE_MDFILE_AS_MAINPAGE"); 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 (title.isEmpty()) title = titleFn;
if (fn==mdfileAsMainPage) if (fn==mdfileAsMainPage)
{ {
......
...@@ -23,6 +23,7 @@ class Entry; ...@@ -23,6 +23,7 @@ class Entry;
/** processes string \a s and converts markdown into doxygen/html commands. */ /** processes string \a s and converts markdown into doxygen/html commands. */
QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &s); QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &s);
QCString markdownFileNameToId(const QCString &fileName);
class MarkdownFileParser : public ParserInterface class MarkdownFileParser : public ParserInterface
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment