Is there a technical reason or did no one get around to writing one?
Topic on Extension talk:CodeEditor
CodeEditor uses the Ace library and it dors not support wikitext highlighting.
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?
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.
So you think it's impossible to write a syntax highlighter without a full-fledged parser?
“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 thanFile:
- 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.
- Media transclusion,
-
{{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
- If
- 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.
That's all true, yes. A parser would need detailed knowledge about the wiki itself. That knowledge is not supremely hard come by:
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 :|
You should read the (by now) heavily outdated documentation page Markup_spec.
Oh and Parsoid of course is a JS parser for wikitext.
Thank you!