Commit graph

124 commits

Author SHA1 Message Date
Ed Sanders cd421a4b1d build: Update eslint-config-wikimedia to 0.28.0
Change-Id: Ia565bd4d314b7b512a46c4bb2af74784d5c2edc1
2024-06-06 16:33:02 +01:00
Novem Linguae 859db0ef3d JSDoc: @mixins -> @mixes
Convert old JSDuck syntax to new JSDoc syntax

Bug: T366230
Change-Id: If1103a5945f6be02f9f6d81ec361e873e40d0192
2024-05-31 15:38:02 +00: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
Novem Linguae e96144ff92 eslint: remove redundant ruleset wikimedia/jsdoc
The ruleset wikimedia/client-es6 already contains
the ruleset wikimedia/jsdoc. So wikimedia/jsdoc
doesn't need to be declared.

Bug: T365047
Change-Id: I59c8f9a244ff727273783b4a3104929232801819
2024-05-15 18:08:16 +00:00
James D. Forrester 5e92671865 eslint: Configure to lint against JSDoc, not old JSDuck
Bug: T138401
Change-Id: I82ae6840c1a37ce9b71e946674eb078c98f84c4b
2024-05-01 08:15:32 +01:00
Ed Sanders e69f76ffc8 Use ES6 syntax (arrow callbacks and let/const)
Change-Id: I494f8ee3ab3d805aafbc1c95a5b19b34de598d2b
2024-04-29 21:09:27 +01: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
jenkins-bot e3cfcbd571 Merge "Allow line ranges to be selected using shift+click" 2024-03-11 19:14:46 +00:00
Ed Sanders d6cc861de7 Allow line ranges to be selected using shift+click
Change-Id: I224de2d2d72525b61608d7b6d0f13ce84a699ef7
2024-03-06 22:30:51 +00:00
Ed Sanders 963859f8c9 VE integration: Remove copyright dates
Change-Id: I424e7bb7ac64297b55a47db058605f528084c35e
2024-02-29 15:13:03 +00:00
Ed Sanders e350f10a7e Don't let native scroll happen when clicking on line links
Update the page hash with history.replaceState instead.

Change-Id: I9d7bc25876aaae929646cd7e5960a8f76ede94f3
2024-02-06 16:33:46 +00:00
thiemowmde 040f45302b Fix GeSHi support, update PHP/JSDocs, use modern PHP
The PHPDoc/JSDoc updates are mostly about generic "array" types that
can be made more specific.

In PHP we can remove documentation when it is 100% identical to the
type declarations in the code.

A few mistakes are fixed as well, e.g. a missing "null".

This patch also made a major mistake visible. It looks like the
$geshi2pygments compatibility map was broken since 2018. The array was
changed from values to keys via I7a852dd and some usages updated, but
one was forgotten.

Change-Id: I480999d21f2f69cba84166bb877aa75882778966
2024-01-22 20:10:04 +01:00
Bryan Davis 99ce3504ba Update Pygments to 2.16.1
Bump embedded Pygments version from 2.15.0 to 2.16.1. Changes
<https://github.com/pygments/pygments/compare/2.15.0...2.16.1>.

New lexers: asn1, blueprint, bqn, desktop, graphql, openscad, ptx,
systemd, tls, urlencoded, verifpal, yar, yara, zon

Bug: T335460
Change-Id: I9577e2f38c8404698c5079033c3cd9742e8b383f
2023-08-15 04:03:17 +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
thiemowmde 0b13847937 Avoid dirty diffs when editing code blocks with line numbers
Steps to reproduce:
* Make a wikitext page with <syntaxhighlight line="sure">…</…>.
* Edit with VisualEditor and make an unrelated change to the content.
* Save.
* Before the attribute was always replaced with line="1".
* With this patch the old value stays untouched.

Change-Id: I433a206905c1a0a1bc06ef8b4037f6db9d935810
2022-10-26 12:59:32 +00:00
Ed Sanders f2613d589c Line number highlight: Use getTargetFromFragment
Bug: T315872
Depends-On: I605a24c708e60ccffde9dce524485f61fd5c7b06
Change-Id: I48c1aaf56ccea232dca7cb52f24a29a421b94d86
2022-08-31 13:10:18 +00:00
Ed Sanders 0345688a4f build: Update devDependencies
Change-Id: Id4d2eaaa8a5faa567e7f978eb21921b9644c7500
2022-03-20 15:05:03 +00:00
Ori Livneh a4273571da Update Pygments to 2.11.2
New lexers: BDD, Elpi, LilyPond, Maxima, Rita, Savi, Sed, Sophia, Spice, .SRCINFO.

Full upstream changelogs:

* https://github.com/pygments/pygments/releases/tag/2.11.0
* https://github.com/pygments/pygments/releases/tag/2.11.1
* https://github.com/pygments/pygments/releases/tag/2.11.2

Bug: T298399
Change-Id: I1177cb8a5c697852856b676c857939e73acb3f6c
2022-01-17 23:51:19 +00:00
Ed Sanders e2a95de1ce Move var delcarations inline
Change-Id: I4546e0bd18845fa21b7aaca2b50d11e16e637229
2021-10-07 14:34:55 +01:00
Timo Tijhof 7d9c268ffd pygments.linenumbers: Avoid deep jQuery loops on unrelated interactions
Follows-up 42c97fa (I82ed4ade), 63c5943a9 (Ic71346196).

This commit makes no functional changes, but it reduces overhead
from the SyntaxHighlight code when interacting with other features,
such as elaborate modals or other hashchange-heavy code paths that
a gadget might produce.

It uses vanilla DOM instead of jQuery where possible, and adds an
early return rather than fairly deep continuation no-ops.

Change-Id: I2264f6f398193802f05c738bad4c294da007fb27
2021-02-19 03:43:24 +00:00
Prod c9892df300 Update pygments to 2.8.0
Changes:
  <https://github.com/pygments/pygments/blob/2.8.0/CHANGES#L10-L150>

The 2.8.0 release contains fixes to existing lexers, as well as the
following new lexers:
  amdgpu, cddl, futhark, graphviz/dot, markdown

Bug: T274741
Change-Id: I84c32591a06aac5e1afe46dab1f80bb53d981bb3
2021-02-18 16:12:33 +00:00
jenkins-bot fc0ded34e1 Merge "Avoid console warning when hash is empty" 2021-01-25 22:54:36 +00:00
Ed Sanders 42c97fa448 Avoid console warning when hash is empty
Bug: T272844
Change-Id: I82ed4ade24ed9e61e654cc7ea1ce19c7607086e1
2021-01-25 22:30:48 +00:00
Ed Sanders 173491fa6f VE: Fix highlight of block syntax next to floats
Bug: T272864
Change-Id: Ifb8a36bb0f7fee93711c07ebc4efa8c0da244469
2021-01-25 15:13:31 +00: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
jenkins-bot 4df77c1138 Merge "De-emphasise line numbers" 2021-01-14 17:40:36 +00:00
Ed Sanders 63c5943a9f Don't try to highlight elements not in a code block
The 'hll' CSS only targets the .linenos selector, but it doesn't
hurt to avoid unnecessary DOM changes.

Change-Id: Ic7134619606c6e4abc2480ddc9650d0352fc33da
2021-01-13 20:47:41 +00:00
Ed Sanders 8f09ace86b Don't throw an error when location.hash in unparseable
Bug: T271572
Change-Id: I50e5593272c0039c32019e5fdcb2c79465229cf0
2021-01-13 20:39:10 +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
Ori Livneh d2e9809554 Update pygments to 2.7.2
Changes:
  <https://github.com/pygments/pygments/blob/2.7.2/CHANGES#L15-L158>

The 2.7.2 release contains fixes to existing lexers, as well as the
following new lexers:

  arrow, bare, devicetree, dmesg, dts, execline, fstar, gd, gdscript,
  ipython, ipython2, ipython3, ipythonconsole, kmsg, llvm-mir,
  llvm-mir-body, miniscript, mosel, ms, peg, pointless, promql, psysh,
  raku, reason, reasonml, ride, sieve, singularity, tid, tnt, usd, usda,
  webidl, and yang

To verify the integrity of the pygmentize binary, you can run
'create_pygmentize_bundle' and verify that the same pygmentize file is
created.

Change-Id: I0be3c1c204237b4a8873063e282be7ab8655be9d
2020-11-23 22:16:20 +00:00
Derk-Jan Hartman 0c4e7b21ac Syntaxhighlight: avoid double background
Bug: T126010
Bug: T237190
Change-Id: Ia7adb168aa5fbd006a524e91bcb85cd6fbe5a1da
2020-02-09 20:18:50 +01:00