update & configure cmark to render three backticks

This commit is contained in:
Zac Pullar-Strecker 2020-08-02 20:19:14 +12:00
parent c4d4869f23
commit b34ad4bc8a
5 changed files with 175 additions and 173 deletions

4
Cargo.lock generated
View File

@ -903,9 +903,9 @@ dependencies = [
[[package]]
name = "pulldown-cmark-to-cmark"
version = "4.0.2"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cffb594e453d29e238ac190362a4a291daec00396717a8d1670863121ac56958"
checksum = "32accf4473121d8c0b508ca5673363703762d6cc59cf25af1df48f653346f736"
dependencies = [
"pulldown-cmark",
]

View File

@ -17,8 +17,8 @@ indexmap = "1.3.2"
itertools = "0.9.0"
log = "0.4.8"
rustc-hash = "1.1.0"
url = "*"
pulldown-cmark-to-cmark = "4.0.2"
url = "2.1.1"
pulldown-cmark-to-cmark = "5.0.0"
pulldown-cmark = {version = "0.7.2", default-features = false}
oorandom = "11.1.2"

View File

@ -425,9 +425,9 @@ fn main() {
expect![[r#"
*iter*
````rust
```rust
Iter<Scan<OtherStruct<OtherStruct<i32>>, |&mut u32, &u32, &mut u32| -> Option<u32>, u32>>
````
```
"#]],
);
}
@ -444,13 +444,13 @@ pub fn foo() -> u32 { 1 }
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
pub fn foo() -> u32
````
```
"#]],
);
@ -493,13 +493,13 @@ pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { }
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str
````
```
"#]],
);
}
@ -515,13 +515,13 @@ fn main() { }
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
pub fn foo(a: u32, b: u32) -> u32
````
```
"#]],
);
}
@ -540,13 +540,13 @@ fn main() {
expect![[r#"
*field_a*
````rust
```rust
test::Foo
````
```
````rust
```rust
field_a: u32
````
```
"#]],
);
@ -562,13 +562,13 @@ fn main() {
expect![[r#"
*field_a*
````rust
```rust
test::Foo
````
```
````rust
```rust
field_a: u32
````
```
"#]],
);
}
@ -580,13 +580,13 @@ fn hover_const_static() {
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
const foo: u32
````
```
"#]],
);
check(
@ -594,13 +594,13 @@ fn hover_const_static() {
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
static foo: u32
````
```
"#]],
);
}
@ -617,9 +617,9 @@ fn main() {
expect![[r#"
*zz*
````rust
```rust
Test<i32, u8>
````
```
"#]],
);
}
@ -636,13 +636,13 @@ enum Option<T> { Some(T) }
expect![[r#"
*Some*
````rust
```rust
test::Option
````
```
````rust
```rust
Some
````
```
"#]],
);
@ -656,9 +656,9 @@ enum Option<T> { Some(T) }
expect![[r#"
*bar*
````rust
```rust
Option<i32>
````
```
"#]],
);
}
@ -675,13 +675,13 @@ enum Option<T> {
expect![[r#"
*None*
````rust
```rust
test::Option
````
```
````rust
```rust
None
````
```
---
@ -702,13 +702,13 @@ fn main() {
expect![[r#"
*Some*
````rust
```rust
test::Option
````
```
````rust
```rust
Some
````
```
---
@ -724,9 +724,9 @@ fn hover_for_local_variable() {
expect![[r#"
*foo*
````rust
```rust
i32
````
```
"#]],
)
}
@ -738,9 +738,9 @@ fn hover_for_local_variable_pat() {
expect![[r#"
*foo*
````rust
```rust
i32
````
```
"#]],
)
}
@ -752,9 +752,9 @@ fn hover_local_var_edge() {
expect![[r#"
*foo*
````rust
```rust
i32
````
```
"#]],
)
}
@ -766,9 +766,9 @@ fn hover_for_param_edge() {
expect![[r#"
*foo*
````rust
```rust
i32
````
```
"#]],
)
}
@ -788,9 +788,9 @@ fn new() -> Thing { Thing { x: 0 } }
expect![[r#"
*foo_test*
````rust
```rust
Thing
````
```
"#]],
)
}
@ -812,13 +812,13 @@ fn new() -> Thing { Thing { x: 0 } }
expect![[r#"
*new*
````rust
```rust
test::wrapper::Thing
````
```
````rust
```rust
fn new() -> Thing
````
```
"#]],
)
}
@ -843,13 +843,13 @@ fn main() {
expect![[r#"
*C*
````rust
```rust
test
````
```
````rust
```rust
const C: u32
````
```
"#]],
)
}
@ -925,9 +925,9 @@ fn y() {
expect![[r#"
*x*
````rust
```rust
i32
````
```
"#]],
)
}
@ -943,13 +943,13 @@ macro_rules! foo { () => {} }
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
macro_rules! foo
````
```
"#]],
)
}
@ -978,13 +978,13 @@ fn foo() {}
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
fn foo()
````
```
"#]],
);
}
@ -999,9 +999,9 @@ macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
expect![[r#"
*bar*
````rust
```rust
u32
````
```
"#]],
);
}
@ -1017,9 +1017,9 @@ macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
expect![[r#"
*bar*
````rust
```rust
u32
````
```
"#]],
);
}
@ -1076,13 +1076,13 @@ fn foo() {
expect![[r#"
*bar*
````rust
```rust
test
````
```
````rust
```rust
fn bar() -> bool
````
```
"#]],
);
}
@ -1113,13 +1113,13 @@ fn foo() { }
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
fn foo()
````
```
---
@ -1135,13 +1135,13 @@ fn test_hover_function_show_qualifiers() {
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
async fn foo()
````
```
"#]],
);
check(
@ -1149,13 +1149,13 @@ async fn foo()
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
pub const unsafe fn foo()
````
```
"#]],
);
check(
@ -1163,13 +1163,13 @@ async fn foo()
expect![[r#"
*foo*
````rust
```rust
test
````
```
````rust
```rust
pub(crate) async unsafe extern "C" fn foo()
````
```
"#]],
);
}
@ -1205,13 +1205,13 @@ fn my() {}
expect![[r#"
*my*
````rust
```rust
test
````
```
````rust
```rust
mod my
````
```
"#]],
);
}
@ -1228,13 +1228,13 @@ fn test_hover_struct_doc_comment() {
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
struct Bar
````
```
---
@ -1255,13 +1255,13 @@ fn test_hover_struct_doc_attr() {
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
struct Bar
````
```
---
@ -1284,13 +1284,13 @@ fn test_hover_struct_doc_attr_multiple_and_mixed() {
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
struct Bar
````
```
---
@ -1315,13 +1315,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1342,13 +1342,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1371,13 +1371,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1398,13 +1398,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1425,13 +1425,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1453,13 +1453,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1480,13 +1480,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1507,13 +1507,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1536,13 +1536,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1563,13 +1563,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1591,13 +1591,13 @@ pub struct B<|>ar
expect![[r#"
*Bar*
````rust
```rust
test
````
```
````rust
```rust
pub struct Bar
````
```
---
@ -1629,13 +1629,13 @@ fn foo(&self) {}
expect![[r#"
*foo*
````rust
```rust
test::Bar
````
```
````rust
```rust
fn foo(&self)
````
```
---
@ -1667,13 +1667,13 @@ fn foo(&self) {}
expect![[r#"
*foo*
````rust
```rust
test::Bar
````
```
````rust
```rust
fn foo(&self)
````
```
---

View File

@ -4,7 +4,7 @@
use itertools::Itertools;
use pulldown_cmark::{CowStr, Event, Options, Parser, Tag};
use pulldown_cmark_to_cmark::cmark;
use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions};
use url::Url;
use hir::{Adt, AsName, AttrDef, Crate, Hygiene, ItemInNs, ModPath, ModuleDef};
@ -42,7 +42,9 @@ pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition)
}
});
let mut out = String::new();
cmark(doc, &mut out, None).ok();
let mut options = CmarkOptions::default();
options.code_block_backticks = 3;
cmark_with_options(doc, &mut out, None, options).ok();
out
}

View File

@ -680,5 +680,5 @@ pub fn foo(_input: TokenStream) -> TokenStream {
});
let value = res.get("contents").unwrap().get("value").unwrap().to_string();
assert_eq!(value, r#""\n````rust\nfoo::Bar\n````\n\n````rust\nfn bar()\n````""#)
assert_eq!(value, r#""\n```rust\nfoo::Bar\n```\n\n```rust\nfn bar()\n```""#)
}