Topic on Extension talk:TemplateStyles

Alex brollo (talkcontribs)

Two questions, mainly related to wikisource needs.

  1. TemplateStyles adds new css. The loaded css works into the whole page? I imagine a text with different tables, with different formatting needs.
  2. Wikisource needs that css can be exported in various derived files (i.e. ePub), is new css injected by TemplateStyles exported / exportable?

One more question, general.

How/when new css is imported, considering complex timing of other css upload by ResourceLoader? Can we be confident about the fact that new css will be uploaded as the last one, t.i. "at the bottom of the cascade"?

Anomie (talkcontribs)
  1. The loaded CSS is automatically scoped to the parsed wikitext's output (by prepending a class to each style rule), but it (currently) can affect the whole content area. It's recommended that you use classes to more specifically target only the corresponding template's output, to make it less likely for different templates' styles to conflict with each other.
  2. That's up to your export tool, probably. On the plus side, you'll be able to use @media and the like.

Re your "one more question", the CSS is included inline in the body at the point where the <templatestyles/> tag appears in the wikitext. Thus it should cascade after ResourceLoader styles.

Also, if the same CSS page is included multiple times, the PHP parser output is postprocessed to replace the extra inclusions with a placeholder. Parsoid doesn't do this postprocessing yet, see phab:T187142.