racket / scribble

Other
194 stars 90 forks source link

HTML style attributes aren't applied to `*section`s #352

Closed sschwarzer closed 1 year ago

sschwarzer commented 1 year ago

The following Scribble file,

#lang scribble/manual

@(require
   scribble/html-properties
   scribble/core)

@(define red-style
   (make-style #f (list (attributes '((style . "color: red"))))))

@elem[#:style red-style]{red elem}
@section[#:style red-style]{red section}
@subsection[#:style red-style]{red subsection}
@subsection[#:style red-style]{red subsubsection}

is supposed to display all the text in the elem and *sections in red.

However, the style isn't applied to the *sections. The HTML is

...
<p><span style="color: red">red elem</span></p>
<h3>1<tt>&nbsp;</tt><a name="(part._red_section)"></a>red section</h3>
<h4>1.1<tt>&nbsp;</tt><a name="(part._red_subsection)"></a>red subsection</h4>
<h5>1.1.1<tt>&nbsp;</tt><a name="(part._red_subsubsection)"></a>red subsubsection</h5>
...

This problem might also occur for other functions apart from *section.

racket-discourse-github-bot commented 1 year ago

This issue has been mentioned on Racket Discussions. There might be relevant details there:

https://racket.discourse.group/t/adding-html-attributes-to-scribble-subsubsection/1296/2

sschwarzer commented 1 year ago

I described a workaround here, adding an alt-tag to an elem:

@(define entry-subsection-style
   (make-style
     #f
     (list (alt-tag "h5")
           (attributes '((style . "border: none;
                                   padding-top: 0px;
                                   margin-top: 1em;
                                   font-size: 1.4rem;"))))))

@(define (entry-subsection text)
   (elem #:style entry-subsection-style text)))

This isn't a "full" workaround though: