@@ -56,6 +56,7 @@ static HOEDOWN_EXT_AUTOLINK: libc::c_uint = 1 << 3;
56
56
static HOEDOWN_EXT_STRIKETHROUGH : libc:: c_uint = 1 << 4 ;
57
57
static HOEDOWN_EXT_SUPERSCRIPT : libc:: c_uint = 1 << 8 ;
58
58
static HOEDOWN_EXT_FOOTNOTES : libc:: c_uint = 1 << 2 ;
59
+ static HOEDOWN_EXT_MATH : libc:: c_uint = 1 << 13 ;
59
60
60
61
static HOEDOWN_EXTENSIONS : libc:: c_uint =
61
62
HOEDOWN_EXT_NO_INTRA_EMPHASIS | HOEDOWN_EXT_TABLES |
@@ -147,10 +148,22 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> {
147
148
}
148
149
}
149
150
151
+ fn hoedown_extensions ( ) -> libc:: c_uint {
152
+ let mut extensions = HOEDOWN_EXTENSIONS ;
153
+
154
+ match use_mathjax. get ( ) . as_ref ( ) {
155
+ Some ( use_math) if * * use_math => { extensions |= HOEDOWN_EXT_MATH ; }
156
+ _ => { }
157
+ }
158
+
159
+ extensions
160
+ }
161
+
150
162
local_data_key ! ( used_header_map: RefCell <HashMap <String , uint>>)
151
163
local_data_key ! ( test_idx: Cell <uint>)
152
164
// None == render an example, but there's no crate name
153
165
local_data_key ! ( pub playground_krate: Option <String >)
166
+ local_data_key ! ( pub use_mathjax: bool )
154
167
155
168
pub fn render ( w : & mut fmt:: Formatter , s : & str , print_toc : bool ) -> fmt:: Result {
156
169
extern fn block ( ob : * mut hoedown_buffer , text : * const hoedown_buffer ,
@@ -285,7 +298,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
285
298
( * renderer) . blockcode = Some ( block) ;
286
299
( * renderer) . header = Some ( header) ;
287
300
288
- let document = hoedown_document_new ( renderer, HOEDOWN_EXTENSIONS , 16 ) ;
301
+ let document = hoedown_document_new ( renderer, hoedown_extensions ( ) , 16 ) ;
289
302
hoedown_document_render ( document, ob, s. as_ptr ( ) ,
290
303
s. len ( ) as libc:: size_t ) ;
291
304
hoedown_document_free ( document) ;
@@ -363,7 +376,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
363
376
( * renderer) . header = Some ( header) ;
364
377
( * ( * renderer) . opaque ) . opaque = tests as * mut _ as * mut libc:: c_void ;
365
378
366
- let document = hoedown_document_new ( renderer, HOEDOWN_EXTENSIONS , 16 ) ;
379
+ let document = hoedown_document_new ( renderer, hoedown_extensions ( ) , 16 ) ;
367
380
hoedown_document_render ( document, ob, doc. as_ptr ( ) ,
368
381
doc. len ( ) as libc:: size_t ) ;
369
382
hoedown_document_free ( document) ;
0 commit comments