Skip to content

Use comrak instead of hoedown #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ r2d2 = "0.7"
r2d2_postgres = "0.12"
url = "1.4"
libc = "0.2"
hoedown = "6.0"
badge = { version = "0", path = "src/web/badge" }
error-chain = "0.5"
comrak = { version = "0.1.3", default-features = false }

# iron dependencies
iron = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate iron;
extern crate router;
extern crate staticfile;
extern crate handlebars_iron;
extern crate hoedown;
extern crate comrak;
extern crate r2d2;
extern crate r2d2_postgres;
extern crate url;
Expand Down
31 changes: 12 additions & 19 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,21 @@ fn match_version(conn: &Connection, name: &str, version: Option<&str>) -> Option



/// Wrapper around the pulldown-cmark parser and renderer to render markdown
/// Wrapper around the Markdown parser and renderer to render markdown
fn render_markdown(text: &str) -> String {
use hoedown::{Markdown, Html, Render, Extension};
use hoedown::renderer::html;

let extensions = {
use hoedown::{FENCED_CODE, FOOTNOTES, SUPERSCRIPT, TABLES, AUTOLINK, NO_INTRA_EMPHASIS};

let mut extensions = Extension::empty();
extensions.insert(FENCED_CODE);
extensions.insert(FOOTNOTES);
extensions.insert(SUPERSCRIPT);
extensions.insert(TABLES);
extensions.insert(AUTOLINK);
extensions.insert(NO_INTRA_EMPHASIS);

extensions
use comrak::{markdown_to_html, ComrakOptions};

let options = {
let mut options = ComrakOptions::default();
options.ext_superscript = true;
options.ext_table = true;
options.ext_autolink = true;
options.ext_tasklist = true;
options.ext_strikethrough = true;
options
};

let doc = Markdown::new(text).extensions(extensions);
let mut html = Html::new(html::Flags::empty(), 0);
html.render(&doc).to_str().unwrap().to_owned()
markdown_to_html(text, &options)
}


Expand Down