aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/style.css___40__unnecessarily__41___breaks_pandoc_table_headers.mdwn
blob: aa4eec9040b8c4a09de93136ccea0c4647768ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
This may, strictly speaking, be a bug in the [[plugins/contrib/pandoc]] plugin, but I think it would be better to fix it in ikiwiki because of its kind (and maybe because I believe/hope pandoc will become the markdown dialect standard). For all I know it might not only affect pandoc tables. 

When creating a simple table in pandoc-flavoured markdown,

    1    2
    ---  ---
    3    4

pandoc converts this to the html code

	<table>
	<thead>
	<tr class="header">
	<th align="left">1</th>
	<th align="left">2</th>
	</tr>
	</thead>
	<tbody>
	<tr class="odd">
	<td align="left">3</td>
	<td align="left">4</td>
	</tr>
	</tbody>
	</table>

`<tr class="header">` causes it to be affected by `style.css`'s

	.header {
		margin: 0;
		font-size: 140%;
		font-weight: bold;
		line-height: 1em;
		display: block;
	}

(more specifically by `display: block;`), which results in all header cells to cramp together in the first column.

The fix is easy: In `style.css` change `.header {` to `.header tr:not(.header) {`.

Alternatively, add the following code.

	tr.header {
		display: table-row;
		}

I've added that last code snippet to my `custom.css` file. I admit `.header tr:not(.header)` is not especially elegant, but then again, I have almost no knowledge of CSS. There might be better solutions. (I don't even know why `display: block;` breaks the tables or why changing it to `display: table-header;` doesn't fix it but `display: table-row;` does :D )

> This is essentially a conflict between ikiwiki's expectations for the
> definitions of CSS classes, and pandoc's expectations. The ikiwiki
> templates use `class="header"` to mean essentially the same thing
> as a HTML5 `<header>`, while Pandoc assumes a different meaning.
>
> I think `div.header, header.header {` is probably a cleaner fix,
> and I have [[done]] that.
>
> FYI, `display: block` breaks the tables because it makes the `<tr>` not
> be treated as a table row by the browser's layout engine.
> `table-header` is not a valid
> [value for the CSS `display` attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/display)
> so that won't work.
>
> --[[smcv]]