Commit graph

28 commits

Author SHA1 Message Date
Bartosz Dziewoński 006e6c6f0f Fix styling for code blocks with copy buttons next to floated content
Make the wrapper div for code block create a block formatting
context. This changes how floated content is laid out: previously
the wrapper was taking 100% width and tried to wrap text around the
floated content, now its width is limited by the width of floated
content. This way absolutely positioned elements inside the code
block (like the copy buttons) won't overlap the floated content.
We've had this problem before when adding line numbers (T272853),
and the workaround we used there won't work for the copy buttons.
It also lets us remove the background-color override, previously
needed to avoid it leaking outside the code block (T126010).

Bug: T40932
Change-Id: I7f51ea78d7fcf07358c6ee45275b2bae2e1cbeb8
2024-10-09 21:48:52 +02:00
Taavi Väänänen 66622c60a5
Make line numbering appear dark in dark mode
This includes some changes to the colors in light mode to make them
match Codex tokens.

Bug: T365926
Change-Id: Ifa5d762bffa3c4ebdcfa451cc4a9965cd7b1b064
2024-09-29 14:39:10 +03:00
Siddharth VP b8dd28343c Support dark mode for code blocks
Update the CSS generation script to generate styles for both light and
dark modes. The Pygments style 'default' is used for light mode, as
before, and 'monokai' for dark mode.

Bug: T365926
Change-Id: I0cc1f9a10d4ff8e0c279a12cacbb1c300225328f
2024-09-28 23:06:30 +05:30
Bartosz Dziewoński 91f3235ed9 Fix forced light mode background-color applied to the wrong element
Changes for T356956 applied the styles in the wrong place.

`<div class="mw-highlight">` should have no background (and we need
to override the default Pygments styles that add it).

`<div class="mw-highlight"><pre>` and `<code class="mw-highlight">`
should have background (and we need to override core MediaWiki styles
that adapt to light/dark mode with forced light mode colors).

Bug: T365927
Change-Id: I473203b12673f7bc004f953ab33fe36fb897e095
2024-08-29 20:43:40 +02:00
Steven Rawson 8662badc21 SyntaxHighlight: Add color to override skin
Bug: T356956
Bug: T365774
Change-Id: I968aa7c9fe28ee83cb62dfd78575e426da5daf5e
2024-05-25 23:32:36 +00:00
Jon Robson 9ecaf3bd13 Apply background to pre tags
This overrides the default skin rule for pre elements as seen
on [[mw:MediaWiki-Docker%2FExtension%2FWikiLambda]]

Bug: T356956
Change-Id: I0a28323f4269e7afb89dce78927e048734f15a49
2024-05-17 14:37:43 +00:00
Jon Robson dda5d1e788 Adjust colors for remaining color contrast issues in night mode
Fixes the remaining issues on
https://en.m.wikipedia.beta.wmflabs.org/wiki/SyntaxHighlight?minervanightmode=1

Follow up to Ic58482b73e520505bde26a47e74f131dd8a51671

Bug: T356956
Change-Id: I71e74980a1ff276d61d2320cfedd92a55b659c7f
2024-04-17 16:52:26 +00:00
Jon Robson 92f155db14 Make syntax highlighting readable in night mode
The existing color of background if set to inherit will not work
in night mode. There does seem to be a background set in pygments.generated
so this probably doesn't need to be defined at all, but I erred on the side
of caution.

When defining a background that is not using a Codex design token
we also want to define a color to avoid the status quo of unreadable
text.

Note: this is a short term fix for making the content readable.
We can theme this in night mode later after further analysis.

Bug: T356956
Change-Id: Ic58482b73e520505bde26a47e74f131dd8a51671
2024-04-16 00:10:42 +00:00
Umherirrender 00595fd798 stylelint: Enable selector-pseudo-element-colon-notation
Via stylelint --fix

Change-Id: I544aaa852df15c2b3088c65115f812e75c93f994
2023-03-30 01:00:39 +02:00
Ed Sanders 1a15a8832c Move position:relative to inner wrapper
The outer wrapper is 100% width, so making it position:relative
causes it to stack above floated elements.

Bug: T272853
Change-Id: I20a73b5086ebb03673f0435e27ca93432dcd000c
2021-01-25 14:43:18 +00:00
Ed Sanders e793626d52 Line number selection: Remove user-select:none
These rules were being kept for cached content, but were
actually breaking Firefox by triggering a multi-part selection.

Bug: T271614
Change-Id: I83fb4aab88fe1f34bc59d1da18ae8a6a4838a831
2021-01-19 20:32:39 +00:00
jenkins-bot 49043547f2 Merge "Line numbers use mw-content-ltr/rtl direction" 2021-01-15 21:39:51 +00:00
jenkins-bot 8824036ea9 Merge "Remove unused directionality styles" 2021-01-15 21:39:34 +00:00
jenkins-bot fe7e9f77e4 Merge "Remove -o-tab-size rule, no longer required by Grade C browsers" 2021-01-15 21:31:31 +00:00
Ebrahim Byagowi e5238a17a8 Line numbers use mw-content-ltr/rtl direction
Content blocks always output a directionality class. It defaults
to LTR as most code is LTR, but it is allowed to set it to RTL
by adding a dir attribute to the <syntaxhiglight> block.

Use this class to do CSS flipping instead of CSSJanus, as this
class indicates the direction of the code.

Bug: T271792
Change-Id: I084550c2775febf13596addfb3598d6ae1afa2db
2021-01-15 17:34:16 +00:00
Ed Sanders c895f1c9e4 Remove unused directionality styles
* direction:ltr default is not required as every block
  gets an mw-content-ltr/rtl class and dir=ltr/rtl attr
* float rules for line numbers are no longer used as
  they are now position:absolute

Change-Id: I417ae969bf969b7cb25fbcf9ca3b1457c7bc6549
2021-01-15 17:34:16 +00:00
Ed Sanders 76fd10659b Remove -o-tab-size rule, no longer required by Grade C browsers
Change-Id: I5d8ca364f96872a6a7da925b6d6cbebf35b7e523
2021-01-13 17:14:57 +00:00
Ed Sanders 8d645a385c De-emphasise line numbers
Use the darker text color for hovered/selected lines.

Bug: T271956
Change-Id: Icc6dce48a2e5720807309a47f84d8c2a7552a4f6
2021-01-13 16:55:02 +00:00
Umherirrender ecbc374f7d build: Run stylelint also for less files
no-descending-specificity:
Expected selector ".mw-highlight.mw-content-ltr .linenos" to come before
selector ".mw-highlight a:hover .linenos"

Change-Id: Ib8bd3dcc83058c6935b6b6c472554e3c1fa01eda
2021-01-10 13:40:20 +01:00
Ed Sanders 583e3b3db8 Add support for line anchors on code pages
Bug: T29531
Change-Id: Ic09086c19d37bdff8bb7e68bbb0f676ef87896fe
2021-01-03 00:19:13 +00:00
Ed Sanders ef196f31ff Fix positioning of line numbers in VE
Change-Id: I349e80d8ad96e240ecb7afcb43dafdd72a76a308
2021-01-03 00:19:13 +00:00
Ed Sanders 0aec99f386 Extend highlight into line number gutter
Change-Id: I8947dc11dc671c44db084287ff1b3fe497eaa25b
2021-01-01 19:55:06 +00:00
Ed Sanders d3b4227ed4 Fix selector specificty for Minerva
Bug: T270989
Change-Id: I55d6735002247b228b7c2a7406d684496b0b7f00
2021-01-01 16:42:55 +00:00
Ed Sanders 98c644a639 Improve appearance of line numbers
* Render a solid gutter that can take 3-4 digit line numbers
* Position line numbers absolutely in the gutter
* Add padding to code so that it doesn't wrap into the gutter

Change-Id: I7abb87452ad61808dad32b41c1d2d86b8ababb28
2020-12-30 21:35:04 +00:00
Ed Sanders f2ef11144a Display line numbers as generated CSS content
This makes them unselectable in more browsers as the
user-select fix isn't supported everywhere (e.g. Safari).

Bug: T32773
Change-Id: I274632a1055e1f85679fbb29c81629104cc8b222
2020-12-30 19:43:03 +00:00
Ed Sanders 6e558b37db Add small gap between line numbers and code
Change-Id: Ie65128872f318a42677e52420338684ad8d814f8
2020-12-30 19:43:03 +00:00
Ed Sanders 9c0e82878e Fix classname lineno->linenos
Bug: T270296
Change-Id: Ia11c2f13161bfd5b8c1c7e898416373202736c76
2020-12-30 19:43:00 +00:00
Ed Sanders 62cd4384ba Convert pygments.wrapper.css to LESS
Change-Id: I3b221a146528cfc328666da40f99f3132d0ac700
2020-12-30 15:31:33 +00:00