SciRuby Jupyter notebook ouputs table and html

224 views Asked by At

I am using IRuby kernel with Jupyter Notebooks on Windows.

I have unexpected behaviour when using the IRuby table display functionality.

The following code is supposed to display a table of the array created:

arr = "123456789".chars().each_slice(3).to_a()
IRuby.display IRuby.table(arr)

It displays the table as expected below the input box. The problem is it also shows the generated HTML in the output box.

["display_data", "<IDS|MSG>", "19980fc78ddf9fb5a1bc54ee7697822b5012afe6056940c6f481f9c2dfe81b2c", "{\"msg_type\":\"display_data\",\"msg_id\":\"a3572ae1-7019-4dba-85ce-f300767af580\",\"username\":\"kernel\",\"session\":\"1aea1761-976a-46a6-964c-85cada3adcc5\",\"version\":\"5.0\"}", "{\"msg_id\":\"09be08ecee814a2cab83f072d39b0cf5\",\"username\":\"username\",\"session\":\"741cfea13df54fd48739951832ccc2bf\",\"msg_type\":\"execute_request\",\"version\":\"5.2\",\"date\":\"2020-02-12T08:02:31.771365Z\"}", "{}", "{\"data\":{\"text/plain\":\"\\\"<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr><tr><td>7</td><td>8</td><td>9</td></tr></table>\\\"\",\"text/html\":\"<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr><tr><td>7</td><td>8</td><td>9</td></tr></table>\"},\"metadata\":{}}"]

This also happens when I run the example code locally.

The ruby part was installed via https://rubyinstaller.org/ and Jupyter via Anaconda.

1

There are 1 answers

0
Gerhard On BEST ANSWER

By adding nil to the end of the cell as the cell return value it is possible to suppress the HTML output:

arr = "123456789".chars.each_slice(3).to_a
IRuby.display IRuby.table(arr)
nil

Not perfect but it is something.