orthecreedence / highlight-lisp

A Common Lisp syntax highlighter written in Javascript
77 stars 7 forks source link

Highlight matching paren on mouse-over #6

Closed priyadarshan closed 9 years ago

priyadarshan commented 10 years ago

It would be very nice to have the option to highlight matching paren on mouse-over, like pastes at paste.lisp.org. See as example the same code of the highlight-lisp demo here: http://paste.lisp.org/display/143836

Thank you for highlight-lisp!

orthecreedence commented 10 years ago

Agreed, this would be cool! It may be outside the scope of the project, but if I find I can do it fairly easily, I'll add the feature. Leaving this issue open until I can make a decision either way.

priyadarshan commented 9 years ago

highlight-lisp will hopefully be used for cl-cookbook (LispCookbook/cl-cookbook#43).

Being able to highlight matching paren on mouse-over would be a good help studying the recipes (at least for absolute beginners like myself).

pnathan commented 9 years ago

:+1:

orthecreedence commented 9 years ago

OK FINE YOU WIN!!

Added paren matching in 93216f5. Works slightly differently than paste.lisp.org (their version is more robust, this one just highlights immediate matches). Pull down master and give it a shot (check out the readme for details)

priyadarshan commented 9 years ago

:smile_cat: Thank you so much for the new feature!

It works wonderfully. A quick test from the example in README:

<html lang="en">
<head>
<link rel="stylesheet" href="/Users/priyadarshan/highlight-lisp/themes/github.css">
<script type="text/javascript" src="/Users/priyadarshan/highlight-lisp/highlight-lisp.js"></script>
<body>

<pre><code class="lisp">(defun test-syntax-highlighter ()
  "Docstring explaining what this function does."
  (let ((hash (make-hash-table :test #'equal)))
    ...))</pre></code>

<script type="text/javascript">
HighlightLisp.highlight_auto({className: null});
HighlightLisp.paren_match();
</script> 

</body>
</html>

Results in screenshot 2015-08-12 at 10 59 07

Thank you.

priyadarshan commented 9 years ago

I was meant to add a link to what looks related to paste.lisp.org's source colouring. Let me do it now, if I may: https://github.com/stassats/lisp-bots

Thanks again.

orthecreedence commented 9 years ago

Cool, glad it's working well!

vindarel commented 7 years ago

@priyadarshan indeed now the CL cookbook uses it :) (https://github.com/LispCookbook/cl-cookbook/pull/64)

priyadarshan commented 7 years ago

@vindarel Very nice PR.

Thank you!