Commit graph

79 commits

Author SHA1 Message Date
Thiemo Kreuz f1cf1a534c Fix performance bottleneck in mediawiki syntax highlighter
I continued profiling the matchbrackets addon for T270237 and run into
performance issues that turned out to be unrelated to the addon. The
flame graph highlighted a "match" function. Note this is not the
String.match() from JavaScript, but something in the CodeMirror lib:

StringStream.prototype.match = function (pattern) {
  var match = this.string.match(pattern);
  if (match && match.index > 0) {
    return null;
  }
  return match;
}

(Note: I simplified this code so we can focus on the bug.)

When the pattern is a regular expression, it's executed via
JavaScript's String.match(). The function then checks if there was a
match and if it's at the start of the string. If not, it's not a
match and doesn't return one.

In other words: Even if there is a match somewhere in the string, the
function acts as if there was no match.

When we change all patterns to be anchored via ^, they don't scan the
entire string any more but return much ealier when there is no match
at the start of the string. We are effectively replacing nested loops
(hidden in the patterns) with single calls.

This bug exists since 2014.

The disabled line in the matchbrackets addon is just dead code. I
don't remove it to document the fact that we disabled it.

Bug: T270237
Bug: T270317
Change-Id: Icbb1122e6a3b26c0606726ff405e108931d185be
2021-01-13 16:58:57 +01:00
Thiemo Kreuz 4a3c2dcad5 Update CodeMirror to 5.58.3
I had to make some CSS selectors more specific, because the
library changed

 .CodeMirror pre

to

 .CodeMirror pre.CodeMirror-line,
 .CodeMirror pre.CodeMirror-line-like

This is only relevant for entire lines (implemented as <pre>
elements). Most of the custom CSS is for characters, not lines.

In my tests in the Wikitext editor as well as VisualEditor I
could not spot any difference between the old and new version.

Bug: T258999
Change-Id: I6f0f030f972838727f3ef220feb105264f122798
2020-12-07 20:20:49 +00:00
Thiemo Kreuz 3e9bb4fb08 Replace all .png images with rgba() background colors
The rgba() syntax is supported for a very, very long time now:
https://caniuse.com/#feat=mdn-css_types_color_alpha

Notes:

I realized the numbers in these file names are actually their
transparency in percent (more precisely their opaqueness).
4 is 4% which translates to 0.04 in the rgba() syntax.

I used Gimp to pick the opaque color values from the images.
Gimp makes this easy. No guesswork or calculations needed.

For multiple, stacked images I calculated the colors by
averaging their RGB values (considering how opaque each color
is). Note this is actually *more* precise than the stacked
images before. Stacking alpha colors is flawed. For example:
Let's say we have an rgba(255, 255, 255, 1) background.
Layering a half transparent rgba(255, 0, 0, 0.5) on top means
half the background shines through. This averages to
rgba( 255, 127, 127, 1). Now we stack rgba(0, 0, 0, 0.5) on
top. Again, half the background shines through, resulting in
rgba(127, 63, 63, 1).

When we apply the two colors the other way around, the result
is rgba(191, 63, 63, 1), a much brighter red.

This flaw doesn't happen when precalculating the averages, as
done in this patch.

Change-Id: I29026864714c5f90c2613af57f08693e7e2b996c
2020-08-11 14:24:20 +02:00
Ed Sanders 2518861bc1 build: Update devDependencies
Change-Id: I2f2967a1525c6a66eba2f5fc225e74b89380c5dd
2020-06-12 22:51:38 +01:00
Derk-Jan Hartman d1a3e49265 Highlight match end tag with different capitalization
This recoginizes <ref></Ref>

Bug: T179321
Change-Id: Ib1e501f97654a019281eddd6cc69ea3b979daec7
2019-04-14 01:25:40 +02:00
jenkins-bot 71a96af684 Merge "Make Special:JavaScriptTest pass on Webkit and on Firefox" 2019-03-12 10:32:28 +00:00
jenkins-bot f6c86b9867 Merge "build: Update eslint-config-wikimedia to 0.11.0" 2019-03-06 14:39:37 +00:00
Ed Sanders 37b49bfdc4 build: Update eslint-config-wikimedia to 0.11.0
Change-Id: I7ca5276791d9add0709387422016d7193e8d9945
2019-03-06 12:10:29 +00:00
Fomafix ebd382f004 Make Special:JavaScriptTest pass on Webkit and on Firefox
CodeMirror inserts

 style="padding-right: 0.1px;"

only on Webkit.

The test case now strips this pattern from the rendered HTML before
comparing with the expected test case output.

Change-Id: I34b201f790d3d85a5f51d8200bf8219f11d14506
2019-02-25 08:14:58 +01:00
Fomafix 5161c6abe9 Make Special:JavaScriptTest pass with and without extension Cite
Change-Id: Ib3bae7968c7d1eb0d5f862f0410f016f47abcd15
2019-02-25 08:10:32 +01:00
Ed Sanders 7604581cc1 Remove obsolete aliases from closures
Bug: T208951
Change-Id: I64c2966b7c41d6b2b1911e2fb52e4c7364bf7964
2018-11-12 13:19:41 +00:00
Ed Sanders 1be09a9a1d build: Update linters
Change-Id: I8d3aaf0b7d453033b72e5d6622b8f54df2c86bca
2018-09-12 00:03:19 +01:00
MusikAnimal 4d2783eb3e Tests for MediaWiki CodeMirror syntax highlighting
Bug: T169592
Change-Id: I0750d3a320af5451f847e6062f82523fb18f12bc
2018-03-20 16:27:55 -04:00
jenkins-bot 0e4bb8feb6 Merge "Don't match // as protocol unless used in a link" 2018-03-15 23:51:21 +00:00
MusikAnimal 5c8eb20c33 Don't match // as protocol unless used in a link
Bug: https://phabricator.wikimedia.org/T185069
Change-Id: I2111e7c7ae599c5aed2f5ae779bc3d7b2d8ce82a
2018-03-13 22:51:35 -04:00
MusikAnimal ccbce0e69d Highlight void tags and invalid self-closing tags correctly
Bug: T170238
Change-Id: Ice1bdae3d16cf365da14c6df0e8d91d2b914e074
2018-03-13 22:18:59 -04:00
jenkins-bot b7a201e2f0 Merge "Fix highlighting of table headers on single text row" 2018-03-13 22:39:01 +00:00
MusikAnimal 62a53c5905 Fix highlighting of table headers on single text row
Bug: https://phabricator.wikimedia.org/T179534
Change-Id: I6e353d52af849678da63624e456ec2a82c680df4
2018-03-13 18:23:16 -04:00
MusikAnimal 980f3d2848 Add <translate> as a permitted tag
Bug: T172456
Change-Id: I2315053b79bfd2dd009a98c0fe824ccdbcaf431c
2018-03-05 15:01:45 -05:00
David Sn 62894aafff Update comment text color CSS
This patch changes the comment text color
to #84A0A0, as suggested by Kaldari in T170067.

Bug: T170067
Change-Id: I016b8ce360a06f14b02cee13b629fa578c889347
2017-12-05 09:32:34 +00:00
Pavel Astakhov cd4bdebe8b Add highlighting of double underscore Magic Words as __TOC__
For testing:
__NOTOC__
___NOTOC___
____NOTOC____
_____NOTOC_____
______NO!TOC__NOTOC____
______NO{{TOC}}_____
______NO[[TOC]]_____
______NO'''TOC'''_____
__nOtOc__
FFFFF___NOtoc______
'''____________NOTOC______'''
__TOC___TOC__
__TOC____TOC__
___TOC_____TOC___
__TOC___TOC__
___NOTOC___
____NOTOC____
_____NOTOC_____
______NO!TOC__NOTOC____
______NO{{TOC}}_____
______NO[[TOC]]_____
______NO'''TOC'''_____
__nOtOc__
FFFFF___NOtoc______
{{__TOC__|__TOC__}}

Wrong, but not a big problem:
[[__TOC__|__TOC__]]

Bug: T170041
Change-Id: I0b2cfd02550c2685d241bdf3596507c5972878d5
2017-09-13 10:43:41 +06:00
Pavel Astakhov 41e83d2984 Take out gray background behind indenting bullet in syntax highlighting
Bug: T165001
Change-Id: I51576f46a8d204784755ef645bb5daf1930fe74e
2017-09-04 16:03:10 +06:00
Max Semenik 54c032d732 Fix exception on some combination of quotes
Bug: T174060
Change-Id: Ie53b7260a98519f45d38d2a705b900142c77c801
2017-08-25 16:05:55 -07:00
Reedy 5cd288b203 Don't use tab indenting between array items
Change-Id: Ifbc293c5075c6518edbefd5d7c4b6ce2cd71ace3
2017-08-21 19:53:52 +01:00
Ed Sanders 410e442fd1 build: Update eslint, stylelint
Whitespace and regex escaping fixes

Change-Id: Ic706dfd3ed7efb16db104b054091bec0ba0cb5ed
2017-07-20 15:58:31 +00:00
Kaldari 71fadf6a95 Changing color of .cm-mw-mnemonic to match color of other HTML code
This changes the green for HTML entities to a slightly lighter
shade of green to match the green of HTML tags.

Change-Id: Ice51e96b0f5fac67d88375fe76630098d380afc9
2017-07-11 10:50:20 -07:00
Niharika29 e8fa11ec94 Design fixes for Codemirror
Bug: T165178
Change-Id: If5b7c0807ff6fcdb30e1b8fe935b53ee0ca46a0d
2017-07-06 15:03:09 -07:00
Pavel Astakhov 0cdf013c73 Take out gray background behind list bullets in syntax highlighting
Bug: T165001
Change-Id: Iec64336881ee38938739cab76a3090542b1ff973
2017-05-11 12:10:15 +06:00
Pavel Astakhov c9b4aa65fd Refactor the Integration with other extensions (v 4.0.0)
This patch makes initialization easier and cheaper.

Since only the PhpTags extension uses the CodeMirrorGetAdditionalResources
  hook it was removed. Instead, the CodeMirrorPluginModules and
  CodeMirrorTagModes properties are used in extension.json file.

This patch adds ext.CodeMirror.lib.mode.php module for the PhpTags
  extension (with dependences). In CodeMirror there are a lot of modes
  they will be registered on request (if they will be requered for
  extensions).

Examples of integration:
* Cite: I1bf156fa813af4d5f891619f692047bbdb8a1a86
* PhpTags: Ie339f0475e63885e603defaee2cdcccd6a95fafc

Bug: T163238
Change-Id: Idb7a1a5769a1047ef2f7cd25a7152f73a6613225
2017-05-04 21:20:21 +01:00
Pavel Astakhov 6ce71b3667 Add additional classes cm-mw-ext-{tag name} to extensions tags
They can be used to create specific color themes (T163533)
See also bug T161694

Change-Id: I499e1e4b2e1e4fa972e28fc05a65047ecadc204c
2017-04-23 13:51:24 +06:00
Pavel Astakhov e3ca35adf5 Syntax highlighting: Switch extension tags to green
Bug: T161694
Change-Id: I1817cd151ac253998f0381126a60960106db3848
2017-04-20 23:45:11 +06:00
niharika29 2fb08d548f Swap parser function and assessment template colors
Bug: T162206
Change-Id: I2d8705a8ec44c668aebc4728cd84e0953cd497a1
2017-04-17 20:01:33 +00:00
Pavel Astakhov 6be1fbc134 Add some extra spacing around H1s and H2s
Bug: T161559
Change-Id: I0d10d39313c11fddefadff7ab13c262bd6606ed0
2017-04-05 11:18:12 +06:00
Ed Sanders 02c22f53ff Styling fixes
* Move CSS out of mediawiki.css which is for wikitext
  highlighting rules.
* Account for wikieditor-ui adding wrappers even when
  disabled.

Change-Id: I0fca693a6771ee1d790800c9afd5c7091fda20c1
2017-03-27 14:02:25 +01:00
Ed Sanders 806527d8a1 Switching fixes
* Fix state toggle in WikiEditor
* Update options API code
* Fix font-size and line-height so text doesn't move
* Append to WikiEditor after loading so it appends in
  correct part of DOM.
* Only add border in classic editor

Change-Id: I5e80298030633d4859d01a92b6c61ef1fa969e96
2017-03-22 11:48:41 +00:00
Ed Sanders 66ba217ba2 build: Replace jshint/jscs with eslint, introduce stylelint
Change-Id: I9b5afb39f5a0d32e722b2a1f56c219b8c85b451c
2017-03-21 16:45:56 +00:00
Pavel Astakhov 339e677bee Remove usage of mod function
Change-Id: Id84d85318ef498b4aa8fcbe073b8bc8a8c8c7ed7
2016-07-19 16:31:35 +06:00
Paladox 45ebd2d55d Update Jenkins tests
Test jshint and jscs through npm using latest version of jscs and jshint.

Add support for composer.json running phplint and in the future php code
sniffer.

Change-Id: Id8f11f9414fae8313dc18a857a07e11694354dcb
2016-03-03 13:29:48 +00:00
Ori Livneh a97494e94e Compress PNGs with zopflipng
Zopfli is the most efficient DEFLATE compression algorithm, trading run-time
performance for file sizes that are typically 3-8% smaller than those produced
by zlib with the maximum compression setting. Its output is Deflate-compatible,
so no specialized decoder is needed.

This change was created by running zopflipng against all the PNG files in this
repository. The exact invocation was:

  git ls-files --exclude-per-directory=.gitignore -- '*.png' \|
    parallel zopflipng -m -y --iterations=500 --filters=01234mepb {} {} \;

Files which zopflipng was not able to compress more efficiently were left unmodified.

Bug: T127608
Change-Id: Iec319a37c5884798afa58145a30d496bb1c9d57b
2016-02-20 22:57:24 +00:00
Pavel Astakhov 991be29500 fix highlighting parameters inside a template transclusion (v 3.2.1)
Bug: T108450
Change-Id: Ic686fe6aa211988d8458037c275779f512d03563
2015-08-20 10:32:11 +06:00
Pavel Astakhov 9acce89672 fix bold and italic apostrophes (v 3.2)
Bug: T108455
Change-Id: Ie9e0d734004d062e4c347f7940eb34bdc231d026
2015-08-19 21:10:31 +06:00
Pavel Astakhov 66b518d8dd fix highlighting of external links, multiple apostrophes end link (3.1.14)
Change-Id: Ibbb4850edc04ed6b184fa59c51e1978d60cd1269
2015-08-14 13:22:47 +06:00
Pavel Astakhov 491f186e14 fix matching hr ---- (v 3.1.13)
Change-Id: I7ea6fa891d2c53da4ac9bd62319dad702a11b8d7
2015-08-14 12:03:41 +06:00
Pavel Astakhov 443ccff873 fix function eatFreeExternalLink (v 3.1.10)
allow one '{' in free external link

Change-Id: Ieaa157b79cff9d05d8bed3ae536cfe45e7e4ae42
2015-08-10 23:30:05 +06:00
Pavel Astakhov 00f668e32c add highlighting of free external links (v 3.1.9)
Bug: T108448
Change-Id: I1311be98e346b9d85350eeb9a6dffaf08f344d56
2015-08-10 23:14:18 +06:00
Pavel Astakhov 545d21ce61 add highlighting of indented tables (v 3.1.8)
Bug: T108454
Change-Id: Ib5344fa870954da166314c8ace916861bd71acf9
2015-08-10 13:48:48 +06:00
Pavel Astakhov 27a7499906 skip leading spaces in table syntax (v 3.1.7)
Bug: T108453
Change-Id: I348855b9ae8a4f571bb765df2b0819ebe3fda75d
2015-08-10 11:07:55 +06:00
Pavel Astakhov 19bced27dc add highlighting of table caption (v 3.1.6)
Bug: T108452
Change-Id: I543db4c26c1a0ed7314ae826ddd2876de7539bf2
2015-08-10 10:34:11 +06:00
Florian Schmidt 3253edba8b Rework extensions setup (v 3.1.0)
* Cleanup the init process of this extension (PHP & JS setup)
* Make it useable for other extensions like MobileFrontend.
* Call new hook CodeMirrorGetAdditionalResources instead of CodeMirrorGetExtensionMode

Bug: T91796
Change-Id: I9763c40835c2edddafb0dcbacdf53a86f663b8cd
2015-03-16 16:45:18 +01:00
Pavel Astakhov ae450a5c3c refactor and extend usability (v 3.0.0)
* add on/off button to toolbar
* add highlighting table, hr ----, sign ~~~
* update codemirror lib to 4.7
* fix font size

Change-Id: Idd5775d6c80a18406aee7b8ab51691f26038764c
2014-10-23 12:09:10 +06:00