Skip to content

Commit

Permalink
default to HTML display for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jonklein committed Dec 31, 2020
1 parent 9303aee commit 8b6c7dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Niex notebooks support two types of cells: code and markdown.
Markdown cells are used for human-readable text using the [Markdown format](https://www.markdownguide.org/basic-syntax/).

Code cells are used to store & execute Elixir code. To use a code cell, simply populate the cell and execute it using
the "run" button. The cell output field will display the result of the execution. Cells must be explicity executed -
if you make changes to code that other cells are dependent on, you must explicitly
the "run" button (or the key combo command-retrun). The cell output field will display the result of the execution.
Cells must be explicity executed - if you make changes to code that other cells are dependent on, you must explicitly
rerun those cell commands in order.

#### Notebook & Interpreter State
Expand All @@ -84,7 +84,7 @@ Like running an IEx session, Niex maintains an internal interpreter state that i
of commands in the notebook**, and **is not saved in the notebook**. This means that when you open a saved
notebook, you must execute each cell in order to restore internal state.

#### Asynchronous execution
#### Asynchronous execution & animation

You can also display intermediate results for long-running code in cells. This allows you
to create animations or updates for asynchronous processes. To render an intermediate result
Expand Down Expand Up @@ -167,7 +167,6 @@ Sample notebook:

- executed code is **not** sandboxed - see section below on arbitrary code execution
- future work - add support for other media types
- future work - add support for Live components in cells
- notebook format & details are subject to change

## WARNING: arbitrary code execution
Expand Down
4 changes: 2 additions & 2 deletions assets/js/niex.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export const hooks = {

NiexOutput: {
mounted: function () {
if(this.el.attributes['data-type'].value != "html")
if(this.el.attributes['data-type'].value == "code ")
this.el.innerHTML = Prism.highlight(this.el.innerText, Prism.languages.elixir, 'elixir');
},
updated: function () {
if(this.el.attributes['data-type'].value != "html")
if(this.el.attributes['data-type'].value == "code")
this.el.innerHTML = Prism.highlight(this.el.innerText, Prism.languages.elixir, 'elixir');
}

Expand Down
8 changes: 4 additions & 4 deletions lib/niex_web/live/cells.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ defmodule NiexWeb.Cells do
"""
end

defp render_output(%{text: text, type: "html"}) do
# pre-rendered HTML
raw(text)
defp render_output(%{text: text, type: "code"}) do
text
end

defp render_output(%{text: text}) do
text
# pre-rendered HTML
raw(text)
end
end
Loading

0 comments on commit 8b6c7dd

Please sign in to comment.