Commit graph

63 commits

Author SHA1 Message Date
Reedy 13dfba4f9a Rename hook subscriber
Swap global function for closure

Change-Id: I41a17461546ac76e223db1c2dc5b2be1ff093af8
2014-06-16 00:20:08 +00:00
Bartosz Dziewoński 44177a6b13 Make sure font size in GeSHi output is not too small
Follow-up to I7bbdcc0a, see it for details.

Also cleared up the comment describing this here.

Bug: 26204
Change-Id: I103a6d5c3e1f91cf74e244756c2ad318e429a78e
2014-05-06 01:50:04 +02:00
Bartosz Dziewoński 79b37aa109 Remove unused backwards-compatibility code
Change-Id: Iffa42d7579d882cd119851a075b6e63f670c02bc
2014-05-05 12:32:56 +02:00
Bartosz Dziewoński b6d8b1a5b9 Use ResourceLoader modules for style loading
We want to be able to track what styles were added to be able to deliver
this information to MediaWiki's live preview functionality (in order
to solve bug 24134).

This required moving some code in SyntaxHighlight_GeSHi class around.

The old way still works and is used for MediaWiki 1.20 and lower.

Bug: 24134
Change-Id: Iafd91de8922be55688fedef4e43a8e7f54d4e1cc
2014-05-04 20:46:21 +02:00
Brad Jorsch 335a5e9a9c Protect tabs from HTML Tidy
HTML Tidy doesn't care for tabs, and likes to always output spaces. This
can break the syntax-highlighted output, since Tidy converts tabs to
spaces on the source-code level instead of on the rendered HTML level,
even inside <pre> tags where it really shouldn't (this is probably a bug
in Tidy).

r97300 fixed the bad indenting by converting tabs to spaces before
highlighting, which works around Tidy's bug but breaks highlighting of
languages where tabs are significant (e.g. Whitespace).

It turns out that Tidy's tab mangling occurs while it's reading the
source file, before the conversion of entities such as &#9; to tab. So
GeSHi can armor its <pre>-wrapped output against Tidy's bug by encoding
all tabs as &#9;.

Bug: 30930
Bug: 57826
Change-Id: Id541e2712bd3f94446442ccf2e1e2f214e2801ba
2013-12-02 16:43:36 +00:00
Bryan Petty cd001a9ed9 Add Option to Enable Keyword Links
Patch by Bryan Petty

Bug: 53787
Change-Id: I8c818859df8240cfcfef94d06d5d12a848cc76dc
2013-10-09 09:03:03 +00:00
Dereckson f976a48f37 (bug 44214) Fix bundled GeSHi library inclusion path
Currently, the SyntaxHighlight GeSHi extension includes geshi/geshi.php.

This creates a conflict when an up to date GeSHI library exists in PHP included path.

This change let the SyntaxHighlight GeSHi include our bundled version instead.

Change-Id: Ie8f9aa6182a38508201d639723e876c156d8b0d1
2013-03-06 03:40:00 +00:00
daniel 064fb261db Use new ContentGetParserOutput hook.
Using ContentGetParserOutput instead of ShowRawCssJs allows highliting to be applied
for other kinds of scripts as well (e.g. Lua). It also allows more special case code
for CSS and JS to be phased out.

NOTE: this requires Ibfb2cbef to be merged in core!

Change-Id: Ie260c22680ec9a31e505c685d70e17efe8a7bf44
2013-03-05 19:52:04 +00:00
Ori.livneh 0122c20452 Merge "(bug 26204) font-size is too small" 2013-02-22 23:41:19 +00:00
Ori Livneh 9fd1639d46 Disable some highlighting for MOUSs
(...modules of unusual size.)

Enabling full syntax highlighting for very long Lua modules can produce DOMs
that have hundreds of thousands of elements and cause browsers to lock up.

I took a count of spans by class (which amounts to a count of tokens by type)
of https://en.wiktionary.org/wiki/Module:languages and came up with:

       sy0:      62545 (symbols)
       br0:      61952 (brackets)
       st0:      39291 (strings)
       kw3:       7746 (keywords)
       kw1:          3
       kw2:          2
       co2:          2
       co1:          2
       nu0:          1
     ------     ------
     Total:     171544

GeSHi allows you to disable highlighting for a particular token type (see
<http://qbnz.com/highlighter/geshi-doc.html#disabling-lexics>) which like a
good way of handling this issue.

Disabling symbols (set_symbols_highlighting(false)) removes both sy0 and br0
elements from the DOM (about 124k elements in the case of Module:languages),
with about 47k elements remaining on the page. This is enough to make Chromium
responsive on my laptop (2.3ghz i5, 8 GB RAM), but it's still noticeably
sluggish. Adding 'set_string_highlighting(false);' removes another 40k elements
from the rendered output, and the resulting DOM is quite zippy at 8k elements.

Proposed solution: disable symbols highlighting when >100 kB; disable strings
highlighting too when >200 kB.

Change-Id: I90c645f9d03bbdc135058a3717a463dec40aa77d
2013-02-20 22:06:59 -08:00
Antoine Musso 6d54985ad6 (bug 26204) font-size is too small
The Geshi rendered output has a font-size of 10px where we would expect
13px just like for <pre>.

Bug 33496 against MediaWiki core dealt with that issue already: in some
(all?) browser 'monospace' has a size of 13px where as the default is
16px. When defining a font-size of 0.8em the monospace is scaled down to
10 px which is too small. By appending another font statement, the
browser treat monospace as a default font and thus scale it starting
with 16px instead of 13px.

This patch append a style to geshi which set the font-family to
"monospace, monospace" thus tricking the browser in considering
monospace a regular font.

Change-Id: I7bbdcc0a21010513473a7ca9d784df77e9920b5b
2013-02-13 22:37:00 +01:00
Siebrand Mazeland c602c5a4a7 Maintenance for extension SyntaxHighlight_GeSHi.
* Use Message class where possible.
* Removed superflous newlines.
* Update .gitignore.

Change-Id: Ic2386183e240662331656ebadcaad1057569fb7c
2012-08-26 11:24:29 +02:00
Catrope a62433879b Shut up a PHP notice when the (css|js) expression doesn't match anything
This can happen if the TitleIsCssOrJsPage hook causes a page without a
.css or .js extension to be considered a CSS/JS page.

Change-Id: I875a7f89f683336f18e70358fe589cef706fd5d1
2012-07-18 16:33:04 -07:00
Timo Tijhof b06fbd3b60 Remove usage of mw-code-inline
Remove usage of mw-code-inline:
 * That class ended up not being merged into core, so it does nothing.
   Only mw-code (for the <pre> wrap) is needed.
   7c9b2273c9cbdae90c9f4e3890a13619f769c5d0 (mediawiki/core) had both
   in an earlier patch version, but only mw-code was merged.

Follows-up:
 * mediawiki/extensions/SyntaxHighlight_GeSHi:
   dc147a5ef1
   Use .mw-code and .mw-code-inline

 * mediawiki/core
   7c9b2273c9cbdae90c9f4e3890a13619f769c5d0
   Add .mw-code styles in core

Change-Id: I793c05c3e103209cf966d9e35ab37c05528cdbb8
2012-05-11 04:36:18 +02:00
Timo Tijhof dc147a5ef1 Use CSS classes .mw-code and .mw-code-inline
- Follows-up I4ff5d0197ba8dc0dad3cafd03f2b120bc22e75cb

- Reverts r113190 (redundant fix that caused 35875)

- Fixes:
 * bug 19416
 * bug 35875

Change-Id: Iaa2227348ca632d4a261c149bdf2428b4b48adc7
2012-04-14 06:08:20 +02:00
Sam Reed d2f784ca96 Documentation, spaces, braces, explicit member variables 2012-03-09 23:33:42 +00:00
Krinkle 5dfa1034c1 [SyntaxHighlight GeSHi] Use <code> and <pre> instead of <span> and <div> to allow skins to universally style these without requiring local wikis to manually maintain a copy of each skins's <pre> style and apply it to .mw-geshi
* Fixes
-- (bug 19416) GeSHi-generated blocks should use <pre> style for the container
2012-03-06 22:35:40 +00:00
Robin Pepermans b81f422ffc Add mw-content-ltr/rtl class: fixes bug 33538: Line numbers are outside of left border when using <source ... line start= > on RTL wikis
Also make sure mw-content-ltr/rtl is the same as the dir attribute value. Restrict that value to either ltr or rtl (not sure if rtl really needed; source code is always ltr). Also remove text-align:left; as it can/should be set manually in the <source> tag.
2012-01-05 19:46:42 +00:00
Sam Reed 65ffff273a Fix whitespace
Don't use direct member variable access
2011-12-16 14:51:31 +00:00
Sam Reed 01139727ee Documentation 2011-12-02 17:00:19 +00:00
Roan Kattouw 4227b5510d (bug 27714) Load MediaWiki:Geshi.css using ResourceLoader. Modified patch by Lewis Cawte 2011-11-20 18:07:20 +00:00
Brion Vibber e739c5d3b8 * (bug 30930) Fix bad tab-to-space conversion in SyntaxHighlight_GeSHi when $wgUseTidy on
Tidy always converts tabs to spaces on input; on a big <pre> section this is ok but it tends to fail on syntax-highlighted output, where the spacing should depend on the *output* not the *input markup*.
As a workaround, when $wgUseTidy is enabled we now apply our own tab-to-space conversion preemptively on the input before feeding it into GeSHi for highlighting; this keeps the right spacing through to output.
2011-09-16 17:52:28 +00:00
Victor Vasiliev bcd5a74456 Make certain members of the SyntaxHighlight_GeSHi class public, so other
extensions may use it.
2011-08-14 06:59:35 +00:00
Brion Vibber 0cd1f4b868 * (bug 10201) SyntaxHighlight_GeSHi now shows the text unformatted along with warning if the language is invalid or unrecognized.
Uses a simple <pre> which may not be ideal but works ok. :D
Consolidated a few repeat lines.
2011-05-13 13:27:29 +00:00
Max Semenik 25fb269d86 SyntaxHighlight_GeSHi: collapse language list by default to look less scary 2011-02-25 16:38:23 +00:00
Sam Reed 8b3fe7231c Minor followup to r81865, only set dir to ltr if it's not already set to something else 2011-02-11 00:31:17 +00:00
Sam Reed 0ed4e3e390 *(bug 10081) Allow html attribute on SyntaxHighlight GeSHi extension
Patch by Umherirrender

(Seems to be all but based on the Poem implementation, as per Brions suggestion)
2011-02-10 01:59:14 +00:00
Sam Reed 40db2f22e7 Explicitally define a couple of variables 2011-01-23 09:38:33 +00:00
Sam Reed fcb04eeed7 More deprecated method call removals and updates 2010-10-29 15:32:44 +00:00
Sam Reed 29de7361fb Fixup (and add) some braces, remove trailing whitespace 2010-08-09 06:56:38 +00:00
Jeroen De Dauw 4bc3dbd009 Follow up to r70741 2010-08-09 06:25:28 +00:00
Max Semenik 973516a5cb SyntaxHighlight_GeSHi: although I haven't been able to reproduce bug 23840, this should fix it. 2010-06-12 06:27:04 +00:00
Chad Horohoe 6ecc369fbd Revert r66934 (Removing wfLoadExtensionMessages() from everything). I disagree on principle...we branch extensions for this very reason. But people want trunk extensions compatible for several versions back, meh. 2010-05-27 15:56:53 +00:00
Chad Horohoe b57547e670 Large commit. Removed 800+ references to no-op wfLoadExtensionMessages() 2010-05-26 22:25:32 +00:00
Happy-melon 0342a1a717 Follow-up to r63815: code style 2010-03-16 12:50:30 +00:00
Happy-melon d0eb05173e (bug 22848) Rm extraneous space after <span> tag, which Tidy moves outside the tag forcing a perhaps-unwanted break. 2010-03-16 12:48:12 +00:00
Max Semenik 8902d97dd0 SyntaxHighlight_GeSHi: fixed bug with <source lang=""> spewing zillion PHP warnings. Patch by Dan Barrett 2009-11-19 20:37:17 +00:00
Shinjiman e63f55da7d show the version information of GeSHi currently using, only show the version when Special:Version is loaded using the SpecialVersionExtensionTypes hook.
Link to r52546, r52550 and r52555 as there have some comments on CodeReview.
2009-07-01 19:34:01 +00:00
Shinjiman bb149b0887 revert r52546 and r52550 for slow loading for the class, per CodeReview. 2009-06-29 17:06:59 +00:00
Shinjiman b7179c44cf tweak for r52546, use require_once() to make the class file only load once. 2009-06-29 16:29:43 +00:00
Tim Starling b424069389 Added a class to the wrapper to allow site CSS to re-add the dashed borders on wikis that want them. 2009-06-24 05:39:23 +00:00
Tim Starling ae726406e2 Added a profiling section for the parser hook. 2009-06-24 05:25:32 +00:00
Brion Vibber 9406b30989 Follow-up to r50693 "Add optional $wgSyntaxHighlightDefaultLang parameter; allows people to set a default language that shows up if the lang parameter is missing."
Fix whitespace (tab/space issues) and drop duplicated strtolower() call to common code path
2009-05-18 20:28:50 +00:00
X! 72521f6b30 Add optional $wgSyntaxHighlightDefaultLang parameter; allows people to set a default language that shows up if the lang parameter is missing. 2009-05-17 15:21:37 +00:00
Siebrand Mazeland 005a5d82a9 (bug 16317) source tag error shows invalid example in german error message 2008-11-21 08:41:06 +00:00
Siebrand Mazeland a2deece649 Consistent casing for addHTML() 2008-11-06 22:20:29 +00:00
Niklas Laxström 3fdce00db1 * (bug 15634) Add The Enclosure/Header Type "none" 2008-09-28 15:30:45 +00:00
Niklas Laxström 79697ffd83 * Trim only preceeding newlines, not all whitespace
* Support for the new GESHI_HEADER_PRE_VALID in geshi 1.0.8
* Strict Standards: Non-static method SyntaxHighlight_GeSHi::validHighlightRange() should not be called statically
2008-07-11 18:12:48 +00:00
Brion Vibber f059181154 Cleanup for r37495 (adds line highlighting support to geshi plugin):
* Break input validation out to a function so it doesn't mush up main program flow readability
* Reduce denial of service attack area by imposing an arbitrary limit on the size of line ranges
* Reject 0 as a valid input line

Some further notes:
* Currently, the line numbers given for highlighting seem to ignore the 'start' line number provided for displaying line numbers. This is IMHO a bit confusing; it might be better to add the start line number in so you can specify line numbers which match what will be displayed.
* You can specify line numbers after the end of the document without complaint. It might be better to count the lines and ignore any additional ones.
2008-07-10 20:55:02 +00:00
Niklas Laxström 9bb924174a * Add highlight support: highlight=3,6-7 2008-07-10 12:45:20 +00:00