Page MenuHomePhabricator

CodeEditor should support editing <syntaxhighlight> blocks on a page
Closed, ResolvedPublicFeature

Description

Author: gryllida

Description:
Script viewer software should support sections and section editing, using one-line comments (or special formatting therein) for heading syntax.


/* Foo */

Foo.prototype.bar = function(){
...
};
Foo.prototype.baz = function(){
...
};

^^^^^ everything above is in the Foo section

/* Foo 2 */ <---------- this becomes a heading

Foo2.prototype.bar = function(){
...
};

Foo2.prototype.baz = function(){
...
};

^^^^^ everything above is in the foo 2 section



Version: unspecified
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=50962

Details

Reference
bz60438

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:02 AM
bzimport added a project: CodeEditor.
bzimport set Reference to bz60438.
bzimport added a subscriber: Unknown Object (MLST).

Hi, what is "Script viewer"? Is this [[mw:Extension:CodeEditor]]?

gryllida wrote:

Whatever I see when reading or editing [[Special:MyPage/common.js]]. (There is one extension which highlights the code when reading it, and another extension which is responsible for the code editor; I don't know which one this bug falls under, since both of them would have to support editing a section of a JS or CSS script.)

gryllida wrote:

https://test.wikipedia.org/wiki/User:Gryllida/common.js
a stupid ugly workaround

https://test.wikipedia.org/wiki/User:Gryllida/afch2/v2
with sections

syntax highlight ok, code-editor does not pick it up

Can I ask why ?

I mean a section in Javascript is usually not a self-contained unit, it only has meaning icw all the other stuff. So I'm trying to understand why you would want to edit it in that way. Can you clarify how this helps you to edit code ?

gryllida wrote:

There are two reasons behind this.

  1. Usually people contain different objects in different files. On wiki, browsing (or simply creating) different files and subfiles of a JS file is far from intuitive. It could make sense to add support for sections.
  1. Inline (POD-like) documentation would benefit readability. See i.e. http://juerd.nl/site.plp/perlpodtut .

In other words, CodeEditor should be capable of editing any <source> block on a page without entering edit mode for the entire page. I am renaming the bug title accordingly.

We actually have a geshi module that does this in the CodeEditor codebase, but it's only the editor mockup, it's not actually able to make changes to the wikitext right now.

Because you seem to be interested in similar functionality, I have fixed up the module in this patch: https://gerrit.wikimedia.org/r/#/c/127451/

Making it fully work would be quite some additional work still, but it's not as far away as I initially figured. The biggest problem is that we need to make sure not to implement everything a dozen times (live preview, editpage, visual editor and inline code editor).

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:13 AM
Aklapper removed a subscriber: wikibugs-l-list.
Krinkle assigned this task to Esanders.
Krinkle added a project: SyntaxHighlight.
Krinkle subscribed.

This seems effectively solved by the SyntaxHighlight extension and its integration for VisualEditor (T49742: Provide basic source code editor features in VisualEditor SyntaxHighlight plugin).

Screenshot 2022-04-05 at 23.36.14.png (582×1 px, 63 KB)

Source code: ve.ui.MWSyntaxHighlightDialog.js