Commit 385b87e0 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Added support for \-- and \--- to prevent interpretation as ndash and mdash

parent 4ccfb9ef
...@@ -209,6 +209,8 @@ documentation: ...@@ -209,6 +209,8 @@ documentation:
\refitem cmdchardot \\\. \refitem cmdchardot \\\.
\refitem cmddcolon \:: \refitem cmddcolon \::
\refitem cmdpipe \\| \refitem cmdpipe \\|
\refitem cmdndash \\\--
\refitem cmdmdash \\\---
\endsecreflist \endsecreflist
The following subsections provide a list of all commands that are recognized by The following subsections provide a list of all commands that are recognized by
...@@ -3076,6 +3078,20 @@ class Receiver ...@@ -3076,6 +3078,20 @@ class Receiver
character has to be escaped in some cases, because it is used character has to be escaped in some cases, because it is used
for Markdown tables. for Markdown tables.
<hr>
\section cmdndash \\--
\addindex \\\--
This command writes two dashes (\--) to the output. This allows
writing two consecutive dashes to the output instead of one n-dash character (--).
<hr>
\section cmdmdash \\---
\addindex \\\---
This command writes three dashes (\---) to the output. This allows
writing three consecutuve dashes to the output instead of one m-dash character (---).
<hr> <hr>
\htmlonly <center> \endhtmlonly \htmlonly <center> \endhtmlonly
<h2> <h2>
......
...@@ -136,6 +136,8 @@ CommandMap cmdMap[] = ...@@ -136,6 +136,8 @@ CommandMap cmdMap[] =
{ "parblock", CMD_PARBLOCK }, { "parblock", CMD_PARBLOCK },
{ "endparblock", CMD_ENDPARBLOCK }, { "endparblock", CMD_ENDPARBLOCK },
{ "diafile", CMD_DIAFILE }, { "diafile", CMD_DIAFILE },
{ "--", CMD_NDASH },
{ "---", CMD_MDASH },
{ 0, 0 }, { 0, 0 },
}; };
......
...@@ -125,7 +125,9 @@ enum CommandType ...@@ -125,7 +125,9 @@ enum CommandType
CMD_PARBLOCK = 95, CMD_PARBLOCK = 95,
CMD_ENDPARBLOCK = 96, CMD_ENDPARBLOCK = 96,
CMD_DIAFILE = 97, CMD_DIAFILE = 97,
CMD_LATEXINCLUDE = 98 CMD_LATEXINCLUDE = 98,
CMD_NDASH = 99,
CMD_MDASH = 100
}; };
enum HtmlTagType enum HtmlTagType
......
...@@ -1200,6 +1200,12 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ...@@ -1200,6 +1200,12 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<Comment>^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{B}*/\n { // horizontal line (dashed) <Comment>^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{B}*/\n { // horizontal line (dashed)
addOutput(yytext); addOutput(yytext);
} }
<Comment>{CMD}"---" { // escaped mdash
addOutput(yytext);
}
<Comment>{CMD}"--" { // escaped mdash
addOutput(yytext);
}
<Comment>"---" { // mdash <Comment>"---" { // mdash
addOutput(insidePre || Doxygen::markdownSupport ? yytext : "&mdash;"); addOutput(insidePre || Doxygen::markdownSupport ? yytext : "&mdash;");
} }
......
...@@ -1271,6 +1271,15 @@ reparsetoken: ...@@ -1271,6 +1271,15 @@ reparsetoken:
case CMD_PERCENT: case CMD_PERCENT:
children.append(new DocSymbol(parent,DocSymbol::Sym_Percent)); children.append(new DocSymbol(parent,DocSymbol::Sym_Percent));
break; break;
case CMD_NDASH:
children.append(new DocSymbol(parent,DocSymbol::Sym_Minus));
children.append(new DocSymbol(parent,DocSymbol::Sym_Minus));
break;
case CMD_MDASH:
children.append(new DocSymbol(parent,DocSymbol::Sym_Minus));
children.append(new DocSymbol(parent,DocSymbol::Sym_Minus));
children.append(new DocSymbol(parent,DocSymbol::Sym_Minus));
break;
case CMD_QUOTE: case CMD_QUOTE:
children.append(new DocSymbol(parent,DocSymbol::Sym_Quot)); children.append(new DocSymbol(parent,DocSymbol::Sym_Quot));
break; break;
...@@ -3281,6 +3290,8 @@ int DocIndexEntry::parse() ...@@ -3281,6 +3290,8 @@ int DocIndexEntry::parse()
case CMD_HASH: m_entry+='#'; break; case CMD_HASH: m_entry+='#'; break;
case CMD_DCOLON: m_entry+="::"; break; case CMD_DCOLON: m_entry+="::"; break;
case CMD_PERCENT: m_entry+='%'; break; case CMD_PERCENT: m_entry+='%'; break;
case CMD_NDASH: m_entry+="--"; break;
case CMD_MDASH: m_entry+="---"; break;
case CMD_QUOTE: m_entry+='"'; break; case CMD_QUOTE: m_entry+='"'; break;
default: default:
warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected command %s found as argument of \\addindex", warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected command %s found as argument of \\addindex",
...@@ -5373,6 +5384,15 @@ int DocPara::handleCommand(const QCString &cmdName) ...@@ -5373,6 +5384,15 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_PERCENT: case CMD_PERCENT:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Percent)); m_children.append(new DocSymbol(this,DocSymbol::Sym_Percent));
break; break;
case CMD_NDASH:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
break;
case CMD_MDASH:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
break;
case CMD_QUOTE: case CMD_QUOTE:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Quot)); m_children.append(new DocSymbol(this,DocSymbol::Sym_Quot));
break; break;
...@@ -6828,6 +6848,15 @@ void DocText::parse() ...@@ -6828,6 +6848,15 @@ void DocText::parse()
case CMD_PERCENT: case CMD_PERCENT:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Percent)); m_children.append(new DocSymbol(this,DocSymbol::Sym_Percent));
break; break;
case CMD_NDASH:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
break;
case CMD_MDASH:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
m_children.append(new DocSymbol(this,DocSymbol::Sym_Minus));
break;
case CMD_QUOTE: case CMD_QUOTE:
m_children.append(new DocSymbol(this,DocSymbol::Sym_Quot)); m_children.append(new DocSymbol(this,DocSymbol::Sym_Quot));
break; break;
......
...@@ -395,7 +395,7 @@ class DocSymbol : public DocNode ...@@ -395,7 +395,7 @@ class DocSymbol : public DocNode
/* doxygen commands mapped */ /* doxygen commands mapped */
Sym_BSlash, Sym_At, Sym_Less, Sym_Greater, Sym_Amp, Sym_BSlash, Sym_At, Sym_Less, Sym_Greater, Sym_Amp,
Sym_Dollar, Sym_Hash, Sym_DoubleColon, Sym_Percent, Sym_Pipe, Sym_Dollar, Sym_Hash, Sym_DoubleColon, Sym_Percent, Sym_Pipe,
Sym_Quot Sym_Quot, Sym_Minus
}; };
enum PerlType { Perl_unknown = 0, Perl_string, Perl_char, Perl_symbol, Perl_umlaut, enum PerlType { Perl_unknown = 0, Perl_string, Perl_char, Perl_symbol, Perl_umlaut,
Perl_acute, Perl_grave, Perl_circ, Perl_slash, Perl_tilde, Perl_acute, Perl_grave, Perl_circ, Perl_slash, Perl_tilde,
......
...@@ -350,7 +350,7 @@ HFILEMASK ("."{FILESCHAR}*{FILEECHAR}+)* ...@@ -350,7 +350,7 @@ HFILEMASK ("."{FILESCHAR}*{FILEECHAR}+)*
FILEMASK ({FILESCHAR}*{FILEECHAR}+("."{FILESCHAR}*{FILEECHAR}+)*)|{HFILEMASK} FILEMASK ({FILESCHAR}*{FILEECHAR}+("."{FILESCHAR}*{FILEECHAR}+)*)|{HFILEMASK}
LINKMASK [^ \t\n\r\\@<&${}]+("("[^\n)]*")")?({BLANK}*("const"|"volatile"){BLANK}+)? LINKMASK [^ \t\n\r\\@<&${}]+("("[^\n)]*")")?({BLANK}*("const"|"volatile"){BLANK}+)?
VERBATIM "verbatim"{BLANK}* VERBATIM "verbatim"{BLANK}*
SPCMD1 {CMD}([a-z_A-Z][a-z_A-Z0-9]*|{VERBATIM}) SPCMD1 {CMD}([a-z_A-Z][a-z_A-Z0-9]*|{VERBATIM}|"--"|"---")
SPCMD2 {CMD}[\\@<>&$#%~".|] SPCMD2 {CMD}[\\@<>&$#%~".|]
SPCMD3 {CMD}form#[0-9]+ SPCMD3 {CMD}form#[0-9]+
SPCMD4 {CMD}"::" SPCMD4 {CMD}"::"
......
...@@ -311,7 +311,8 @@ static struct htmlEntityInfo ...@@ -311,7 +311,8 @@ static struct htmlEntityInfo
{ SYM(DoubleColon), "::", "::", "::", "::", "::", "::", "::", { "::", DocSymbol::Perl_string }}, { SYM(DoubleColon), "::", "::", "::", "::", "::", "::", "::", { "::", DocSymbol::Perl_string }},
{ SYM(Percent), "%", "%", "%", "%", "\\%", "%", "%", { "%", DocSymbol::Perl_char }}, { SYM(Percent), "%", "%", "%", "%", "\\%", "%", "%", { "%", DocSymbol::Perl_char }},
{ SYM(Pipe), "|", "|", "|", "|", "$|$", "|", "|", { "|", DocSymbol::Perl_char }}, { SYM(Pipe), "|", "|", "|", "|", "$|$", "|", "|", { "|", DocSymbol::Perl_char }},
{ SYM(Quot), "\"", "\"", "\"", "&quot;", "\"", "\"", "\"", { "\"", DocSymbol::Perl_char }} { SYM(Quot), "\"", "\"", "\"", "&quot;", "\"", "\"", "\"", { "\"", DocSymbol::Perl_char }},
{ SYM(Minus), "-", "-", "-", "-", "-\\/", "-", "-", { "-", DocSymbol::Perl_char }}
}; };
static const int g_numHtmlEntities = (int)(sizeof(g_htmlEntities)/ sizeof(*g_htmlEntities)); static const int g_numHtmlEntities = (int)(sizeof(g_htmlEntities)/ sizeof(*g_htmlEntities));
......
...@@ -1004,6 +1004,16 @@ static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int ...@@ -1004,6 +1004,16 @@ static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int
if (c=='[' || c==']' || c=='*' || c=='+' || c=='-' || if (c=='[' || c==']' || c=='*' || c=='+' || c=='-' ||
c=='!' || c=='(' || c==')' || c=='.' || c=='`' || c=='_') c=='!' || c=='(' || c==')' || c=='.' || c=='`' || c=='_')
{ {
if (c=='-' && size>3 && data[2]=='-' && data[3]=='-') // \---
{
out.addStr(&data[1],3);
return 4;
}
else if (c=='-' && size>2 && data[2]=='-') // \--
{
out.addStr(&data[1],2);
return 3;
}
out.addStr(&data[1],1); out.addStr(&data[1],1);
return 2; return 2;
} }
......
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