Commit graph

62 commits

Author SHA1 Message Date
James D. Forrester d1addca20d build: Update MediaWiki requirement to 1.39.0
Change-Id: I20feff254dfd5438818b9428a4afdd7994e8d435
2023-03-14 18:02:01 +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
Subramanya Sastry 0eef7add67 Add Parsoid support for syntaxhighlight
* Added Parsoid config, and refactored code slightly to
  add native Parsoid handlers for parser tags exposed
  by this extension.
* Enabled parsoid mode testing on the test file.
* Added html/parsoid sections on a few tests.
* Marked rest of tests as wt2html and wt2wt only since
  html2wt and html2html will fail without a html/parsoid section
  and there is no real benefit to adding them to all tests.
* Added a couple tests to the known failures list:
  - One is because of T299103.
  - The other is because Parsoid always emits attributes in the
    form <tag .. foo="bar"..> instead of just <tag ... foo ..>
    Since Parsoid needs to accept this format that is present on
    wikis, I added a html/parsoid section for this test and
    added the failures to the known failures list.

Bug: T272939
Change-Id: Ie30aa6b082d4fc43c73296ff2ed6cb8c3873f48f
2022-08-08 20:07:46 -04:00
Reedy 39b4f0c7c1 Namespace rest of the extension
Global alias of SyntaxHighlight left behind for migration

Change-Id: I35b2caa42ac91454abe359949e360d1601748121
2022-03-18 01:42:11 +00:00
jenkins-bot 5274a69824 Merge "Bump required MediaWiki version to 1.36" 2021-10-05 14:54:57 +00:00
Func 81e24e26df Bump required MediaWiki version to 1.36
After change I2e82e5aa, this extension no longer supports 1.35
and earlier.

Change-Id: I51c318f77a03f0f72611f039e139b4869b80f8ba
2021-10-05 14:51:20 +00:00
Kunal Mehta af6654e5f9 Port to BoxedCommand
All of the interactions with `pygmentize` have been refactored into a
new class, conviently called Pygmentize. It is responsible for getting

* pygments version (cached in APCu for 1 hour)
* generated CSS (cached in WAN by version for 1 week)
* lexer list (cached in APCu by version for 1 day)

and actually highlighting stuff! Most code paths differentiate whether
we're using a bundled version of pygments or one that has been
explicitly configured. If using the bundled one, we take shortcuts since
we already know the lexer list, have the CSS generated, etc.

ResourceLoaderPygmentsModule is added to switch between loading
generated CSS from the bundled file or Shellboxing out to get it from
pygments.

Bug: T289227
Change-Id: I2e82e5aa2a71604b87ffb4936204201d06678341
2021-09-10 11:47:28 -07:00
Kunal Mehta b8a5dd08ee Expose Pygments version on Special:Version
Change-Id: Ia4eccc4f16873b16e106c8196d7582ca5b27b365
2021-09-10 11:47:28 -07:00
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