Jump to content

User:Alien333/cmbb

From Wikisource

Code Mirror
But homeBrew[1]

I was annoyed at how CM worked[2], 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.

  1. It aims to be eventually better for my purpose, and maybe even others'.
    Title was at first "But Better", but it isn't really, it's just a different way of doing, different goals (and until I fix #Bugs it's going to be decidedly worse).
  2. that was CM5; CM6 brings a lot of interesting stuff; When they start supporting headers & footers and protected pages, I'm probably going to drop most of this, and maintain only as a sort of plugin a few things like in-page preview & diff, scanno coloring, autocompletion, and/or redlink marking.

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 (CM6 only does it for magic words)
  • 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 (CM6 also does this)
  • redlink marking in template names and and link targets

Bugs

[edit]
  • in Page:space, past a certain page length, it overflows the container -- that's an issue with the CSS used to overlay the overlay
  • Doesn't recognise {{VARIABLES}} -- use CM's list
  • Redlinking is mistakenly redlinking {{...}} and {{....}} -- probably trying to find parent (..) + ..
  • overeager tag matching -- taking nearly anything between <s and >s as a tag. Excessive. -- maybe just assume multiple-line tags are not tags?

Other to do

[edit]

important:

  • redo stacks -- undo without redo is a bit meh

less important:

  • try to make an alternative discussiontools, with 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 red[3]
cmbb-conp commas green[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.
  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