Skip to content

rustdoc: Don't strip #-lines if notrust #17090

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
Sep 9, 2014
Merged
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
24 changes: 9 additions & 15 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,35 +153,25 @@ local_data_key!(test_idx: Cell<uint>)
local_data_key!(pub playground_krate: Option<String>)

pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
extern fn block(ob: *mut hoedown_buffer, text: *const hoedown_buffer,
extern fn block(ob: *mut hoedown_buffer, orig_text: *const hoedown_buffer,
lang: *const hoedown_buffer, opaque: *mut libc::c_void) {
unsafe {
if text.is_null() { return }
if orig_text.is_null() { return }

let opaque = opaque as *mut hoedown_html_renderer_state;
let my_opaque: &MyOpaque = &*((*opaque).opaque as *const MyOpaque);
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
slice::raw::buf_as_slice((*orig_text).data, (*orig_text).size as uint,
|text| {
let origtext = str::from_utf8(text).unwrap();
debug!("docblock: ==============\n{}\n=======", text);
let mut lines = origtext.lines().filter(|l| {
stripped_filtered_line(*l).is_none()
});
let text = lines.collect::<Vec<&str>>().connect("\n");

let buf = hoedown_buffer {
data: text.as_bytes().as_ptr(),
size: text.len() as libc::size_t,
asize: text.len() as libc::size_t,
unit: 0,
};
let rendered = if lang.is_null() {
false
} else {
slice::raw::buf_as_slice((*lang).data,
(*lang).size as uint, |rlang| {
let rlang = str::from_utf8(rlang).unwrap();
if LangString::parse(rlang).notrust {
(my_opaque.dfltblk)(ob, &buf, lang,
(my_opaque.dfltblk)(ob, orig_text, lang,
opaque as *mut libc::c_void);
true
} else {
Expand All @@ -190,6 +180,10 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
})
};

let mut lines = origtext.lines().filter(|l| {
stripped_filtered_line(*l).is_none()
});
let text = lines.collect::<Vec<&str>>().connect("\n");
if !rendered {
let mut s = String::new();
let id = playground_krate.get().map(|krate| {
Expand Down