Commit graph

54 commits

Author SHA1 Message Date
Kunal Mehta 9bdf728fc1 Move default CSS/JS model mapping out of extension.json
These are for MediaWiki core models, so it seems reasonable to specify
them in the PHP source.

Change-Id: Iab6f9969d2bf72122b2661e139aa21a3475a92a8
2021-02-10 23:54:21 -08:00
libraryupgrader c7600c3f40 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 34.0.0 → 35.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.18.1

Additional changes:
* Added the "composer phan" command to conveniently run phan.

Change-Id: Ie7649408030682fccc0c0f0251359246bc06a986
2021-01-30 14:48:22 +00:00
Ed Sanders 16af4f3c6b Register VE module unconditionally
Change-Id: Ifccc0223c2b57c0de6f6c14355850213b090f8fb
2021-01-03 00:25:21 +00: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 62cd4384ba Convert pygments.wrapper.css to LESS
Change-Id: I3b221a146528cfc328666da40f99f3132d0ac700
2020-12-30 15:31:33 +00:00
jenkins-bot 3bc07c4dfa Merge "Pass associative array to Sanitizer::validateAttributes" 2020-06-12 02:44:29 +00:00
C. Scott Ananian c281e5f423 Pass associative array to Sanitizer::validateAttributes
Bug: T255049
Change-Id: I68f122d5a3fa06b0434863cff73851a39dd10514
2020-06-10 14:01:21 -04:00
Reedy 7b266265a8 Move SyntaxHighlightModels from config to attributes
Change-Id: I6b98dbde365125cc2a5d336865080f67941403db
2020-05-12 19:27:56 +01:00
Reedy 3023aa4e2e Convert to manifest_version 2
Bug: T252470
Change-Id: I37b01df452d625e7c739726217f1e72c0b093d64
2020-05-12 02:39:12 +00:00
Reedy 16243d424f Also remove GeSHi class
I think two years is more than long enough for this one too

Change-Id: I6dd34c3fd60d6ade0206bc3d62759d87359c0b7a
2020-04-19 00:52:50 +01:00
Reedy 2d2119801a Kill SyntaxHighlight_GeSHi alias
I think 3 years is more than long enough

Change-Id: I03563e45be48f03622cbeda09a20b2f6ffe2b998
2020-04-19 00:48:44 +01:00
DannyS712 f5b61126da Add tracking categories when deprecated syntax is used
When the `enclose` attribute is used `syntaxhighlight-enclose-category`
is added, and when a <source> tag is used, the
`syntaxhighlight-source-category` is used.

Parser tests verify the tracking category is added when appropriate.

Bug: T241636
Bug: T237267
Change-Id: I7a21c635de426ab024703c04acdc6fa2184daedb
2020-04-09 19:18:32 +00:00
Kunal Mehta b5a904e2ec Require the ability to shell out in extension.json
This extension is useless if you can't shell out to pygments.

Depends-On: Iff8512530b08ef509e7ac0b6ed8fe9578ef3e2a1
Change-Id: I3ea7d82ab44516f5e202b6e6b86c1d7ec9a3b642
2019-04-13 19:25:33 +00:00
Kunal Mehta 27b6687848 Use wfMakeStaticArrayFile()
wfMakeStaticArrayFile() expects an associative array, so let's take this
opportunity to turn the lexer list into one with true as the value. This
allows us to use isset() instead of the slower in_array() when checking
to see if a lexer is known.

Bug: T200626
Change-Id: I7a852ddbcfa7c8ed19ac933205cabd176b20d0cb
2018-07-28 21:29:57 -07:00
Jayprakash12345 a79bf7638c Update extensions to take advantage of parser test autodiscovery
Bug: T170037
Change-Id: I99e68197bbe0438c7a5a55815e8000f4deb49234
2018-04-13 15:25:52 +00:00
Kunal Mehta 141455aa33 Move classes into includes/
Change-Id: Ie26b5be1bb2551ed339fdb4a587a89823c609b2e
2018-02-15 14:29:07 -08:00
Kunal Mehta dcd54e6c09 Remove unused back-compat ResourceLoaderGeSHiVisualEditorModule alias
This isn't used by anything.

And use ::class syntax while we're at it.

Change-Id: I5cb0b9f36903636825080026d9bc18e5a7f7379e
2018-02-15 14:17:39 -08:00
zoranzoki21 0d1acc53b6 Removed deprecated position statements from resource loader module
Bug: T184257
Change-Id: Icca050498f0be381b8bc142e38462ac74455c336
2018-02-03 16:34:16 +01:00
Jayprakash12345 d81620b94f Use SPDX 3.0 license identifier
Bug: T183858
Change-Id: Ic53ab079fdc36dc4497e930283ad93b586ef7b6f
2018-01-29 05:54:24 +00:00
Kunal Mehta 15b894bdbc Drop symfony/process dependency, use Shell\Command instead
We originally started using symfony/process because kzykhys/pygments
depended upon it. But that library was unmaintained and became broken,
so we stopped using it, and just used symfony/process directly.

At the time, the main reason in favor of symfony/process was that it
could pass stdin to pygments, while Shell\Command couldn't - but it can
now (T182463)! On top of that, there are downsides, like not respecting
the default MediaWiki shell limits, being incompatible with core's
firejail support, and requiring an external composer dependency.

Note that because Shell::command() will enforce MediaWiki's normal
limits, it's possible that some large pages may no longer render with
syntax highlighting if they pass those limits.

Bug: T182467
Bug: T181771
Change-Id: Ie1cb72b7eb17d943f79ecae4d94a2110546ef039
2018-01-04 13:07:35 -08:00
Umherirrender deb5fc0fcf Rename files to match classes
Change-Id: I6e66abdf4f0eff0a24b96e543f2ce8f293bb7860
2017-12-10 01:32:49 +01:00
Kunal Mehta 987187935c Make sure $wgPygmentizePath is sane only when we need it
This avoids having an extension function, which runs on every request,
regardless of whether it uses syntax highlighting or not.

Change-Id: I890348b73af956819300cce64d0672dcdb209c19
2017-07-06 00:57:40 -07:00
Kunal Mehta 8db92c2d0c Remove RejectParserCacheValue hook for old GeSHi parser cache
SyntaxHighlight migrated to Pygments nearly 2 years ago, and was
included in the 1.26 release. By now everyone should have cleared their
parser caches, so this hook isn't useful.

Change-Id: Ia267a648ce9188232dd55c6ed3bb2c2fa65223a9
2017-05-21 16:17:18 +02:00
Derk-Jan Hartman 45e3085a59 Remove GeSHi from class and filenames
Remove the GeSHi name from filenames and classes where possible. We no
longer actually use GeSHi, and though we cannot rename the extension or
repo atm, we can rename these.

Bug: T164939
Change-Id: I02bc3304d88103c5302f203e788fc73ff20e1050
2017-05-20 14:47:23 +00:00
Derk-Jan Hartman 0fa395c72d GeSHi: Make sure the autoload of Compat doesn't load GeSHi
Bug: T139594
Change-Id: Ib8c78f6f1da9750e0429f7bcf29b8dcb5ecca8a1
2017-05-13 15:14:05 +02:00
Derk-Jan Hartman 39f0b85229 Do not extend GeSHi class with private modifications
Our GeSHi class is intended for other extensions making use of GeSHi.
However other libraries or extensions can bring their own GeSHi to the
classloader. In those cases, we cannot find our private modifications
like $compatibleLexers on this class. Instead use
SyntaxHighlightGeSHiCompat for our privact modifications and keep GeSHi
closer to the original implementation.

Bug: T139594
Change-Id: I5c2ba9dfb08ec31f6b5cfd90083cbae0ae0ac3c4
2017-05-11 18:11:25 +00:00
jenkins-bot 4a6ddadf73 Merge "Skip registering RL modules depending on VisualEditor" 2017-02-13 10:53:30 +00:00
Umherirrender 570c3be65a Fix key for requires in extension.json
Change-Id: Ic6c8422186a74e926e9b1ac28afe612474e1d0e7
2017-02-05 21:06:42 +01:00
Antoine Musso fea05d6859 Skip registering RL modules depending on VisualEditor
When VisualEditor is not installed, there is no point in registering
resource loader modules that depends on it.

A use case is trying to run tests for the MediaWiki tarball. It comes
with SyntaxHighlight_GeSHi but without VisualEditor.

The patch is based on GuidedTour patch by Matthew Flaschen
https://gerrit.wikimedia.org/r/#/c/305691/ for T143297
A similar one has been done for Cite:
https://gerrit.wikimedia.org/r/#/c/316010/

Change-Id: Idf769e0149f93c099a94b1b7a6cb203273dab881
2017-01-30 14:29:38 +01:00
Derk-Jan Hartman 50075eaa66 Convert SyntaxHighlight names to Ace names
Provide a translation from Syntaxhighlight compatible Pygments and
GeSHi language names to CodeEditor compatible Ace lexer names

Now when you select php4, the CodeEditor will use the Ace lexer php,
instead of falling back to text mode.

Bug: T148515
Change-Id: Ibc209f97318614f764457726f8d55f4e15276d79
2016-10-31 14:13:36 +01:00
Kunal Mehta 03bbdd8a2e Use load_composer_autoloader
See Ib031bef17c8a7d708a5c7878e74967d19217bbc8

Change-Id: If7fff2476382853426fa61b5c878f0c6f6b9d0a8
2016-01-14 19:59:28 +00:00
Ed Sanders 0f10206cf2 Use dialog for editing block level syntax highlights
Maintain the inspector for inline snippets (which are editable
but still not creatable).

Bug: T112617
Bug: T57934
Change-Id: I76e36590363d36c0d3db4ec28ce81c4860d9b467
2015-10-20 15:16:11 +01:00
Ed Sanders 359c060eb7 Rename modules/VisualEditor to modules/ve-syntaxhighlight
Per new naming convention.

Change-Id: I0db6f70c2d7671eb9c25a6ff7eecf46eafb696d2
2015-09-18 12:14:39 +01:00
Alex Monk 0a59b4ccb1 VE integration: Provide a combobox for language input
Bug: T103756
Change-Id: Ic84c5afb1cf83cce6fa521a99f5fee242bc610b1
2015-08-27 03:24:07 +01:00
Ed Sanders d38d9c1994 Add VisualEditor support for 'line' attribute
The line attribute sets line='1', as both Parsoid and VE
expect proper XML attributes.

Change-Id: I10b5717fcc4b8e84a3030425a4a6a9a865272830
2015-07-06 22:09:23 +01:00
Ori Livneh f41f26a85c Add a tracking category on pages that contain invalid <syntaxhighlight> attributes
Do this by having SyntaxHighlight_GeSHi::highlight() return a Status object
rather than a plain string, and by making it the highlight method's job to look
up a lexer for a language.  The actual warning text is not outputted anywhere
yet; deferring that for a follow-up patch.

Bug: T103586
Change-Id: Id839f925a56ab09a8423958327b9aefd7207ef37
2015-07-02 23:14:34 -07:00
Ori Livneh 927f40e98a Hide the red border around syntax errors
MZMcBride noticed the red border around '國' in
https://en.wikipedia.org/wiki/Swift_(programming_language)#Example_code

That particular case happens to be a Pygments bug, because multibyte characters
are valid variable names in Swift. But even in cases of legitimate syntax
errors, I don't think we want to show the red border. This behavior may be
useful in code editors, but it is not useful in a wiki environment, especially
given the longstanding habit of using an existing, mostly-compatible lexer to
highlight a language for which no specific lexer exists.

To fix this, override the style in pygments.wrapper.css, and swap the order in
which the two CSS files are concatenated, so that in general we have the
ability to override Pygments-generated CSS.

Change-Id: I304fdaf3a462445d316e0f7fecc983fa87afc629
2015-06-25 17:24:15 -07:00
Bartosz Dziewoński ca778d0a99 Revert "Remove obsolete mw-highlighter styles"
The 'direction' rules must not be applied to regular preformatted
text in MediaWiki core, only to syntax-highlighted programming
language code.

(Not reverting the part that removes 'monospace' rule, *that* is
superfluous.)

This reverts commit f834b719b9.

Bug: T103780
Change-Id: Ie7e9123ab3456aa6fff0485431fe81cd5eb31fa2
2015-06-25 13:05:19 +02:00
Timo Tijhof f834b719b9 Remove obsolete mw-highlighter styles
The styles in MediaWiki core for <pre> already cover this. And
for skins that want different styles, SyntaxHighlight should not
have been overriding it.

Bug: T103780
Change-Id: Ib863288a9a4530b183cf5fdb692489363d82a50f
2015-06-25 05:43:24 +01:00
Legoktm f1c6b66bac Revert "Add Pyglet, a web micro-service for highlighting using Pygments"
Doesn't work, shouldn't have been self-merged either.

This reverts commit 7e4efbe114.

Change-Id: I52b200d3fb0fea101317740e4ce63a7b71015303
2015-06-25 01:11:54 +00:00
Ori Livneh 7e4efbe114 Add Pyglet, a web micro-service for highlighting using Pygments
Pyglet is an internal web service that listens on port 31337 by default and
which accepts syntax highlighting request via POST. If $wgPygletURL is set to a
URL of a Pyglet instance, the extension will attempt to query the web service
instead of shelling out.

Change-Id: Ic49f4cd77585dbffc5392e80904754ff889b8a63
2015-06-24 17:57:50 -07:00
Timo Tijhof 6ba411fe2f Merge ext.geshi.data and ext.geshi.visualeditor modules
Until and unless there is an explicit need (and intent to support)
a public interface to use this data elsewhere, there is no need
for it to be a separate module.

It can be its own class, but at the resource level this data should
be considered a JavaScript file. And we don't create separate modules
for each file. They are in the same module unless they should be
semantically loaded in unrelated page contexts.

The module registery is not a javascript class autoloader. There
is a global cost to adding more modules to this registry.

Change-Id: Ifeddef8cfe00b6c115734f92eceab251a0b75bdb
2015-06-25 00:32:03 +00:00
Ed Sanders b403b58682 Add VisualEditor support
Most functionality is provided by MWExtensionNode & MWLiveExtensionInspector.

Bug: T45126
Bug: T60388
Bug: T69515
Change-Id: If502a8bd2199b6ceb824e02fdfd13c81c39b53b4
2015-06-24 22:43:42 +01:00
Kunal Mehta 01802ac3fb Use RejectParserCacheValue hook to invalidate caches that were using GeSHi
Change-Id: I47de88dc1c2f2380e41e6af0d3222b46c9c65569
2015-06-23 21:26:44 +00:00
jenkins-bot 9f5eade94c Merge "Add basic parser tests for functionality of non-recognized languages" 2015-06-23 15:29:31 +00:00
Derk-Jan Hartman d272c1e0e2 Enable syntaxhighlighting on mobile target
Now that we switched to pygments, there should be mo reason not to
enable this on mobile

Bug: T100563
Change-Id: I008b71d4cef04fb7dc7c2ad574032f9c4645b063
2015-06-23 13:17:03 +02:00
Kunal Mehta fb0e430f47 Add basic parser tests for functionality of non-recognized languages
Change-Id: I07cecb588818fd4abb0b1b8e8de893cf6f72014a
2015-06-22 22:26:22 -07:00
Ori Livneh 648744325c Bundle Pygments 2.0.2
Include Pygments 2.0.2 as an executable zip bundle. Also include a script to
automate the process of creating such bundles and to make it reproducible and
verifiable.

Change-Id: I67e6f804e493f065311164c610dc541a5779654e
2015-06-22 22:54:42 +00:00
Ori Livneh 6484894497 Highlight using Pygments rather than Geshi
GeSHi is unmaintained, lacks support for many popular modern languages, and
suffers from deep architectural flaws, chief among them the inconsistent
tokenization of different languages, each of which requires a custom
stylesheet.

Pygments is a well-maintained alternative. It is, by my count, the most popular
syntax highlighting library around. It is BSD-licensed, actively maintained,
and is widely used in PHP projects.

To keep this easy to review, this change does not include update for l10n
files, and it does not delete the geshi/ directory. I will do those in a
separate patch.

The chief change between this and the previous implementation is that errors
result in the code block not being highlighted, as opposed to not being printed
at all, having been replaced by an angry red error message. I think that is the
right user experience. If you go to StackOverflow or GitHub and try to mark up
your code block as being written in some language that their highlighter
doesn't know about, you don't get an error message -- the code simply doesn't
get highlighted.

Because we don't recursively load dependencies for extensions, to test this,
you will need to create a composer.local.json in $IP and add:

    {
        "extra": {
            "merge-plugin": {
                "include": [
                    "extensions/SyntaxHighlight_GeSHi/composer.json"
                ]
            }
        }
    }

Then run `composer update`.

Bug: T85794
Change-Id: I07446ec9893fae3d1e394f435d3d95cf8be6bc33
2015-06-22 23:37:15 +01:00
Gilles Dubuc 58c81408f5 Explicitly define module position
Style modules currently added through addModuleStyles default
to being in the head ("top" position). This is an unhealthy default,
since only critical styles that are needed at pageload should be
in the head. In order to be able to switch the default to "bottom",
existing module positions have to be defined explicitly.

Bug: T97410
Change-Id: Ie120a781ac1950abd7963d6f722aa316b5542b51
2015-05-29 15:28:06 +00:00