Commit graph

14 commits

Author SHA1 Message Date
Nathaniel Nicandro
465d3222a4 Delete all script tags before parsing html
There is an issue where SVG images containing script tags would cause the SVG
render to error.
2018-11-17 15:00:49 -06:00
Nathaniel Nicandro
e04a81a3ad jupyter-fontify-buffer: Don't store fontify buffers 2018-11-16 17:29:47 +00:00
Nathaniel Nicandro
b39f9020c5 jupyter-fontify-according-to-mode: Don't show the fontify buffer 2018-11-16 17:24:18 +00:00
Nathaniel Nicandro
081f329da1 v0.6.0 2018-11-16 00:27:47 -06:00
Nathaniel Nicandro
66c2ee40cb jupyter-insert: Allow for passing in message property lists
* jupyter-mime.el (jupyter-insert): Do it.
2018-11-15 23:04:27 -06:00
Nathaniel Nicandro
08363178ac jupyter-mime.el: Mention all methods defined in the file 2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
c4f37a0156 Implement rudimentary Jupyter display API
Adds methods which operate on Jupyter displays. A Jupyter display is a part of
the frame tagged with a display ID. The current implementation just associates
part of a buffer with a jupyter-display text property and demarcates the
beginning of a display with a jupyter-display-begin property.

* jupyter-mime.el (jupyter-current-display):
(jupyter-beginning-of-display):
(jupyter-end-of-display):
(jupyter-next-display-with-id):
(jupyter-delete-current-display): New methods to work with display IDs.
(jupyter-update-display): Ditto. Was previously a function.

* jupyter-repl.el (jupyter-handle-display-data): Remove handling of
`jupyter-display-ids`.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
126d4bacf8 jupyter-update-display: Be more efficient when replacing displays
Instead of re-computing the inserted data whenever multiple displays exist with
the same ID, copy the previously inserted region to all other regions.

* jupyter-mime.el (jupyter-update-display): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
8146fe660f Move display ID routines from jupyter-repl.el to jupyter-mime.el
jupyter-mime.el might not be the best place for these functions but they are
moved there because that is the current location of `jupyter-insert-with-id`.

* jupyter-repl.el (jupyter-repl-next-display-with-id):
(jupyter-repl-update-display): Move to jupyter-mime.el, replace `jupyter-repl-`
prefix with `jupyter-`.
(jupyter-delete-display-at-point): Move to jupyter-mime.el.
(jupyter-handle-update-display-data): Replace occurrence of
`jupyter-repl-update-display` with `jupyter-update-display`.

* jupyter-mime.el (jupyter-next-display-with-id):
(jupyter-delete-display-at-point):
(jupyter-update-display): Moved from jupyter-repl.el, which see. Promote
`jupyter-next-display-with-id` and `jupyter-delete-display-at-point` to
methods. This is in anticipation of having other kinds of displays besides text
in a buffer, e.g. controlling the display of an external browser.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
df64f6b801 Add jupyter-fontify-region-according-to-mode
* jupyter-mime.el (jupyter-fontify-region-according-to-mode): Do it.

* jupyter-python.el (jupyter-insert): Use it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
092b7f9853 Refactor of fontification routines
* jupyter-mime.el (jupyter-fontify-buffer-name): New helper function.
(jupyter-get-fontify-buffer): Rename to `jupyter-fontify-buffer`. Use
`jupyter-fontify-buffer-name`.
(jupyter-fontify-according-to-mode): Replace call of
`jupyter-get-fontify-buffer` with `jupyter-fontify-buffer`. Remove
`with-silent-modifications`, this prevents modes like markdown from being
fontified correctly.

Allow modifications otherwise markdown mode doesn't work
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
227b4fde49 Use jupyter-with-insertion-bounds in more places
* jupyter-mime.el (jupyter--delete-javascript-tags): Now takes bounds of region
to check as arguments.
(jupyter-insert-html): Do it.
(jupyter-insert-latex): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
959eb0b9b7 Use delay-mode-hooks
* jupyter-mime (jupyter-get-fontify-buffer): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
75a08c26d0 Implement jupyter-insert method
The goal of this method is to act as a single entry point for insertion of
kernel results in any context. One would simply add another method to handle a
specific context.

* jupyter-base.el (jupyter-mime-types):
(jupyter-nongraphic-mime-types): New variables that give mime-types that can be
handled.
(jupyter-insert): New method for dispatching to code that inserts mimetype
representations in the current buffer.

* jupyter-mime.el: New file.
(jupyter-display-ids):
(jupyter-handle-control-codes):
(jupyter-fontify-buffers):
(jupyter-get-fontify-buffer):
(jupyter-fixup-font-lock-properties):
(jupyter-add-font-lock-properties):
(jupyter-fontify-according-to-mode):
(jupyter-insert-html):
(jupyter-markdown-mouse-map):
(juputer-markdown-follow-link-at-point):
(jupyter-insert-markdown):
(jupyter-insert-latex):
(jupyter-insert-ansi-coded-text): Moved from jupyter-repl.el, replaced
`jupyter-repl-` prefix with `jupyter-`.
(jupyter--shr-put-image): Ditto. Also add `shr-` prefix.
(jupyter--delete-javascript-tags): Ditto. Also mark as private functions.
(jupyter-insert-image): Ditto. Also mark as a public function.
(jupyter-insert): (DISPLAY-ID ...) Moved from jupyter-repl.el. Was
`jupyter-repl-insert-data-with-id`.
(jupyter-with-control-code-handling):
(jupyter-markdown-follow-link): Moved from jupyter-repl.el
(jupyter-insert): Implement methods to do the work previously done by
`jupyter-repl-insert-data`.

* jupyter-repl.el (jupyter-repl-graphic-mimetypes): Moved to jupyter-base.el,
 inverted and renamed to `jupyter-nongraphic-mime-types`.
(jupyter-repl-graphic-data-p): Remove unused function.
(jupyter-repl-insert-data): Remove, replace calls with `jupyter-insert`.
(jupyter-repl-add-font-lock-properties):
(jupyter-repl-fixup-font-lock-properties):
(jupyter-repl-get-fontify-buffer):
(jupyter-repl-fontify-according-to-mode):
(jupyter-repl-delete-javascript-tags):
(jupyter-repl-put-image):
(jupyter-repl-insert-html):
(jupyter-repl-markdown-mouse-map):
(jupyter-repl-markdown-follow-link-at-point):
(jupyter-repl-insert-markdown):
(jupyter-repl-insert-latex):
(jupyter-repl--insert-image): Moved to jupyter-mime.el, which see.
(jupyter-repl-insert-data-with-id): Ditto. Changed to a `jupyter-insert` method
dispatched on a string argument.
(jupyter-repl-insert-ansi-coded-text): Ditto. Replace calls with
`jupyter-insert-ansi-coded-text`.
(jupyter-with-control-code-handling):
(jupyter-markdown-follow-link): Moved to jupyter-mime.el.

* jupyter-org-client.el (jupyter-handle-error): Replace
  `jupyter-repl-insert-ansi-coded-text` with `jupyter-insert-ansi-coded-text`.

* jupyter-tests.el (jupyter-insert): Add tests for `jupyter-insert`
2018-11-13 17:46:07 -06:00