Skip to content

Commit bc2b5f7

Browse files
authored
More fixes for HTMLization and PDFization (ietf-tools#4899)
* More fixes for HTMLization and PDFization * Remove print * More fixed from @martinthomson * Hopefully fix ietf-tools#4885 * Apply suggestion from @rjsparks
1 parent c3e7c1e commit bc2b5f7

3 files changed

Lines changed: 75 additions & 31 deletions

File tree

ietf/doc/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ def htmlized(self):
606606
# The path here has to match the urlpattern for htmlized
607607
# documents in order to produce correct intra-document links
608608
html = rfc2html.markup(text, path=settings.HTMLIZER_URL_PREFIX)
609+
html = f'<div class="rfcmarkup">{html}</div>'
609610
if html:
610611
cache.set(cache_key, html, settings.HTMLIZER_CACHE_TIME)
611612
return html

ietf/static/css/document_html.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ $tooltip-margin: inherit !default;
154154
}
155155

156156
pre {
157-
width: 72ch;
158157
margin: 0;
159158
padding: 0;
160159
}
@@ -176,6 +175,11 @@ $tooltip-margin: inherit !default;
176175
white-space: pre;
177176
display: inline;
178177
}
178+
179+
.newpage {
180+
margin-top: -1.25em;
181+
}
182+
179183
}
180184

181185
tbody.meta tr {
@@ -299,11 +303,16 @@ tbody.meta tr {
299303
margin: .75in;
300304
}
301305

302-
* {
306+
.rfcmarkup {
303307
font-size: 9.75pt !important;
304308
line-height: 1.25em !important;
305309
}
306310

311+
.rfchtml {
312+
font-size: 9.75pt;
313+
line-height: 1.25em;
314+
}
315+
307316
body {
308317
margin: 0;
309318
padding: 0;

ietf/static/css/document_html_txt.scss

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ blockquote {
7070
border-left: 2px solid darkgrey;
7171
}
7272

73-
// Don't wrap boilerplate URLs; makes it look more like text version.
74-
:is(#status-of-memo, #copyright) a[href] {
75-
white-space: nowrap;
76-
}
77-
7873
/* Header junk */
7974
#external-metadata {
8075
display: none !important; /* metadata.min.js is evil because it produces unstyleable goop */
@@ -87,18 +82,13 @@ blockquote {
8782
}
8883
#identifiers {
8984
margin: 0;
90-
display: grid;
91-
grid-template-columns: 47ch 24ch;
92-
grid-auto-rows: auto;
93-
gap: 0 1ch;
9485
}
9586
#identifiers dt {
9687
margin: 0 1ch 0 0;
9788
float: revert;
9889
display: inline-block;
9990
}
10091
#identifiers dd {
101-
grid-column: 1;
10292
margin: 0;
10393
width: 47ch;
10494
/* HAXX: this gets around the lack of text-content-trim support */
@@ -146,7 +136,7 @@ blockquote {
146136
margin: 0 0 0 1ch;
147137
}
148138
#identifiers dd:is(.updates, .obsoletes) a:last-of-type {
149-
margin: 0 1ch;
139+
margin-right: 1ch;
150140
}
151141
#identifiers dd.published::before {
152142
content: "Published:";
@@ -160,11 +150,52 @@ blockquote {
160150
#identifiers dd.issn::before {
161151
content: "ISSN:";
162152
}
163-
#identifiers dd.authors {
164-
grid-area: 1 / 2 / 100 / 3;
165-
width: 24ch;
166-
text-align: right;
167-
display: block;
153+
154+
/* Thanks WeasyPrint for not supporting @supports */
155+
/* @supports not (display: grid) { */
156+
#identifiers dd.authors {
157+
padding-left: 8ch;
158+
width: 64ch;
159+
}
160+
#identifiers dd.authors::before {
161+
content: "Authors:";
162+
margin: 0 0 0 -8ch;
163+
}
164+
#identifiers dd.authors .author {
165+
display: inline-block;
166+
margin: 0 2ch 0 1ch;
167+
}
168+
#identifiers dd.authors .author:last-of-type {
169+
margin-right: 0;
170+
}
171+
/* } */
172+
/* #identifiers styling for when grid layout is supported, or not */
173+
@supports(display: grid) {
174+
#identifiers {
175+
display: grid;
176+
grid-template-columns: 47ch 24ch;
177+
grid-auto-rows: auto;
178+
gap: 0 1ch;
179+
}
180+
#identifiers dd {
181+
grid-column: 1;
182+
}
183+
#identifiers dd.authors {
184+
grid-area: 1 / 2 / 100 / 3;
185+
width: 24ch;
186+
text-align: right;
187+
display: block;
188+
/* overrides for @supports not block */
189+
padding-left: 0;
190+
}
191+
/* more overrides for @supports not block */
192+
#identifiers dd.authors::before {
193+
display: none;
194+
}
195+
#identifiers dd.authors .author {
196+
display: block;
197+
margin: 0;
198+
}
168199
}
169200

170201
#title {
@@ -175,6 +206,9 @@ blockquote {
175206
#rfcnum {
176207
display: none;
177208
}
209+
:is(#status-of-memo, #copyright) a {
210+
white-space: nowrap;
211+
}
178212
.toplink {
179213
display: none;
180214
}
@@ -200,7 +234,7 @@ ol, ul {
200234
ol {
201235
margin: 0 0 0 6ch; /* todo: deal with lists that have >= 10 items */
202236
}
203-
ol ol, ul ol {
237+
:is(ol, ul) ol {
204238
margin: 0 0 0 3ch;
205239
}
206240
ul {
@@ -210,7 +244,7 @@ ul {
210244
ul ul {
211245
list-style-type: '-';
212246
}
213-
ul ul, ol ul {
247+
:is(ul, ol) ul {
214248
margin-left: 1ch;
215249
}
216250
ul ul ul {
@@ -224,7 +258,7 @@ li {
224258
.compact li {
225259
margin: 0;
226260
}
227-
li p:first-child, dd p:first-child {
261+
:is(li, dd) p:first-child {
228262
margin: 0;
229263
}
230264
dt {
@@ -238,7 +272,7 @@ dd {
238272
@include margin-paragraph;
239273
break-before: avoid;
240274
}
241-
dl.compact dt, dl.compact dd {
275+
dl.compact :is(dt, dd) {
242276
margin-top: 0;
243277
margin-bottom: 0;
244278
}
@@ -248,7 +282,7 @@ dl.references dt {
248282
dl.references dd {
249283
margin-left: 11ch;
250284
}
251-
dd.break {
285+
:is(dd, span).break {
252286
display: none;
253287
}
254288

@@ -257,31 +291,31 @@ pre {
257291
// margin: var(--line) 0;
258292
@include margin-line;
259293
}
260-
div.artwork, div.sourcecode {
294+
div:is(.artwork, .sourcecode) {
261295
display: flex;
262296
flex-wrap: nowrap;
263297
align-items: end;
264298
}
265-
div.artwork.alignCenter, div.sourcecode.alignCenter {
299+
div:is(.artwork, .sourcecode).alignCenter {
266300
justify-content: center;
267301
}
268-
div.artwork.alignRight, div.sourcecode.alignRight {
302+
div:is(.artwork, .sourcecode).alignRight {
269303
justify-content: end;
270304
}
271-
div.artwork::before, div.sourcecode::before {
305+
div:is(.artwork, .sourcecode)::before {
272306
flex: 0 1 3ch;
273307
content: "";
274308
}
275-
div.artwork.alignRight::before, div.sourcecode.alignRight::before {
309+
div:is(.artwork, .sourcecode).alignRight::before {
276310
flex-grow: 1;
277311
}
278-
div.artwork pre, div.sourcecode pre {
312+
div:is(.artwork, .sourcecode) pre {
279313
flex: 0 0 content;
280314
margin: 0;
281315
max-width: 72ch;
282316
overflow: auto;
283317
}
284-
div.artwork .pilcrow, div.sourcecode .pilcrow {
318+
div:is(.artwork, .sourcecode) .pilcrow {
285319
flex: 0 0 1ch;
286320
}
287321
figcaption, table caption {
@@ -335,7 +369,7 @@ a.selfRef, a.pilcrow {
335369
a.relref, a.xref {
336370
hyphens: none;
337371
}
338-
a.relref, a.xref.cite {
372+
a:is(.relref, .xref:is(.cite, .auto.internal)) {
339373
white-space: nowrap;
340374
}
341375
.pilcrow {

0 commit comments

Comments
 (0)