mhuebert / maria

A ClojureScript coding environment for beginners.
https://maria.cloud
473 stars 34 forks source link

Can't define function with a minus sign inside docstring #81

Closed daveliepmann closed 7 years ago

daveliepmann commented 7 years ago

This bug is in dev only. Works fine in non-markdown/prod.

If a minus sign exists in the docstring of a function I'd like to defn, it will not evaluate:

(defn entropy1
  "—"
  [p-pos p-neg]
  (+ (* (- p-pos) (log2 p-pos))
     (* (- p-neg) (log2 p-neg))))

Does not evaluate. Error in console suggests that the minus sign is converted to a dash:

live.js:26477 Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
    at Object.goog.crypt.base64.encodeString (https://dev-user.maria.cloud/js/compiled/live.js:26477:106)
    at cljs.js.append_source_map (https://dev-user.maria.cloud/js/compiled/live.js:26868:166)
    at v (https://dev-user.maria.cloud/js/compiled/live.js:27016:101)
    at cljs.js.compile_str_STAR_ (https://dev-user.maria.cloud/js/compiled/live.js:27017:283)
    at Function.cljs.js.compile_str.cljs$core$IFn$_invoke$arity$5 (https://dev-user.maria.cloud/js/compiled/live.js:27021:34)
    at cljs.js.compile_str (https://dev-user.maria.cloud/js/compiled/live.js:27018:313)
    at Function.cljs_live.eval.compile_str.cljs$core$IFn$_invoke$arity$4 (https://dev-user.maria.cloud/js/compiled/live.js:27095:371)
    at cljs_live.eval.compile_str (https://dev-user.maria.cloud/js/compiled/live.js:27090:217)
    at https://dev-user.maria.cloud/js/compiled/live.js:27104:183
    at Function.cljs_live.eval.eval.cljs$core$IFn$_invoke$arity$4 (https://dev-user.maria.cloud/js/compiled/live.js:27107:54)
mhuebert commented 7 years ago

Ugh. Looks like #57. We should try and fix this in ClojureScript because it will pop up with emoji too.

daveliepmann commented 7 years ago

Since it's limited to docstrings, a quick fix might be sufficient to block the conversion (by CodeMirror?) of minus sign to en-dash.

mhuebert commented 7 years ago

unfortunately, it's not limited to docstrings :(..

I also wasn't able to reproduce the conversion to n-dash, was there a specific order it was typed in?

On Sun, Aug 13, 2017 at 21:14 Dave Liepmann notifications@github.com wrote:

Since it's limited to docstrings, a quick fix might be sufficient to block the conversion (by CodeMirror?) of minus sign to en-dash.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mhuebert/maria/issues/81#issuecomment-322061181, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKFZ-8oQOm6vKx2VMz_-THTv3BlhW1zks5sX0srgaJpZM4O1wMG .

-- http://matt.is — Berlin, Germany

daveliepmann commented 7 years ago

I copied from https://gist.github.com/jackrusher/5201340 but I thought the dashification occurred when just typing out the entropy docstring. Only noticed it on copy-paste outside the editor to here.

mhuebert commented 7 years ago

Ok. In any case I've submitted a new patch to https://dev.clojure.org/jira/browse/CLJS-1576, so hopefully we won't have to worry about this for long.

On Mon, Aug 14, 2017 at 10:14 AM, Dave Liepmann notifications@github.com wrote:

I copied from https://gist.github.com/jackrusher/5201340 but I thought the dashification occurred when just typing out the entropy docstring. Only noticed it on copy-paste outside the editor to here.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mhuebert/maria/issues/81#issuecomment-322126956, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKFZ2Y06PTIGFoIzqBHu7nQEzUMSN1Vks5sYAIBgaJpZM4O1wMG .

-- http://matt.is — Berlin, Germany

mhuebert commented 7 years ago

Tracking in #57