@@ -64,7 +64,8 @@ impl Production {
64
64
name = self . name,
65
65
)
66
66
. unwrap ( ) ;
67
- self . expression . render_markdown ( link_map, output) ;
67
+ self . expression
68
+ . render_markdown ( link_map, output, for_summary) ;
68
69
output. push ( '\n' ) ;
69
70
}
70
71
}
@@ -91,11 +92,16 @@ impl Expression {
91
92
}
92
93
}
93
94
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
+ ) {
95
101
match & self . kind {
96
102
ExpressionKind :: Grouped ( e) => {
97
103
output. push_str ( "( " ) ;
98
- e. render_markdown ( link_map, output) ;
104
+ e. render_markdown ( link_map, output, for_summary ) ;
99
105
if !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
100
106
output. push ( ' ' ) ;
101
107
}
@@ -104,7 +110,7 @@ impl Expression {
104
110
ExpressionKind :: Alt ( es) => {
105
111
let mut iter = es. iter ( ) . peekable ( ) ;
106
112
while let Some ( e) = iter. next ( ) {
107
- e. render_markdown ( link_map, output) ;
113
+ e. render_markdown ( link_map, output, for_summary ) ;
108
114
if iter. peek ( ) . is_some ( ) {
109
115
if !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
110
116
output. push ( ' ' ) ;
@@ -116,34 +122,34 @@ impl Expression {
116
122
ExpressionKind :: Sequence ( es) => {
117
123
let mut iter = es. iter ( ) . peekable ( ) ;
118
124
while let Some ( e) = iter. next ( ) {
119
- e. render_markdown ( link_map, output) ;
125
+ e. render_markdown ( link_map, output, for_summary ) ;
120
126
if iter. peek ( ) . is_some ( ) && !matches ! ( e. last( ) , ExpressionKind :: Break ( _) ) {
121
127
output. push ( ' ' ) ;
122
128
}
123
129
}
124
130
}
125
131
ExpressionKind :: Optional ( e) => {
126
- e. render_markdown ( link_map, output) ;
132
+ e. render_markdown ( link_map, output, for_summary ) ;
127
133
output. push_str ( "<sup>?</sup>" ) ;
128
134
}
129
135
ExpressionKind :: Repeat ( e) => {
130
- e. render_markdown ( link_map, output) ;
136
+ e. render_markdown ( link_map, output, for_summary ) ;
131
137
output. push_str ( "<sup>\\ *</sup>" ) ;
132
138
}
133
139
ExpressionKind :: RepeatNonGreedy ( e) => {
134
- e. render_markdown ( link_map, output) ;
140
+ e. render_markdown ( link_map, output, for_summary ) ;
135
141
output. push_str ( "<sup>\\ * (non-greedy)</sup>" ) ;
136
142
}
137
143
ExpressionKind :: RepeatPlus ( e) => {
138
- e. render_markdown ( link_map, output) ;
144
+ e. render_markdown ( link_map, output, for_summary ) ;
139
145
output. push_str ( "<sup>+</sup>" ) ;
140
146
}
141
147
ExpressionKind :: RepeatPlusNonGreedy ( e) => {
142
- e. render_markdown ( link_map, output) ;
148
+ e. render_markdown ( link_map, output, for_summary ) ;
143
149
output. push_str ( "<sup>+ (non-greedy)</sup>" ) ;
144
150
}
145
151
ExpressionKind :: RepeatRange ( e, a, b) => {
146
- e. render_markdown ( link_map, output) ;
152
+ e. render_markdown ( link_map, output, for_summary ) ;
147
153
write ! (
148
154
output,
149
155
"<sup>{}..{}</sup>" ,
@@ -174,7 +180,7 @@ impl Expression {
174
180
ExpressionKind :: Charset ( set) => charset_render_markdown ( set, link_map, output) ,
175
181
ExpressionKind :: NegExpression ( e) => {
176
182
output. push ( '~' ) ;
177
- e. render_markdown ( link_map, output) ;
183
+ e. render_markdown ( link_map, output, for_summary ) ;
178
184
}
179
185
ExpressionKind :: Unicode ( s) => {
180
186
output. push_str ( "U+" ) ;
@@ -184,9 +190,12 @@ impl Expression {
184
190
if let Some ( suffix) = & self . suffix {
185
191
write ! ( output, "<sub class=\" grammar-text\" >{suffix}</sub>" ) . unwrap ( ) ;
186
192
}
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
+ }
190
199
}
191
200
}
192
201
}
0 commit comments