Skip to content

Commit c359e13

Browse files
committed
Tex: add \renewcommand and \providecommand
1 parent 05e6ab4 commit c359e13

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
\\bar input.tex /^\\providecommand{\\bar}{\\section{#1}}$/;" C
2+
\\foo input.tex /^\\renewcommand{\\foo}{\\section{#1}}$/;" C
13
\\mysection0 input.tex /^\\newcommand{\\mysection0}{\\section{#1}}$/;" C
24
\\mysection1 input.tex /^\\newcommand{\\mysection1}[1]{\\section{#1}}$/;" C
35
\\mysection2 input.tex /^\\newcommand{\\mysection2}[1][1]{\\section{#1}}$/;" C

Units/parser-tex.r/newcommand.d/input.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
\newcommand{\mysection0}{\section{#1}}
33
\newcommand{\mysection1}[1]{\section{#1}}
44
\newcommand{\mysection2}[1][1]{\section{#1}}
5+
\renewcommand{\foo}{\section{#1}}
6+
\providecommand{\bar}{\section{#1}}
57
\begin{document}
68
\mysection0{ABC}
79
\mysection1{EFG}

parsers/tex.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ enum eKeywordId {
6363
KEYWORD_bibitem,
6464
KEYWORD_bibliography,
6565
KEYWORD_newcommand,
66+
KEYWORD_renewcommand,
67+
KEYWORD_providecommand,
6668
KEYWORD_newcounter,
6769
};
6870
typedef int keywordId; /* to allow KEYWORD_NONE */
@@ -169,6 +171,8 @@ static const keywordTable TexKeywordTable [] = {
169171
{ "bibitem", KEYWORD_bibitem },
170172
{ "bibliography", KEYWORD_bibliography },
171173
{ "newcommand", KEYWORD_newcommand },
174+
{ "renewcommand", KEYWORD_renewcommand },
175+
{ "providecommand", KEYWORD_providecommand },
172176
{ "newcounter", KEYWORD_newcounter },
173177
};
174178

@@ -934,6 +938,8 @@ static void parseTexFile (tokenInfo *const token)
934938
false, &tokenUnprocessed);
935939
break;
936940
case KEYWORD_newcommand:
941+
case KEYWORD_renewcommand:
942+
case KEYWORD_providecommand:
937943
eof = parseNewcommand (token, &tokenUnprocessed);
938944
break;
939945
case KEYWORD_newcounter:

0 commit comments

Comments
 (0)