Skip to content

Instantly share code, notes, and snippets.

@cben
Created January 29, 2016 06:52
Show Gist options
  • Select an option

  • Save cben/e3eebddb9cc7fb3d8386 to your computer and use it in GitHub Desktop.

Select an option

Save cben/e3eebddb9cc7fb3d8386 to your computer and use it in GitHub Desktop.
Feedback for Gitbook Editor 5 beta

saw it on hacker news but it's already closed for comments.

[specifically tried gitbook-editor-5.0.0-beta.6-linux-x64.deb on lubuntu 15.10]

Very nicely done WYSIWYM! I'm author of mathdown.net & https://github.com/cben/CodeMirror-MathJax/, which only renders math, and less well than your implementation.

(the exact meaning of "WYSIWYM" is fuzzy; styled text is probably not exactly what LyX meant but math/image/link rendering brings it closer, and in any case it's a better description than "WYSIWYG". I understand the term never got widely known and you might prefer WYSIWYG for publicity...)

Images and links preview in inline syntax but not [reference][id] syntax. Better than nothing and I can see why it's easier. (You listening to CM change events and calling markText(), right? I'd love to discuss how to implement it more fully, mail me.)

Your markdown syntax highlight can be confused by math content, especially _ and * chars:

foo $$x_{y}$$ this should not be italic

The easy solution is https://codemirror.net/doc/manual.html#addon_multiplex . Being start/end regexp based, it's not perfect; I'm working to fix some limitations soon but e.g. understanding nested $s will be remain impossible. A deeper fix would be to make math built-in to mode/markdown.

There are some stateful bugs. E.g. edit $$abcd$$ -> $$ab$$cd$$, move around, then remove the middle $$. Not always but that tends to cause a mess. I think you get overlapping markText widgets?

Nested dollars break things badly:

$$\sum_\text{$x$ is prime} \frac{1}{x}$$ bar

Upon loading such file, everything up to closing $$ remains text, and $$ bar... becomes math. Even after I remove $x$, it remains in some messy state. [practical workaround: \(x\) is prime. But since only $$ is delimiter for kramed, you should be able to support single dollars safely.]

In general, math being delimited by $$ on both sides too easily leads to text/math inversion for rest of file... Most common case is during editing when you have unfinished formulas. Mitigation ideas: (1) reset to text state on say empty lines? It seems currently empty lines are legal within math in gitbook, don't know if you'll want to break that. (2) reset on encountering "math" that's not legal math? Not sure how to formulate this rule, and anyway hard to affect parsing given MathJax's async nature.

Race condition: if you quickly change a formula (eg. $$a$$ -> $$ab$$) and press up/down arrow to move outside, it's possible it will render but show an outdated formula. (in some cases the preview pane also leaves outdated formula, but preview is completely rebuilt on following edits, while the in-place rendering can stay outdated until you enter that specific formula again.)


  • Nasty bug: switching to another file having unsaved edits warns they might be lost, offers Cancel | >>Save<< | Don't save. Great! Alas choosing Cancel doesn't switch, yet reloads(?) LOSING THE UNSAVED EDITS.

    Consider just always saving?

  • No search/replace? https://codemirror.net/demo/search.html is not super pretty but does the job well. Just load the plugin and add menu entries for discoverability. Unlike in browser there will be no fight over Ctrl+F.

  • Proofreader seems too aggressive on markdown constructs.

  • What does "Hide Gitbook editor (Ctrl-H)" do? I see process is still running but how do I get it back? My only guess was running it again but that gives me a fresh instance (now I have 2 gitbook-editor/editor process trees).

  • kudos for leaving access to dev tools!

  • Toggling preview pane deserves a keyboard shortcut IMHO.

  • Denoting keyboard modifiers with ^⎇⇧ chars is IMHO less readable than "Ctrl-Shift-..." for non-Mac users (esp. ⎇); and the menus use "Ctrl-..." style anyway [I'm on linux].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment