Topic on Extension talk:CodeEditor

Why is there no wikitext syntax highlighting?

10
Zewas (talkcontribs)

Is there a technical reason or did no one get around to writing one?

TheDJ (talkcontribs)

CodeEditor uses the Ace library and it dors not support wikitext highlighting.

Zewas (talkcontribs)

Yes, I noticed :) But why not? Is there a technical reason why there's no syntax highlighter for wikitext or is the problem simply that nobody has tried to write one yet?

PerfektesChaos (talkcontribs)

The reason is that Wikitext is not really a formal language, but a mess.

For 15 years it has been tried to create a Backus-Naur description, without full success. There is also no syntaxhighlight presentation.

However, you may search for a thing called CodeMirror.

Zewas (talkcontribs)

So you think it's impossible to write a syntax highlighter without a full-fledged parser?

PerfektesChaos (talkcontribs)

“Impossible” is a big word.

Theoretically, yes. Practically, low outcome.

  • You might do some markup for bracket pairs.
  • Interpretation is dependant on localization and state of the farm.
  • Interpretation depends on localization.

Consider:

  • [[CSI: Miami]]
    • Currently in article space.
    • As soon as csi will be etablished as wiki language, it is an interwiki link.
  • [[Image:map.png|Legend]]
    • Media transclusion, Image: rather than File:
    • Could be localised file namespace name: [[Fichier:map.png|Legend]] is image transclusion in French.
    • If Fichier: is not file namespace name, that is linking to article or other namespace.
  • {{Something}}
    • Could be anything: template transclusion, parser function, localised variable name.
  • so <what> now
    • If what is known HTML or tag extension (may be localised name), this is a tag.
    • Otherwise, it is mathematical: A < B < C
  • A template transclusion may be embedded within syntax and evaluates to some string under certain conditions. No way.

Huge efforts, limited resulta.

  • You need to put constant set of keywords at syntax repository, but interpretation depends on local wiki environment.
Zewas (talkcontribs)

That's all true, yes. A parser would need detailed knowledge about the wiki itself. That knowledge is not supremely hard come by:

https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=namespaces%7Cgeneral%7Cinterwikimap%7Cextensiontags%7Cfunctionhooks%7Cvariables%7Cfileextensions%7Cmagicwords%7Cspecialpagealiases

but still, that knowledge is required. And the parser would also need a database of extension tags, parser functions, magic words and such. That's where it gets really tedious...

I'm asking all of these questions because I'm determined to write a wikitext parser in JavaScript. Not a complete parser. It won't output HTML or resolve templates, but it will parse everything into an abstract syntax tree. It's ambitious, I know :|

TheDJ (talkcontribs)

You should read the (by now) heavily outdated documentation page Markup_spec.

TheDJ (talkcontribs)

Oh and Parsoid of course is a JS parser for wikitext.

Zewas (talkcontribs)

Thank you!

Reply to "Why is there no wikitext syntax highlighting?"