Skip to content

Commit a32ff6e

Browse files
author
Yuki Izumi
committed
Use comrak instead of hoedown
1 parent afca824 commit a32ff6e

File tree

4 files changed

+46
-39
lines changed

4 files changed

+46
-39
lines changed

Cargo.lock

Lines changed: 32 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ r2d2 = "0.7"
2424
r2d2_postgres = "0.12"
2525
url = "1.4"
2626
libc = "0.2"
27-
hoedown = "6.0"
2827
badge = { version = "0", path = "src/web/badge" }
2928
error-chain = "0.5"
29+
comrak = { version = "0.1.3", default-features = false }
3030

3131
# iron dependencies
3232
iron = "0.5"

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern crate iron;
1818
extern crate router;
1919
extern crate staticfile;
2020
extern crate handlebars_iron;
21-
extern crate hoedown;
21+
extern crate comrak;
2222
extern crate r2d2;
2323
extern crate r2d2_postgres;
2424
extern crate url;

src/web/mod.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -303,28 +303,21 @@ fn match_version(conn: &Connection, name: &str, version: Option<&str>) -> Option
303303

304304

305305

306-
/// Wrapper around the pulldown-cmark parser and renderer to render markdown
306+
/// Wrapper around the Markdown parser and renderer to render markdown
307307
fn render_markdown(text: &str) -> String {
308-
use hoedown::{Markdown, Html, Render, Extension};
309-
use hoedown::renderer::html;
310-
311-
let extensions = {
312-
use hoedown::{FENCED_CODE, FOOTNOTES, SUPERSCRIPT, TABLES, AUTOLINK, NO_INTRA_EMPHASIS};
313-
314-
let mut extensions = Extension::empty();
315-
extensions.insert(FENCED_CODE);
316-
extensions.insert(FOOTNOTES);
317-
extensions.insert(SUPERSCRIPT);
318-
extensions.insert(TABLES);
319-
extensions.insert(AUTOLINK);
320-
extensions.insert(NO_INTRA_EMPHASIS);
321-
322-
extensions
308+
use comrak::{markdown_to_html, ComrakOptions};
309+
310+
let options = {
311+
let mut options = ComrakOptions::default();
312+
options.ext_superscript = true;
313+
options.ext_table = true;
314+
options.ext_autolink = true;
315+
options.ext_tasklist = true;
316+
options.ext_strikethrough = true;
317+
options
323318
};
324319

325-
let doc = Markdown::new(text).extensions(extensions);
326-
let mut html = Html::new(html::Flags::empty(), 0);
327-
html.render(&doc).to_str().unwrap().to_owned()
320+
markdown_to_html(text, &options)
328321
}
329322

330323

0 commit comments

Comments
 (0)