mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Split the input/output data of the conversion from the test code to the respective files
This commit is contained in:
parent
c78d759ab3
commit
0c6fd4dbe5
@ -573,185 +573,13 @@ impl Macro {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
#[test]
|
||||
fn test_asciidoc_to_markdown_conversion() {
|
||||
let input = "\
|
||||
= Changelog #256
|
||||
:sectanchors:
|
||||
:page-layout: post
|
||||
|
||||
Hello!
|
||||
|
||||
Commit: commit:0123456789abcdef0123456789abcdef01234567[] +
|
||||
Release: release:2022-01-01[]
|
||||
|
||||
== New Features
|
||||
|
||||
* **BREAKING** pr:1111[] shortcut kbd:[ctrl+r]
|
||||
- hyphen-prefixed list item
|
||||
* nested list item
|
||||
** `foo` -> `foofoo`
|
||||
** `bar` -> `barbar`
|
||||
* listing in the secondary level
|
||||
. install
|
||||
. add to config
|
||||
+
|
||||
[source,json]
|
||||
----
|
||||
{\"foo\":\"bar\"}
|
||||
----
|
||||
* list item with continuation
|
||||
+
|
||||
image::https://example.com/animation.gif[]
|
||||
+
|
||||
image::https://example.com/animation.gif[\"alt text\"]
|
||||
+
|
||||
video::https://example.com/movie.mp4[options=loop]
|
||||
+
|
||||
video::https://example.com/movie.mp4[options=\"autoplay,loop\"]
|
||||
+
|
||||
.Image
|
||||
image::https://example.com/animation.gif[]
|
||||
+
|
||||
.Video
|
||||
video::https://example.com/movie.mp4[options=loop]
|
||||
+
|
||||
[source,bash]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
+
|
||||
----
|
||||
This is a plain listing.
|
||||
----
|
||||
* single line item followed by empty lines
|
||||
|
||||
* multiline list
|
||||
item followed by empty lines
|
||||
|
||||
* multiline list
|
||||
item with indent
|
||||
|
||||
* multiline list
|
||||
item not followed by empty lines
|
||||
* multiline list
|
||||
item followed by different marker
|
||||
** foo
|
||||
** bar
|
||||
* multiline list
|
||||
item followed by list continuation
|
||||
+
|
||||
paragraph
|
||||
paragraph
|
||||
|
||||
== Another Section
|
||||
|
||||
* foo bar baz
|
||||
* list item with an inline image
|
||||
image:https://example.com/animation.gif[]
|
||||
|
||||
The highlight of the month is probably pr:1111[].
|
||||
See https://example.com/manual[online manual] for more information.
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
|
||||
[source]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
|
||||
----
|
||||
This is a plain listing.
|
||||
----
|
||||
";
|
||||
let expected = "\
|
||||
# Changelog #256
|
||||
|
||||
Hello!
|
||||
|
||||
Commit: [`0123456`](https://github.com/rust-analyzer/rust-analyzer/commit/0123456789abcdef0123456789abcdef01234567) \\
|
||||
Release: [`2022-01-01`](https://github.com/rust-analyzer/rust-analyzer/releases/2022-01-01)
|
||||
|
||||
## New Features
|
||||
|
||||
- **BREAKING** [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111) shortcut <kbd>ctrl</kbd>+<kbd>r</kbd>
|
||||
- hyphen-prefixed list item
|
||||
- nested list item
|
||||
- `foo` -> `foofoo`
|
||||
- `bar` -> `barbar`
|
||||
- listing in the secondary level
|
||||
1. install
|
||||
1. add to config
|
||||
|
||||
```json
|
||||
{\"foo\":\"bar\"}
|
||||
```
|
||||
- list item with continuation
|
||||
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
![alt text](https://example.com/animation.gif)
|
||||
|
||||
<video src=\"https://example.com/movie.mp4\" controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
<video src=\"https://example.com/movie.mp4\" autoplay controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
_Image_\\
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
_Video_\\
|
||||
<video src=\"https://example.com/movie.mp4\" controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
```bash
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
This is a plain listing.
|
||||
```
|
||||
- single line item followed by empty lines
|
||||
- multiline list
|
||||
item followed by empty lines
|
||||
- multiline list
|
||||
item with indent
|
||||
- multiline list
|
||||
item not followed by empty lines
|
||||
- multiline list
|
||||
item followed by different marker
|
||||
- foo
|
||||
- bar
|
||||
- multiline list
|
||||
item followed by list continuation
|
||||
|
||||
paragraph
|
||||
paragraph
|
||||
|
||||
## Another Section
|
||||
|
||||
- foo bar baz
|
||||
- list item with an inline image
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
The highlight of the month is probably [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111).
|
||||
See [online manual](https://example.com/manual) for more information.
|
||||
|
||||
```bash
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
This is a plain listing.
|
||||
```
|
||||
";
|
||||
let actual = convert_asciidoc_to_markdown(std::io::Cursor::new(input)).unwrap();
|
||||
let input = read_to_string("test_data/input.adoc").unwrap();
|
||||
let expected = read_to_string("test_data/expected.md").unwrap();
|
||||
let actual = convert_asciidoc_to_markdown(std::io::Cursor::new(&input)).unwrap();
|
||||
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
81
xtask/test_data/expected.md
Normal file
81
xtask/test_data/expected.md
Normal file
@ -0,0 +1,81 @@
|
||||
# Changelog #256
|
||||
|
||||
Hello!
|
||||
|
||||
Commit: [`0123456`](https://github.com/rust-analyzer/rust-analyzer/commit/0123456789abcdef0123456789abcdef01234567) \
|
||||
Release: [`2022-01-01`](https://github.com/rust-analyzer/rust-analyzer/releases/2022-01-01)
|
||||
|
||||
## New Features
|
||||
|
||||
- **BREAKING** [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111) shortcut <kbd>ctrl</kbd>+<kbd>r</kbd>
|
||||
- hyphen-prefixed list item
|
||||
- nested list item
|
||||
- `foo` -> `foofoo`
|
||||
- `bar` -> `barbar`
|
||||
- listing in the secondary level
|
||||
1. install
|
||||
1. add to config
|
||||
|
||||
```json
|
||||
{"foo":"bar"}
|
||||
```
|
||||
- list item with continuation
|
||||
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
![alt text](https://example.com/animation.gif)
|
||||
|
||||
<video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
<video src="https://example.com/movie.mp4" autoplay controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
_Image_\
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
_Video_\
|
||||
<video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
|
||||
|
||||
```bash
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
This is a plain listing.
|
||||
```
|
||||
- single line item followed by empty lines
|
||||
- multiline list
|
||||
item followed by empty lines
|
||||
- multiline list
|
||||
item with indent
|
||||
- multiline list
|
||||
item not followed by empty lines
|
||||
- multiline list
|
||||
item followed by different marker
|
||||
- foo
|
||||
- bar
|
||||
- multiline list
|
||||
item followed by list continuation
|
||||
|
||||
paragraph
|
||||
paragraph
|
||||
|
||||
## Another Section
|
||||
|
||||
- foo bar baz
|
||||
- list item with an inline image
|
||||
![](https://example.com/animation.gif)
|
||||
|
||||
The highlight of the month is probably [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111).
|
||||
See [online manual](https://example.com/manual) for more information.
|
||||
|
||||
```bash
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
rustup update nightly
|
||||
```
|
||||
|
||||
```
|
||||
This is a plain listing.
|
||||
```
|
90
xtask/test_data/input.adoc
Normal file
90
xtask/test_data/input.adoc
Normal file
@ -0,0 +1,90 @@
|
||||
= Changelog #256
|
||||
:sectanchors:
|
||||
:page-layout: post
|
||||
|
||||
Hello!
|
||||
|
||||
Commit: commit:0123456789abcdef0123456789abcdef01234567[] +
|
||||
Release: release:2022-01-01[]
|
||||
|
||||
== New Features
|
||||
|
||||
* **BREAKING** pr:1111[] shortcut kbd:[ctrl+r]
|
||||
- hyphen-prefixed list item
|
||||
* nested list item
|
||||
** `foo` -> `foofoo`
|
||||
** `bar` -> `barbar`
|
||||
* listing in the secondary level
|
||||
. install
|
||||
. add to config
|
||||
+
|
||||
[source,json]
|
||||
----
|
||||
{"foo":"bar"}
|
||||
----
|
||||
* list item with continuation
|
||||
+
|
||||
image::https://example.com/animation.gif[]
|
||||
+
|
||||
image::https://example.com/animation.gif["alt text"]
|
||||
+
|
||||
video::https://example.com/movie.mp4[options=loop]
|
||||
+
|
||||
video::https://example.com/movie.mp4[options="autoplay,loop"]
|
||||
+
|
||||
.Image
|
||||
image::https://example.com/animation.gif[]
|
||||
+
|
||||
.Video
|
||||
video::https://example.com/movie.mp4[options=loop]
|
||||
+
|
||||
[source,bash]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
+
|
||||
----
|
||||
This is a plain listing.
|
||||
----
|
||||
* single line item followed by empty lines
|
||||
|
||||
* multiline list
|
||||
item followed by empty lines
|
||||
|
||||
* multiline list
|
||||
item with indent
|
||||
|
||||
* multiline list
|
||||
item not followed by empty lines
|
||||
* multiline list
|
||||
item followed by different marker
|
||||
** foo
|
||||
** bar
|
||||
* multiline list
|
||||
item followed by list continuation
|
||||
+
|
||||
paragraph
|
||||
paragraph
|
||||
|
||||
== Another Section
|
||||
|
||||
* foo bar baz
|
||||
* list item with an inline image
|
||||
image:https://example.com/animation.gif[]
|
||||
|
||||
The highlight of the month is probably pr:1111[].
|
||||
See https://example.com/manual[online manual] for more information.
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
|
||||
[source]
|
||||
----
|
||||
rustup update nightly
|
||||
----
|
||||
|
||||
----
|
||||
This is a plain listing.
|
||||
----
|
Loading…
Reference in New Issue
Block a user