Make the wrapper div for code block create a block formatting
context. This changes how floated content is laid out: previously
the wrapper was taking 100% width and tried to wrap text around the
floated content, now its width is limited by the width of floated
content. This way absolutely positioned elements inside the code
block (like the copy buttons) won't overlap the floated content.
We've had this problem before when adding line numbers (T272853),
and the workaround we used there won't work for the copy buttons.
It also lets us remove the background-color override, previously
needed to avoid it leaking outside the code block (T126010).
Bug: T40932
Change-Id: I7f51ea78d7fcf07358c6ee45275b2bae2e1cbeb8
This includes some changes to the colors in light mode to make them
match Codex tokens.
Bug: T365926
Change-Id: Ifa5d762bffa3c4ebdcfa451cc4a9965cd7b1b064
Update the CSS generation script to generate styles for both light and
dark modes. The Pygments style 'default' is used for light mode, as
before, and 'monokai' for dark mode.
Bug: T365926
Change-Id: I0cc1f9a10d4ff8e0c279a12cacbb1c300225328f
Prepend '//' to relative URLs to turn them to real new (root)
addresses instead of relative paths in current domain
Bug: T368166
Follow-up: I999937c1f6303ecc64adb6285e73a9ce10f67bd8
Change-Id: I2cf901c7b0454517dc93ea8113dcf69832584c08
In Scribunto modules, link page names used in require(), mw.loadData()
and mw.loadJsonData() invocations.
Inspired from the CodeLinks gadget[0] but rewritten for brevity,
avoiding Wiktionary specific code, making the code more generic,
and thereby adding support for mw.loadJsonData().
[0]: https://en.wiktionary.org/wiki/MediaWiki:Gadget-CodeLinks.js
Bug: T368166
Change-Id: Idc554269ee52a05660fa41f065a2b3c73e2e1b9b
* Use mw.Title so that template links work for templates outside
template namespace, and so that titles are normalized.
* Use recursion instead of while loop so that both the segments before
and after the inserted link are searched for further linking
possibilities. Among other cases, this fixes the case where a template
link before a wikilink (on the same line) was not working. This also
avoids infinite iteration if mw.Title.newFromText() failed to create a
valid Title object.
Bug: T368166
Bug: T374693
Change-Id: I4d485340928b81df26ca035874422fdb5930710f
<syntaxhighlight> blocks with a boolean "copy" param will now have a
button next to them for copying the code to the clipboard. Not
applicable for inline code blocks.
Adapted from the mediawiki.org gadget written by Krinkle.
Bug: T40932
Change-Id: Ic8ef030514c3b6dd2cb9b137f032588869ab3762
Changes for T356956 applied the styles in the wrong place.
`<div class="mw-highlight">` should have no background (and we need
to override the default Pygments styles that add it).
`<div class="mw-highlight"><pre>` and `<code class="mw-highlight">`
should have background (and we need to override core MediaWiki styles
that adapt to light/dark mode with forced light mode colors).
Bug: T365927
Change-Id: I473203b12673f7bc004f953ab33fe36fb897e095
It's common practise to use [[wikilink]] syntax to mention page names
in comments of JS/CSS/Scribunto code where the links ordinarily don't
work. Using JavaScript to actually make the syntax clickable makes
navigation easier.
{{Templates links}} and external links are also supported.
Bug: T368166
Change-Id: I999937c1f6303ecc64adb6285e73a9ce10f67bd8
This overrides the default skin rule for pre elements as seen
on [[mw:MediaWiki-Docker%2FExtension%2FWikiLambda]]
Bug: T356956
Change-Id: I0a28323f4269e7afb89dce78927e048734f15a49
The ruleset wikimedia/client-es6 already contains
the ruleset wikimedia/jsdoc. So wikimedia/jsdoc
doesn't need to be declared.
Bug: T365047
Change-Id: I59c8f9a244ff727273783b4a3104929232801819
The existing color of background if set to inherit will not work
in night mode. There does seem to be a background set in pygments.generated
so this probably doesn't need to be defined at all, but I erred on the side
of caution.
When defining a background that is not using a Codex design token
we also want to define a color to avoid the status quo of unreadable
text.
Note: this is a short term fix for making the content readable.
We can theme this in night mode later after further analysis.
Bug: T356956
Change-Id: Ic58482b73e520505bde26a47e74f131dd8a51671
The PHPDoc/JSDoc updates are mostly about generic "array" types that
can be made more specific.
In PHP we can remove documentation when it is 100% identical to the
type declarations in the code.
A few mistakes are fixed as well, e.g. a missing "null".
This patch also made a major mistake visible. It looks like the
$geshi2pygments compatibility map was broken since 2018. The array was
changed from values to keys via I7a852dd and some usages updated, but
one was forgotten.
Change-Id: I480999d21f2f69cba84166bb877aa75882778966
Steps to reproduce:
* Make a wikitext page with <syntaxhighlight line="sure">…</…>.
* Edit with VisualEditor and make an unrelated change to the content.
* Save.
* Before the attribute was always replaced with line="1".
* With this patch the old value stays untouched.
Change-Id: I433a206905c1a0a1bc06ef8b4037f6db9d935810
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
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
The outer wrapper is 100% width, so making it position:relative
causes it to stack above floated elements.
Bug: T272853
Change-Id: I20a73b5086ebb03673f0435e27ca93432dcd000c
These rules were being kept for cached content, but were
actually breaking Firefox by triggering a multi-part selection.
Bug: T271614
Change-Id: I83fb4aab88fe1f34bc59d1da18ae8a6a4838a831