@@ -6,6 +6,7 @@ use lol_html::{element, rewrite_str, HtmlRewriter, RewriteStrSettings, Settings}
6
6
use rari_md:: ext:: DELIM_START ;
7
7
use rari_md:: node_card:: NoteCard ;
8
8
use rari_types:: fm_types:: PageType ;
9
+ use rari_types:: globals:: settings;
9
10
use rari_types:: locale:: Locale ;
10
11
use rari_utils:: concat_strs;
11
12
use tracing:: warn;
@@ -51,6 +52,7 @@ pub fn post_process_html<T: PageLike>(
51
52
if url. ends_with( '/' ) { "" } else { "/" }
52
53
) ) ?;
53
54
let base_url = options. base_url ( Some ( & base) ) ;
55
+ let data_issues = settings ( ) . data_issues ;
54
56
55
57
let mut element_content_handlers = vec ! [
56
58
element!( "*[id]" , |el| {
@@ -110,7 +112,9 @@ pub fn post_process_html<T: PageLike>(
110
112
"Error parsing {}: {e}" ,
111
113
file. display( )
112
114
) ;
113
- el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
115
+ if data_issues {
116
+ el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
117
+ }
114
118
( None , None )
115
119
}
116
120
}
@@ -125,7 +129,9 @@ pub fn post_process_html<T: PageLike>(
125
129
"Error opening {}: {e}" ,
126
130
file. display( )
127
131
) ;
128
- el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
132
+ if data_issues {
133
+ el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
134
+ }
129
135
130
136
( None , None )
131
137
}
@@ -171,7 +177,9 @@ pub fn post_process_html<T: PageLike>(
171
177
if resolved_href_no_hash == page. url( ) {
172
178
el. set_attribute( "aria-current" , "page" ) ?;
173
179
}
174
- if !Page :: exists( resolved_href_no_hash) && !Page :: ignore_link_check( href) {
180
+ let remove_href = if !Page :: exists( resolved_href_no_hash)
181
+ && !Page :: ignore_link_check( href)
182
+ {
175
183
tracing:: debug!( "{resolved_href_no_hash} {href}" ) ;
176
184
let class = el. get_attribute( "class" ) . unwrap_or_default( ) ;
177
185
el. set_attribute(
@@ -182,8 +190,12 @@ pub fn post_process_html<T: PageLike>(
182
190
"page-not-created"
183
191
) ,
184
192
) ?;
193
+ el. remove_attribute( "href" ) ;
185
194
el. set_attribute( "title" , l10n_json_data( "Common" , "summary" , page. locale( ) ) ?) ?;
186
- }
195
+ true
196
+ } else {
197
+ false
198
+ } ;
187
199
if original_href != resolved_href {
188
200
if let Some ( pos) = el. get_attribute( "data-sourcepos" ) {
189
201
if let Some ( ( start, _) ) = pos. split_once( '-' ) {
@@ -204,7 +216,9 @@ pub fn post_process_html<T: PageLike>(
204
216
url = original_href,
205
217
redirect = resolved_href. as_ref( )
206
218
) ;
207
- el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
219
+ if data_issues {
220
+ el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
221
+ }
208
222
}
209
223
}
210
224
} else {
@@ -215,17 +229,23 @@ pub fn post_process_html<T: PageLike>(
215
229
url = original_href,
216
230
redirect = resolved_href. as_ref( )
217
231
) ;
218
- el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
232
+ if data_issues {
233
+ el. set_attribute( "data-flaw" , & ic. to_string( ) ) ?;
234
+ }
219
235
}
220
236
}
221
- el. set_attribute(
222
- "href" ,
223
- if no_locale {
224
- strip_locale_from_url( & resolved_href) . 1
225
- } else {
226
- & resolved_href
227
- } ,
228
- ) ?;
237
+ if remove_href {
238
+ el. remove_attribute( "href" ) ;
239
+ } else {
240
+ el. set_attribute(
241
+ "href" ,
242
+ if no_locale {
243
+ strip_locale_from_url( & resolved_href) . 1
244
+ } else {
245
+ & resolved_href
246
+ } ,
247
+ ) ?;
248
+ }
229
249
} else if original_href. starts_with( "http:" ) || original_href. starts_with( "https:" ) {
230
250
let class = el. get_attribute( "class" ) . unwrap_or_default( ) ;
231
251
if !class. split( ' ' ) . any( |s| s == "external" ) {
0 commit comments