Skip to content

Commit

Permalink
fix: Move sourcecode classes (#839)
Browse files Browse the repository at this point in the history
* Move sourcecode classes

The HTML elements created for a `<sourcecode>` element have class
attributes attached to the `<pre>` element.  In comparison, `<artwork>`
is rendered with class attributes attached to the outer `<div>`.

Having the classes on the outer `<div>` makes it a LOT easier to style
these properly, so I've moved them to this CL.

* Update CSS to match

* .breakable is also affected
  • Loading branch information
martinthomson authored Nov 6, 2022
1 parent d86b1f2 commit 1381bb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions xml2rfc/data/xml2rfc.css
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ hr.addr {
figure {
overflow: scroll;
}
pre.breakable {
.breakable pre {
break-inside: auto;
}
h1, h2, h3, h4, h5, h6 {
Expand Down Expand Up @@ -792,7 +792,7 @@ tt, code, pre {
}

/* Fix the height/width aspect for ascii art*/
pre.sourcecode,
.sourcecode pre,
.art-text pre {
line-height: 1.12;
}
Expand Down Expand Up @@ -1128,7 +1128,7 @@ dd > div.artwork:first-child,
dd > aside:first-child,
dd > figure:first-child,
dd > ol:first-child,
dd > div:first-child > pre.sourcecode,
dd > div.sourcecode:first-child,
dd > table:first-child,
dd > ul:first-child {
clear: left;
Expand Down
4 changes: 2 additions & 2 deletions xml2rfc/writers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -2469,9 +2469,9 @@ def render_sourcecode(self, h, x):
classes += ' lang-%s' % type
if (len(x.text.split('\n')) > 50):
classes += ' breakable'
div = add.div(h, x)
div = add.div(h, x, classes=classes)
div.text = None
pre = add.pre(div, None, x.text, classes=classes)
pre = add.pre(div, None, x.text)
if mark:
text = pre.text
if file:
Expand Down

0 comments on commit 1381bb8

Please sign in to comment.