-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python-markdown new install fails to render {{var}}. Browser error 'TypeError: marked is not a function ' #1638
Comments
Looks like the fail is here: So the 'marked is not a function' error is symptom, not a cause. The entry in |
This is due to changes in the notebook main code itself. The "marked" library is no longer included there.
|
Thanks. Do you have any posts on the nbextensions transition?
I have to say that the choice between no extensions (all disabled by
default) and extensions that just fail makes the platform very
unattractive. I would have expected a "stable" distribution with old
extensions and a "beta" distribution for transitions.
…On Sun, May 7, 2023 at 1:05 PM Juergen Hasch ***@***.***> wrote:
This is due to changes in the notebook main code itself. The "marked"
library is no longer included there.
It can be fixed, but it is a little bit tricky. In case you want to try:
1. Download the marked.js file from https://cdnjs.com/libraries/marked
and copy it to the python-markdown extension directory
2. Replace 'components/marked/lib/marked',with
nbextensions/python-markdown/marked.min',
3. Replace all calls to marked(...) by marked.marked(...) calls in
main.js of the extension.
—
Reply to this email directly, view it on GitHub
<#1638 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABSGATYIWR25LZNZFSBVBDXE76BLANCNFSM6AAAAAAXYPZHOY>
.
You are receiving this because you authored the thread.Message ID:
<ipython-contrib/jupyter_contrib_nbextensions/issues/1638/1537529703@
github.com>
|
In v6 jupyter notebook components/marked/lib/marked no longer exists. The extension silently falls over. Hack around puts local copy of marked.min from cdnjs.com into the python-markdown directory. See Issue ipython-contrib#1638
Ok I cloned the repo and edited per your instructions. Where might I ask about dev setup issues? Is committing marked.min to python-markdown/ in the plan for v6+? Maybe the two different marked libs could both be required and have a runtime test/fallback? |
I accidently noticed that on the nbextensions_configurator tab there was an info panel: "This nbextension's require url (python-markdown/main) is referenced by two different yaml files on the server." The server log confirms that this duplicate issue. I don't recognize either path however, eg There must be some server config that points now to two roots for nbextensions. |
Using this hint |
Unfortunately I succeeded by dumb luck. I made more edits and these do not appear in the app. I tried various uninstall/install commands but no dice. It seems as if the app runs off stuff in AppData rather than my git repo directly. Some command must copy files into the AppData. The command |
…h fallback for v<6 In v6 jupyter notebook components/marked/lib/marked no longer exists. The extension silently falls over. Hack around puts local copy of marked.min from cdnjs.com into the python-markdown directory. require 'marked' on two paths, first expecting marked.min.j in the same dir, second expecting marked in the v6 compenents/ location. Insert ERROR message in user page if neither is found.
My fix is in #1639 |
…d.js In v6 jupyter notebook components/marked/lib/marked no longer exists. The extension silently falls over. Add https://cdnjs.com/libraries/marked for local loading into the python-markdown directory. Change required path and calls marked -> marked.marked. Add 6.x to yaml compat setting
Any update on this? I am having the same issues outputting just the example'a = 1.23' '{{a}}' in the extensions documentation. |
@bradenmitchell I don't know if it is useful, but I can confirm that @johnjbarton's patches work, at least for me. You should be able to use them, instead of the default Jupyter notebook extensions, by running:
(Probably best to do so in a venv.) I've also got a small docker-compose example demonstrating them - details below. docker-compose example of johnjbarton's patches in useDockerfile: FROM jupyter/base-notebook:notebook-6.5.4
USER root
RUN \
apt-get update && \
apt-get --no-install-recommends install -yq \
git
USER jovyan
# (not sure if ipykernel need to be upgraded, but some posts
# on this bug thread report it might)
RUN \
pip install --no-cache-dir --user --upgrade \
ipykernel \
'git+https://github.com/johnjbarton/jupyter_contrib_nbextensions.git@84aeb3b0c9880d47c562d80d5155fb87caaecac2'
# also, jupyter_lsp seems not to work and throws errors on server
# startup, so we disable it.
RUN \
export PATH=$HOME/.local/bin:$PATH \
&& jupyter contrib nbextension install --user \
&& jupyter nbclassic-extension enable python-markdown/main --user \
&& jupyter serverextension disable jupyter_lsp \
&& fix-permissions "${CONDA_DIR}" \
&& fix-permissions "/home/${NB_USER}"
RUN \
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc docker-compose.yml: version: '3'
services:
jupyter:
build: .
ports:
- "8888:8888"
volumes:
- ".:/home/jovyan/work"
environment:
- "DOCKER_STACKS_JUPYTER_CMD=notebook" mynotebook.ipynb: {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "30e30612",
"metadata": {},
"outputs": [],
"source": [
"x = \"some value\""
]
},
{
"cell_type": "markdown",
"id": "d20c6c3a",
"metadata": {
"variables": {
"repr(x)": ""'some value'""
}
},
"source": [
"The value of x is {{repr(x)}}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22f26b7d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
} To use this example, run @juhasch or other maintainers - are the patches suggested by johnjbarton likely to be incorporated into the repo, thus fixing this bug? |
(New user here)
python-markdown seems like a killer feature... but rendering python silently fails for me.
I assume this is some config/install issue. I've not found any debug procedure or hints.
In the browser debugger I see 'TypeError: marked is not a function '. That seems bad ;-)
markdown does render otherwise, just the variable interpolation fails. The double braces and the var are missing:
Davidson Gemer electron velocity {{ dg_electron_velocity }} kg/sec and wavelength {{ dg_wavelength }}
becomes
Davidson Gemer electron velocity kg/sec and wavelength
The text was updated successfully, but these errors were encountered: