@@ -67,6 +67,8 @@ enum eKeywordId {
6767 KEYWORD_providecommand ,
6868 KEYWORD_def ,
6969 KEYWORD_declaremathoperator ,
70+ KEYWORD_newenvironment ,
71+ KEYWORD_renewenvironment ,
7072 KEYWORD_newcounter ,
7173};
7274typedef int keywordId ; /* to allow KEYWORD_NONE */
@@ -122,6 +124,7 @@ typedef enum {
122124 TEXTAG_BIBITEM ,
123125 TEXTAG_COMMAND ,
124126 TEXTAG_OPERATOR ,
127+ TEXTAG_ENVIRONMENT ,
125128 TEXTAG_COUNTER ,
126129 TEXTAG_COUNT
127130} texKind ;
@@ -155,6 +158,7 @@ static kindDefinition TexKinds [] = {
155158 { true, 'B' , "bibitem" , "bibliography items" },
156159 { true, 'C' , "command" , "command created with \\newcommand" },
157160 { true, 'o' , "operator" , "math operator created with \\DeclareMathOperator" },
161+ { true, 'e' , "environment" , "environment created with \\newenvironment" },
158162 { true, 'N' , "counter" , "counter created with \\newcounter" },
159163};
160164
@@ -179,6 +183,8 @@ static const keywordTable TexKeywordTable [] = {
179183 { "providecommand" , KEYWORD_providecommand },
180184 { "def" , KEYWORD_def },
181185 { "DeclareMathOperator" , KEYWORD_declaremathoperator },
186+ { "newenvironment" , KEYWORD_newenvironment },
187+ { "renewenvironment" , KEYWORD_renewenvironment },
182188 { "newcounter" , KEYWORD_newcounter },
183189};
184190
@@ -892,6 +898,48 @@ static bool parseDef (tokenInfo *const token, bool *tokenUnprocessed)
892898 return eof ;
893899}
894900
901+ static bool parseNewEnvironment (tokenInfo * const token , bool * tokenUnprocessed )
902+ {
903+ bool eof = false;
904+ /* \newenvironment{nam}[args]{begdef}{enddef} */
905+ struct TexParseStrategy strategy [] = {
906+ {
907+ .type = '{' ,
908+ .flags = 0 ,
909+ .kindIndex = TEXTAG_ENVIRONMENT ,
910+ .roleIndex = ROLE_DEFINITION_INDEX ,
911+ .name = NULL ,
912+ .unique = false,
913+ },
914+ {
915+ .type = '[' ,
916+ .flags = TEX_NAME_FLAG_OPTIONAL ,
917+ .kindIndex = KIND_GHOST_INDEX ,
918+ .name = NULL ,
919+ },
920+ {
921+ .type = '{' ,
922+ .flags = 0 ,
923+ .kindIndex = KIND_GHOST_INDEX ,
924+ .name = NULL ,
925+ },
926+ {
927+ .type = '{' ,
928+ .flags = 0 ,
929+ .kindIndex = KIND_GHOST_INDEX ,
930+ .name = NULL ,
931+ },
932+ {
933+ .type = 0
934+ }
935+ };
936+
937+ if (parseWithStrategy (token , strategy , tokenUnprocessed ))
938+ eof = true;
939+
940+ return eof ;
941+ }
942+
895943static bool parseNewcounter (tokenInfo * const token , bool * tokenUnprocessed )
896944{
897945 bool eof = false;
@@ -921,6 +969,7 @@ static bool parseNewcounter (tokenInfo *const token, bool *tokenUnprocessed)
921969
922970 return eof ;
923971}
972+
924973static void parseTexFile (tokenInfo * const token )
925974{
926975 bool eof = false;
@@ -995,6 +1044,10 @@ static void parseTexFile (tokenInfo *const token)
9951044 case KEYWORD_declaremathoperator :
9961045 eof = parseNewcommandFull (token , & tokenUnprocessed , TEXTAG_OPERATOR );
9971046 break ;
1047+ case KEYWORD_newenvironment :
1048+ case KEYWORD_renewenvironment :
1049+ eof = parseNewEnvironment (token , & tokenUnprocessed );
1050+ break ;
9981051 case KEYWORD_newcounter :
9991052 eof = parseNewcounter (token , & tokenUnprocessed );
10001053 break ;
0 commit comments