@@ -64,7 +64,8 @@ impl Production {
6464 name = self . name,
6565 )
6666 . unwrap ( ) ;
67- self . expression . render_markdown ( link_map, output) ;
67+ self . expression
68+ . render_markdown ( link_map, output, for_summary) ;
6869 output. push ( '\n' ) ;
6970 }
7071}
@@ -91,11 +92,16 @@ impl Expression {
9192 }
9293 }
9394
94- fn render_markdown ( & self , link_map : & HashMap < String , String > , output : & mut String ) {
95+ fn render_markdown (
96+ & self ,
97+ link_map : & HashMap < String , String > ,
98+ output : & mut String ,
99+ for_summary : bool ,
100+ ) {
95101 match & self . kind {
96102 ExpressionKind :: Grouped ( e) => {
97103 output. push_str ( "( " ) ;
98- e. render_markdown ( link_map, output) ;
104+ e. render_markdown ( link_map, output, for_summary ) ;
99105 if !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
100106 output. push ( ' ' ) ;
101107 }
@@ -104,7 +110,7 @@ impl Expression {
104110 ExpressionKind :: Alt ( es) => {
105111 let mut iter = es. iter ( ) . peekable ( ) ;
106112 while let Some ( e) = iter. next ( ) {
107- e. render_markdown ( link_map, output) ;
113+ e. render_markdown ( link_map, output, for_summary ) ;
108114 if iter. peek ( ) . is_some ( ) {
109115 if !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
110116 output. push ( ' ' ) ;
@@ -116,34 +122,34 @@ impl Expression {
116122 ExpressionKind :: Sequence ( es) => {
117123 let mut iter = es. iter ( ) . peekable ( ) ;
118124 while let Some ( e) = iter. next ( ) {
119- e. render_markdown ( link_map, output) ;
125+ e. render_markdown ( link_map, output, for_summary ) ;
120126 if iter. peek ( ) . is_some ( ) && !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
121127 output. push ( ' ' ) ;
122128 }
123129 }
124130 }
125131 ExpressionKind :: Optional ( e) => {
126- e. render_markdown ( link_map, output) ;
132+ e. render_markdown ( link_map, output, for_summary ) ;
127133 output. push_str ( "<sup>?</sup>" ) ;
128134 }
129135 ExpressionKind :: Repeat ( e) => {
130- e. render_markdown ( link_map, output) ;
136+ e. render_markdown ( link_map, output, for_summary ) ;
131137 output. push_str ( "<sup>\\ *</sup>" ) ;
132138 }
133139 ExpressionKind :: RepeatNonGreedy ( e) => {
134- e. render_markdown ( link_map, output) ;
140+ e. render_markdown ( link_map, output, for_summary ) ;
135141 output. push_str ( "<sup>\\ * (non-greedy)</sup>" ) ;
136142 }
137143 ExpressionKind :: RepeatPlus ( e) => {
138- e. render_markdown ( link_map, output) ;
144+ e. render_markdown ( link_map, output, for_summary ) ;
139145 output. push_str ( "<sup>+</sup>" ) ;
140146 }
141147 ExpressionKind :: RepeatPlusNonGreedy ( e) => {
142- e. render_markdown ( link_map, output) ;
148+ e. render_markdown ( link_map, output, for_summary ) ;
143149 output. push_str ( "<sup>+ (non-greedy)</sup>" ) ;
144150 }
145151 ExpressionKind :: RepeatRange ( e, a, b) => {
146- e. render_markdown ( link_map, output) ;
152+ e. render_markdown ( link_map, output, for_summary ) ;
147153 write ! (
148154 output,
149155 "<sup>{}..{}</sup>" ,
@@ -174,7 +180,7 @@ impl Expression {
174180 ExpressionKind :: Charset ( set) => charset_render_markdown ( set, link_map, output) ,
175181 ExpressionKind :: NegExpression ( e) => {
176182 output. push ( '~' ) ;
177- e. render_markdown ( link_map, output) ;
183+ e. render_markdown ( link_map, output, for_summary ) ;
178184 }
179185 ExpressionKind :: Unicode ( s) => {
180186 output. push_str ( "U+" ) ;
@@ -184,9 +190,12 @@ impl Expression {
184190 if let Some ( suffix) = & self . suffix {
185191 write ! ( output, "<sub class=\" grammar-text\" >{suffix}</sub>" ) . unwrap ( ) ;
186192 }
187- if let Some ( footnote) = & self . footnote {
188- // The ZeroWidthSpace is to avoid conflicts with markdown link references.
189- write ! ( output, "​[^{footnote}]" ) . unwrap ( ) ;
193+ if !for_summary {
194+ if let Some ( footnote) = & self . footnote {
195+ // The `ZeroWidthSpace` is to avoid conflicts with markdown link
196+ // references.
197+ write ! ( output, "​[^{footnote}]" ) . unwrap ( ) ;
198+ }
190199 }
191200 }
192201}
0 commit comments