From ce4f9a378703ad8043bec19722399b5d4b78f162 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 4 Feb 2011 21:05:48 -0800 Subject: HTML writer: Spacing adjustments for Plain and RawHtml blocks. --- src/Text/Pandoc/Writers/HTML.hs | 2 + tests/s5.basic.html | 12 +- tests/s5.fancy.html | 12 +- tests/s5.fragment.html | 9 +- tests/s5.inserts.html | 9 +- tests/tables.html | 308 ++++++++++++++-------------------------- tests/writer.html | 246 ++++++++++---------------------- 7 files changed, 196 insertions(+), 402 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index fe6bede09..637f8744f 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -317,6 +317,8 @@ attrsToHtml opts (id',classes',keyvals) = -- | Convert Pandoc block element to HTML. blockToHtml :: WriterOptions -> Block -> State WriterState Html +blockToHtml opts b@(Plain _) = blockToHtml' opts b +blockToHtml opts b@(RawBlock _ _) = blockToHtml' opts b blockToHtml opts b = blockToHtml' opts b >>= return . (nl opts +++) blockToHtml' :: WriterOptions -> Block -> State WriterState Html diff --git a/tests/s5.basic.html b/tests/s5.basic.html index f21cca0e7..581c7842e 100644 --- a/tests/s5.basic.html +++ b/tests/s5.basic.html @@ -40,25 +40,19 @@

First slide

- -

Math

-
diff --git a/tests/s5.fancy.html b/tests/s5.fancy.html index d0e653557..c165f95a0 100644 --- a/tests/s5.fancy.html +++ b/tests/s5.fancy.html @@ -239,25 +239,19 @@

First slide

- -

Math

-
diff --git a/tests/s5.fragment.html b/tests/s5.fragment.html index cca3f7244..bf93c05a2 100644 --- a/tests/s5.fragment.html +++ b/tests/s5.fragment.html @@ -1,15 +1,12 @@

First slide

Math

diff --git a/tests/s5.inserts.html b/tests/s5.inserts.html index afdec0fab..2de50c3dc 100644 --- a/tests/s5.inserts.html +++ b/tests/s5.inserts.html @@ -16,17 +16,14 @@ STUFF INSERTED

First slide

Math

STUFF INSERTED diff --git a/tests/tables.html b/tests/tables.html index 59f1390e5..95c1a4ef5 100644 --- a/tests/tables.html +++ b/tests/tables.html @@ -1,234 +1,142 @@

Simple table with caption:

- - - - - - - - - - - - - - - - - - - +
Demonstration of simple table syntax.
-Right -Left -Center -Default
-12 -12 -12 -12
-123 -123 -123 -123
-1 -1 -1 -1
+ + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111

Simple table without caption:

- - - - - - - - - - - - - - - - - - - +
-Right -Left -Center -Default
-12 -12 -12 -12
-123 -123 -123 -123
-1 -1 -1 -1
+ + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111

Simple table indented two spaces:

- - - - - - - - - - - - - - - - - - - +
Demonstration of simple table syntax.
-Right -Left -Center -Default
-12 -12 -12 -12
-123 -123 -123 -123
-1 -1 -1 -1
+ + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111

Multiline table with caption:

- - - - - - - - - - - - - - +
Here's the caption. It may span multiple lines.
-Centered Header -Left Aligned -Right Aligned -Default aligned
-First -row -12.0 -Example of a row that spans multiple lines.
-Second -row -5.0 -Here's another one. Note the blank line between rows.
+ + + + + + + + + + + + +
Here's the caption. It may span multiple lines.
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.

Multiline table without caption:

- - - - - - - - - - - - - - +
-Centered Header -Left Aligned -Right Aligned -Default aligned
-First -row -12.0 -Example of a row that spans multiple lines.
-Second -row -5.0 -Here's another one. Note the blank line between rows.
+ + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.

Table without column headers:

- - - - - - - - - - - - - - +
-12 -12 -12 -12
-123 -123 -123 -123
-1 -1 -1 -1
+ + + + + + + + + + + + +
12121212
123123123123
1111

Multiline table without column headers:

- - - - - - - - - +
-First -row -12.0 -Example of a row that spans multiple lines.
-Second -row -5.0 -Here's another one. Note the blank line between rows.
+ + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
diff --git a/tests/writer.html b/tests/writer.html index 2963a0294..02f0ea244 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -68,10 +68,8 @@

A list:

    -
  1. -item one
  2. -
  3. -item two
  4. +
  5. item one
  6. +
  7. item two

Nested block quotes:

@@ -117,12 +115,9 @@ These should not be escaped: \$ \\ \> \[ \{

Asterisks tight:

Asterisks loose:

@@ -139,12 +134,9 @@ asterisk 3

Pluses tight:

Pluses loose:

@@ -161,12 +153,9 @@ Plus 3

Minuses tight:

Minuses loose:

@@ -185,23 +174,17 @@ Minus 3

Tight:

    -
  1. -First
  2. -
  3. -Second
  4. -
  5. -Third
  6. +
  7. First
  8. +
  9. Second
  10. +
  11. Third

and:

    -
  1. -One
  2. -
  3. -Two
  4. -
  5. -Three
  6. +
  7. One
  8. +
  9. Two
  10. +
  11. Three

Loose using tabs:

@@ -242,16 +225,13 @@ Three

Nested

@@ -259,21 +239,15 @@ Tab

Here’s another:

    -
  1. -First
  2. -
  3. -Second: +
  4. First
  5. +
  6. Second:
      -
    • -Fee
    • -
    • -Fie
    • -
    • -Foe
    • +
    • Fee
    • +
    • Fie
    • +
    • Foe
  7. -
  8. -Third
  9. +
  10. Third

Same thing but with paragraphs:

@@ -285,12 +259,9 @@ Third

Second:

  • Third

  • @@ -315,24 +286,19 @@ Foe

    Fancy list markers

      -
    1. -begins with 2
    2. +
    3. begins with 2
    4. and now 3

      with a continuation

        -
      1. -sublist with roman numerals, starting with 4
      2. -
      3. -more items +
      4. sublist with roman numerals, starting with 4
      5. +
      6. more items
          -
        1. -a subsublist
        2. -
        3. -a subsublist
        4. +
        5. a subsublist
        6. +
        7. a subsublist
    @@ -340,20 +306,16 @@ a subsublist

    Nesting:

      -
    1. -Upper Alpha +
    2. Upper Alpha
        -
      1. -Upper Roman. +
      2. Upper Roman.
          -
        1. -Decimal start with 6 +
        2. Decimal start with 6
            -
          1. -Lower alpha with paren
          2. +
          3. Lower alpha with paren
    3. @@ -362,14 +324,11 @@ Lower alpha with paren

      Autonumbering:

        -
      1. -Autonumber.
      2. -
      3. -More. +
      4. Autonumber.
      5. +
      6. More.
          -
        1. -Nested.
        2. +
        3. Nested.
      @@ -387,16 +346,13 @@ Nested.
      apple
      -
      -red fruit +
      red fruit
      orange
      -
      -orange fruit +
      orange fruit
      banana
      -
      -yellow fruit +
      yellow fruit
      @@ -404,16 +360,13 @@ yellow fruit
      apple
      -
      -red fruit +
      red fruit
      orange
      -
      -orange fruit +
      orange fruit
      banana
      -
      -yellow fruit +
      yellow fruit
      @@ -459,16 +412,12 @@ yellow fruit
      apple
      -
      -red fruit -
      -computer +
      red fruit +
      computer
      orange
      -
      -orange fruit -
      -bank +
      orange fruit +
      bank
      @@ -503,10 +452,8 @@ bank

      orange fruit

        -
      1. -sublist
      2. -
      3. -sublist
      4. +
      5. sublist
      6. +
      7. sublist
      @@ -514,45 +461,32 @@ sublist

      HTML Blocks

      Simple block on one line:

      -
      - foo -

      And nested without indentation:

      -
      - foo -
      - bar -

      Interpreted markdown in a table:

      -
      - This is emphasized - - And this is strong -
      @@ -561,12 +495,9 @@ And this is strong

      Here’s a simple block:

      -
      - foo -
      @@ -583,26 +514,21 @@ foo

      Now, nested:

      -
      - foo -

      This should just be an HTML comment:

      -

      Multiline:

      - @@ -629,7 +554,6 @@ Blah

      Hr’s:

      -

      @@ -702,41 +626,28 @@ Blah

      LaTeX

      These shouldn’t be math:

      Here’s a LaTeX table:

      -

      Special Characters

      @@ -744,16 +655,11 @@ Escaped $: $73 this should be emphasized 23$.

      Here is some unicode:

      AT&T has an ampersand in their name.

      @@ -869,12 +775,9 @@ document.write(''+'Email link'+'<\/'+'a'+'>')

      With an ampersand: http://example.com/?foo=1&bar=2

      An e-mail address: