Jump to content

User:Alien333/cmbb

From Wikisource

 DRAFT

Code Mirror
But Better[1]

  1. At least it aims to be eventually better for my purpose. Currently still has some bugs

I was annoyed at CM's faults, so I wrote User:Alien333/cmbb.js for syntax highlighting, and have been adding other stuff to it. The reasoning behind it all is this: MediaWiki is not optimised for proofreading, and we won't find anything better, so let's optimise it ourselves.


Features

[edit]

Available:

  • better syntax highlighting: thorougher, e.g. italics in templates
  • includes headers and footers
  • in-page preview & diff: replaces the normal, slow preview and "show changes" that reload the page, by faster ones that don't have to reload and can be closed without reloading (is imperfect, the standard ones can be forced with ctrl-click)
  • autocompletion: for link targets and template names, three results displayed, insert one by clicking on it
  • coloring on protected pages: why, you might ask? see the last thread there, that bug was out there for at least three years because (understandably) no one bothered to manually check that there were 5 not 6 brackets
  • opening pages linked to/transcluded in the code, in a new tab, by ctrl-click
  • redlink marking in template names and and link targets

Planned at some point:

  • adding stuff to discussiontools, namely CMBB highlighting (and correcting DT's issues with automatic intending, it breaks with tables and syntaxhighlights)
  • sorting lists

Not sure of:

  • limited WYSIWYG support, e.g. making sections titles and {{l}} larger, centering {{ppoem}} and {{c}} (quite complicated, not sure I'll manage)
  • code folding. It's a long story, but technically it's very much related to the item above.
  • pasting of formatted content (maybe)

Compatibiity

[edit]

This tries to still be compatible with all scripts, so textarea .val()ing still works. There is a delay up to 0.5secs in displaying .vals(), though. To make it instant, add a .trigger("input") after the .val() closing parentheses.

Classes

[edit]

The colors it uses are my colors, and are also made for (my hacked) dark mode, so you may not like them. You can change them with these classes:

class what it targets does by default
cmbb-titl link targets, template names, parser function names, variable names underline (plus the color &/or bold)
cmbb-temp templates[1] bold #055
cmbb-para variables[1] bold #660
cmbb-pars parser functions[1] bold #F95
cmbb-link links #0063BF
cmbb-tabl table markup bold #A8F
cmbb-taat html attributes in tables #F0E
cmbb-comm comments grey
cmbb-ital italics italics
cmbb-bold bold bold
cmbb-medi mediawiki formatting[2] #07F
cmbb-nowi text that is nowiki'd/syntaxhighlightt'd #F3F3F3 background
cmbb-xtag xml-style tags #396
cmbb-sugg autocomplete suggestions #000 on #EEE
cmbb-redl redlinks #F77
cmbb-digi digits and other likely scannos none[3]
cmbb-conp commas Green underline[4]
  1. 1.0 1.1 1.2 includes brackets, name, and pipes, but not arguments
  2. the italic/bold apostrophes, list markers, indentation, magic words, signature, section titles
  3. During proofreading, these are most of the time errors. This helps differentiate for instance an 1 from an I. However, it can be rather visually polluting, so it's your choice of how you style it and when, e.g. I put it in red only in Page:space.
  4. conp is for COmma Not Period. Commas and Periods are often much too easy to confuse, and this has long for me been one of the hardest-to-spot scannos. Like this, they are very easily distinguishable