Commit graph

103 commits

Author SHA1 Message Date
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
Ed Sanders c09c3ed190 Use language as node description
No point using body as that is already visible.

Change-Id: I3425ae4712ccc820ba736ee605524abbc35aecc4
2019-07-31 16:41:15 +01:00
Ed Sanders 6f1c7c88e5 VE: Add read-only support
Change-Id: Ib39d6247385affed7ef46316903db97795407f32
2019-04-16 12:13:18 +01:00
Ed Sanders 8d1c397b63 Update eslint-config-wikimedia to 0.9.0
Change-Id: Ifded26af687dd409b01554df68e83c32a6844317
2018-11-27 21:59:16 +00:00
Ed Sanders c546bf5348 Replace jQuery.map with Array.map
Change-Id: I4bc7e347fe12038bdcadd62a023b6e0041d105c0
2018-10-31 12:51:24 +00:00
Ed Sanders b485d4c6fa Remove unused window.static.icon
Change-Id: I0d79af60052554a5a6c3f79139688d14e5351ab4
2018-10-31 12:51:02 +00:00
Ed Sanders e25603a1b6 Follow-up I3daca6fb: Fix exception thrown when inserting new code block
Change-Id: Ie5f93ace8a81c5053dbadb99dd447b37d2d07316
2018-10-31 12:45:50 +00:00
Bjornskjald ad372167bc Make VE language checking case-insensitive
Bug: T125231
Change-Id: I3daca6fbfce1c2fe4bd901b8912089aa820fb022
2018-10-24 18:01:46 +00:00
Thalia dbd6afcfab Update syntax highlight dialog actions consistently
Require that the node is modified and the language input is
valid before enabling the "done" action. Otherwise disable it.

Bug: T206481
Change-Id: Ie9d2907358ea585ba72628887c46af69f942772f
2018-10-09 12:19:38 +01:00
Thalia 118dcdb405 Separate node classes into individual files
Bug: T205231
Change-Id: Id175f839f0ac8714c44407c52145d4140cd8e343
2018-09-24 18:48:22 +01:00
Ed Sanders af1a91ade9 Use OOUI 'markup' icon instead of VE's deprecated 'alienextension'
Change-Id: Iad1882c20c17792c1339cf9922b9c4c43bf6122b
2018-03-20 19:00:41 +00:00
Ed Sanders b5eb22bf04 Document monospace hack
Change-Id: Ia27dccdb9dc2de6ca66e08c54c62eb91302a381c
2018-01-11 14:45:39 +01:00
Eddie Greiner-Petter 3abd668325 Add new (unprefixed) CSS modifier user-select
The CSS already has this modifier prefixed with -webkit-, -ms- and
-moz-, some browsers now support this without any prefix (according to
caniuse.com: Chrome 54+, Opera 41+).

Change-Id: Icd67250c26bec61be0fb101f1db077ee13ccf6b7
2017-11-07 19:36:32 +01:00
David Lynch 17c5301995 ce.MWSyntaxHighlightNode: Always generate node contents
Don't bother checking supported languages before generating the node contents.
We always want the preview, as that's what will display on the rendered page
even if the language is invalid.

Bug: T164120
Change-Id: I8344449bbf9c9cce131d745ea5f4e54b96fe57b1
2017-07-17 11:37:05 -05:00
Ed Sanders 7239e4439c Remove redundant multiline option
MWAceEditorWidget is now multiline by inheritance

Bug: T170275
Change-Id: Ie9d8f200b95497bbe91396ea92e29b0d317f010a
2017-07-12 16:28:34 +01:00
Bartosz Dziewoński 8a186b5822 ve.ui.MWSyntaxHighlightWindow: Set $overlay for the ComboBoxInputWidget
* Allows the dropdown menu to extend outside of the dialog.
* Avoid z-index conflicts with Ace scrollbars (T170027).

Bug: T170027
Change-Id: I52d2d06b56391f30be07c71a86d71d9ab50f0a8c
2017-07-11 00:15:38 +02:00
Ed Sanders 28b480ca0a Pass dataElement type to parent's toDataElement
Ensures the rendering is cached with the correct hash.

Bug: T151130
Depends-On: I80e2f2587cff8e9d9fe6ded5d8581263268deaa8
Change-Id: I64466cc342f7ab7f9d4539f935688d167853a662
2017-05-19 16:06:44 +02:00
Ed Sanders f53d8c2e6e VE: Support editing start line parameter
Change-Id: I869ac413f4d7581026353e2d54f9d22c6b6290f5
2017-05-15 09:49:42 +01:00
Derk-Jan Hartman 9638ee20c3 Avoid background when the content is narrow
All our highlight content is inside a <pre> block. When this block is
more narrow that the page (due to being pushed aside by floating
context for instance), then the background of this parent element will
extend beyond the contents.

An alternative could be setting overflow:hidden; and then setting
margin:0 on the included <pre> element (which has UA default margins)

Bug: T126010
Change-Id: Id3c9544ea8fa379c7c640afa692d6184ad9c550f
2017-04-27 18:38:55 +02:00
Kunal Mehta db681d158b Update pygments to 2.2
Notable changes:

* Added new token types and lexing for magic methods and variables in
  Python and PHP.
* Added a new token type for heredoc (and similar) string delimiters and
  lexing for them in C++, Perl, PHP, Postgresql and Ruby lexers.
* Improved the CSS lexer.
* Added Varnish config lexer

Full changelog is found at:
<bc45808f83/CHANGES>

Bug: T156573
Change-Id: I4dc1782f19881ba1294308e1cdea1b2e063f438a
2017-04-27 15:10:16 +02:00
Ed Sanders d150ddea1c build: Replace jshint/jscs with eslint
Change-Id: I503a57bed2ee6bb648697d6245af0b0286b5f3ec
2016-11-19 13:56:05 +00:00
Ed Sanders 37711ca15c VE: Fix combobox API and other issues
* Combobox is now an input widget so doesn't need .input
* Replace isValid with getValidity.
* Remove 'Show line numbers' from inline mode, as it has
  no effect.
* Remove no-longer required z-index hack.

Bug: T150555
Change-Id: I3c4ac3cb6b174348cc3582469a86fb1a23ca7c51
2016-11-15 17:22:54 +00:00