Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to CodeMirror 6. #2595

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Commits on Oct 18, 2024

  1. Upgrade to CodeMirror 6.

    Some features of this change are improved syntax highlighting and
    the addition of autocompletion.  To see available autocompletions at the
    current cursor location, you can type Ctrl-Space.  In many cases,
    autocompletions are offered automatically when certain things have been
    typed.
    
    CodeMirror 6 can not be used via script tags.  So a PGProblemEditor
    package has been created for this.  The repository for that is
    https://github.com/openwebwork/pg-problem-editor.  An initial package
    has been published in npm at
    https://www.npmjs.com/package/@openwebwork/pg-codemirror-editor. The
    real work is done in the codemirror-lang-pg package that adds support
    for the PG language in CodeMirror 6.  The repository for that package is
    https://github.com/openwebwork/codemirror-lang-pg, and the npm package
    at https://www.npmjs.com/package/@openwebwork/codemirror-lang-pg.
    
    The pg-problem-editor package is designed so that it can be used by
    webwork2, the standalone renderer, and possible others that want a PG
    problem editor.  It may need a few tweaks to make it work for webwork3
    in the future, but should also work for that.
    
    The codemirror-lang-pg package consists of a base PG parser that is
    largely derived from the codemirror-lang-perl package (at
    https://github.com/drgrice1/codemirror-lang-perl and
    https://www.npmjs.com/package/codemirror-lang-perl) with a modifications
    specific to the perl available in a PG problem.  The main differences
    are that its escape sequence is ~~, much of what can not be used in
    the safe compartment has been stripped out, and there are special blocks
    for PGML, PG text, and LaTeX image code.  Then there are two other
    parsers.  Those are the PGML and PG text parsers.  Those parsers run on
    the contents of the PGML and PG text blocks found by the base PG parser.
    Note that the PGML parser is actually a javascript implementation of the
    parser in PGML.pl with some modifications to track position and things
    needed to associate the parsed tree with the original code.
    
    Note that the configuration of theme, keymaps, and such are now part of
    the pg-codemirror-editor, and are shown in a panel of the editor
    instead of below as before.
    
    Emacs and Vim keymaps are available, but at this point there is not a
    Sublime keymap for CodeMirror 6.
    
    The themes that are available include a basic default theme (that is
    part of the pg-problem-editor package and just adds some syntax
    highlighting that is missing from the CodeMirror 6 default), the OndDark
    theme that is the only other theme provided by the CodeMirror 6
    developers directly, the themes in the thememirror package, and the
    themes from https://github.com/craftzdog/cm6-themes which are in several
    separate npm packages.  Note that both thememirror and
    craftzdog/cm6-themes provide a solarized light theme, and that is why
    there are two of those.  They are slightly different though.
    
    I am sure that there is a lot more work to do on this, and there are
    other things available with CodeMirror 6 that could probably be
    implemented.  In any case, this is a good start.
    drgrice1 committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    ad4df93 View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2024

  1. Use the Mojolicious template language for CodeMirror when editing ach…

    …ievement notifications.
    
    The new codemirror-lang-mt package is used for this, and support for
    that language has been added to the pg-codemirror-editor.
    drgrice1 committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    d9ca88c View commit details
    Browse the repository at this point in the history