From ec53e5420b41725a14b9bf0fc5d89e90bcfb882d Mon Sep 17 00:00:00 2001 From: Philipp A Date: Sat, 7 Dec 2019 17:28:13 +0100 Subject: On second thought let’s not overcomplicate things --- src/renderer/html.rs | 2 +- src/renderer/html_tests.rs | 245 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 245 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/renderer/html.rs b/src/renderer/html.rs index 68b471c..b3ee343 100644 --- a/src/renderer/html.rs +++ b/src/renderer/html.rs @@ -227,7 +227,7 @@ impl HTMLRender for String { impl HTMLRender for e::Reference { fn render_html(&self, stream: &mut W) -> Result<(), Error> where W: Write { let extra = self.extra(); - write!(stream, "Simple String

", + ); +} + +#[test] +fn test_simple_string_with_markup() { + check_renders_to( + "Simple String with *markup*", + "

Simple String with markup

", + ); +} + +#[test] +fn test_check_inline_literal() { + check_renders_to( + "Simple String with an even simpler ``inline literal``", + "

Simple String with an even simpler inline literal

", + ); +} + +#[test] +fn test_reference_anonymous() { + check_renders_to("\ +A simple `anonymous reference`__ + +__ http://www.test.com/test_url +", "\ +

A simple anonymous reference

\ +"); +} + +#[test] +fn test_two_paragraphs() { + check_renders_to( + "One paragraph.\n\nTwo paragraphs.", + "

One paragraph.

\n

Two paragraphs.

", + ); +} + +#[test] +fn test_named_reference() { + check_renders_to("\ +A simple `named reference`_ with stuff in between the +reference and the target. + +.. _`named reference`: http://www.test.com/test_url +", "\ +

A simple named reference with stuff in between the +reference and the target.

\ +"); +} + +/* +#[test] +fn test_section_hierarchy() { + check_renders_to("\ ++++++ +Title ++++++ + +Subtitle +======== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +", "\ +

Some stuff

+
+

Section

+

Some more stuff

+
+

Another Section

+

And even more stuff

+
+
\ +"); +} + +#[test] +fn test_docinfo_title() { + check_renders_to("\ ++++++ +Title ++++++ + +:author: me + +Some stuff +", "\ +
+

Title

+
+
Author
+

me

+
+

Some stuff

+
\ +"); +} +*/ + +#[test] +fn test_section_hierarchy() { + check_renders_to("\ ++++++ +Title ++++++ + +Not A Subtitle +============== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +", "\ +
+

Title

+
+

Not A Subtitle

+

Some stuff

+
+

Section

+

Some more stuff

+
+

Another Section

+

And even more stuff

+
+
+
+
\ +"); +} + +#[test] +fn test_bullet_list() { + check_renders_to("\ +* bullet +* list +", "\ +\ +"); +} + +#[test] +fn test_table() { + check_renders_to("\ +.. table:: + :align: right + + +-----+-----+ + | 1 | 2 | + +-----+-----+ + | 3 | 4 | + +-----+-----+ +", "\ + ++++ + + + + + + + + +

1

2

3

4

\ +"); +} + +#[test] +fn test_field_list() { + check_renders_to("\ +Not a docinfo. + +:This: .. _target: + + is +:a: +:simple: +:field: list +", "\ +

Not a docinfo.

+
+
This
+

is

+
+
a
+

+
simple
+

+
field
+

list

+
+
\ +"); +} + +#[test] +fn test_field_list_long() { + check_renders_to("\ +Not a docinfo. + +:This is: a +:simple field list with loooong field: names +", "\ +

Not a docinfo.

+
+
This is
+

a

+
+
simple field list with loooong field
+

names

+
+
\ +"); +} + -- cgit v1.2.3