tianlinhe
tianlinhe

Reputation: 989

Display pipe in table in jupyter notebook on Github

I uploaded a table in a Jupyter notebook (ipynb file). The table contains some pipes '|', and it is in a markdown-formatted cell of course. It looks normal on my local Jupyter notebook:

enter image description here

The codes for the table are:

||**hash table**|**direct-address table**|
|:-|:--------------:|:------------------------:|
|Storage requirement|$\Theta(|K|)$|$|U|$|
|Search time| $O(1)$ time for *average-case*|$O(1)$ time for *worst-case*|
|Location of an element with key $k$|slot $h(k)$|slot $k$|

However, it seems to be a problem when I open it after uploading to Github (I suspect errors with the '|' symbol):

enter image description here

The center alignment also failed.

I apologise if the question has been asked before, but I tried other answers on SO: escape-pipe. Unfortunately, the \| they recommended did not work. The link to the GitHub page is: this one, where you can see the edited full codes.

Could anyone help? I am rather new in Github and Markdown.

Upvotes: 2

Views: 421

Answers (2)

TheUnch0senOne
TheUnch0senOne

Reputation: 40

I saw the linked answer on the question, the answer in the linked question is incorrect, look at the comments there!

As of March 2019, in Gitlab Wikis, you still need to use "|" inside the markup code. – knb Mar 22 '19 at 13:52

You should use |.

If you do not like the jumble of characters, use this!

(Although it technically is a different character, you can still use it! [Its width is higher because it is a full-width character.])

Full-width character: enter in your keyboard, and it shows . (note the extra width as a different character)
Normal pipe: enter |, and this shows |, live  example:"|".

Recommendation:

You should use the | method, as the character is exactly the same as you wanted, and not a different variant of the character.

Upvotes: 1

TheUnch0senOne
TheUnch0senOne

Reputation: 40

On the Alignment of the text in the table:

I personally think that is impossible:

Well, the problem is on Github and Html5 itself. Github doesn't allow ANY style OR script, so editing the page with DOM, or using style is no use.

Html5 does not support the align attribute OR the center tag. And Github has a bad bug in it's ipynb rendering engine, so be ready to say bye bye to aligning text in iphnb files!

Also take a look on this github issue which hints that using ipynb files on github are not as good as you think!

Upvotes: 1

Related Questions