Skip to content

Commit 35c0cdf

Browse files
committed
rustdoc: Enable various useful markdown extensions
1 parent 3585c64 commit 35c0cdf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ use std::vec;
1818
pub struct Markdown<'self>(&'self str);
1919

2020
static OUTPUT_UNIT: libc::size_t = 64;
21+
static MKDEXT_NO_INTRA_EMPHASIS: libc::c_uint = 1 << 0;
22+
static MKDEXT_TABLES: libc::c_uint = 1 << 1;
23+
static MKDEXT_FENCED_CODE: libc::c_uint = 1 << 2;
24+
static MKDEXT_AUTOLINK: libc::c_uint = 1 << 3;
25+
static MKDEXT_STRIKETHROUGH: libc::c_uint = 1 << 4;
26+
static MKDEXT_SPACE_HEADERS: libc::c_uint = 1 << 6;
27+
static MKDEXT_SUPERSCRIPT: libc::c_uint = 1 << 7;
28+
static MKDEXT_LAX_SPACING: libc::c_uint = 1 << 8;
2129

2230
type sd_markdown = libc::c_void; // this is opaque to us
2331

@@ -67,6 +75,9 @@ fn render(w: &mut io::Writer, s: &str) {
6775
// This code is all lifted from examples/sundown.c in the sundown repo
6876
unsafe {
6977
let ob = bufnew(OUTPUT_UNIT);
78+
let extensions = MKDEXT_NO_INTRA_EMPHASIS | MKDEXT_TABLES |
79+
MKDEXT_FENCED_CODE | MKDEXT_AUTOLINK |
80+
MKDEXT_STRIKETHROUGH;
7081
let options = html_renderopt {
7182
toc_data: html_toc_data {
7283
header_count: 0,
@@ -79,7 +90,7 @@ fn render(w: &mut io::Writer, s: &str) {
7990
let callbacks: sd_callbacks = [0, ..26];
8091

8192
sdhtml_renderer(&callbacks, &options, 0);
82-
let markdown = sd_markdown_new(0, 16, &callbacks,
93+
let markdown = sd_markdown_new(extensions, 16, &callbacks,
8394
&options as *html_renderopt as *libc::c_void);
8495

8596
do s.as_imm_buf |data, len| {

0 commit comments

Comments
 (0)