jupyterhub / the-littlest-jupyterhub

Simple JupyterHub distribution for 1-100 users on a single server
https://tljh.jupyter.org
BSD 3-Clause "New" or "Revised" License
1.01k stars 341 forks source link

Markdown formatting erratic if carriage return characters are present (eg via paste on Windows) #947

Closed cmichal2 closed 5 months ago

cmichal2 commented 9 months ago

Bug description

If multiline text is copied in to a markdown cell (on Windows), the copy/paste produces line endings of \r\n. With further editing of the markdown, sometimes the \r and \n can become separated and then cause very strange formatting effects.

How to reproduce

  1. Open a fresh python 3 notebook in tlhj

  2. create a cell, change type to markdown

  3. Open a blank document in Notepad on windows

  4. enter four lines: Line 1 Line 2 Line 3 Line 4

  5. Then select all lines with CTRL-A, copy with CTRL-C

  6. Paste into the markdown cell with CTRL-V

  7. Position cursor after the 2, and use the delete key to put Line 2 and Line 3 on the same line.

  8. Use Shift-Enter to format the text.

  9. Notice that the 2 is missing, even though if you double click to edit the markdown, it remains present.

Some really strange things can then happen with further editing of these lines, where bits of text get moved around to the wrong line or disappear altogether. If you save the notebook and then revert to the saved version, the errors become permanent.

Expected behaviour

Was expecting output of: Line 1 Line 2 Line 3 Line 4

Actual behaviour

Found: Line 1 Line Line 3 Line 4

Your personal set up

Distribution: the-littlest-jupyterhub, installed Oct 13.

# paste output of `pip freeze` or `conda list` here

alembic==1.12.0
anyio==4.0.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.0
async-generator==1.10
async-lru==2.0.4
attrs==23.1.0
Babel==2.13.0
backcall==0.2.0
beautifulsoup4==4.12.2
bleach==6.1.0
bqplot==0.12.40
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1666764671472/work
certifi==2022.12.7
certipy==0.1.3
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1671179353105/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1678108872112/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work
comm==0.1.4
conda==23.1.0
conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1669907009957/work
conda_package_streaming @ file:///home/conda/feedstock_root/build_artifacts/conda-package-streaming_1669733752472/work
contourpy==1.1.1
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1679811212387/work
cycler==0.12.1
data-entry2==0.1.7
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
exceptiongroup==1.1.3
executing==2.0.0
fastjsonschema==2.18.1
fonttools==4.43.1
fqdn==1.5.1
gast==0.4.0
greenlet==3.0.0
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1663625384323/work
ipydatagrid==1.1.16
ipykernel==6.25.2
ipython==8.16.1
ipywidgets==8.1.1
isoduration==20.11.0
jedi==0.19.1
Jinja2==3.1.2
json5==0.9.14
jsonpointer==2.4
jsonschema==4.19.1
jsonschema-specifications==2023.7.1
jupyter-events==0.7.0
jupyter-lsp==2.2.0
jupyter-resource-usage==1.0.1
jupyter-telemetry==0.1.0
jupyter_client==8.4.0
jupyter_core==5.4.0
jupyter_server==2.7.3
jupyter_server_terminals==0.4.4
jupyterhub==4.0.2
jupyterlab==4.0.7
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.9
jupyterlab_server==2.25.0
kiwisolver==1.4.5
libmambapy @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1680002410624/work/libmambapy
Mako==1.2.4
mamba @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1680002410624/work/mamba
MarkupSafe==2.1.3
matplotlib==3.8.0
matplotlib-inline==0.1.6
mistune==3.0.2
nbclient==0.8.0
nbconvert==7.9.2
nbformat==5.9.2
nbgitpuller==1.2.0
nest-asyncio==1.5.8
notebook==7.0.5
notebook_shim==0.2.3
numpy==1.26.0
oauthlib==3.2.2
overrides==7.4.0
packaging==23.2
pamela==1.1.0
pandas==2.1.1
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==10.0.1
platformdirs==3.11.0
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1667232663820/work
prometheus-client==0.17.1
prompt-toolkit==3.0.39
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
py2vega==0.6.1
pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1666836542287/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
Pygments==2.16.1
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1680037383858/work
pyparsing==3.1.1
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
python-dateutil==2.8.2
python-json-logger==2.0.7
pytz==2023.3.post1
PyYAML==6.0.1
pyzmq==25.1.1
referencing==0.30.2
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.10.6
ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1678272977710/work
ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1670412719074/work
Send2Trash==1.8.2
six==1.16.0
sniffio==1.3.0
soupsieve==2.5
SQLAlchemy==2.0.22
stack-data==0.6.3
terminado==0.17.1
tinycss2==1.2.1
tomli==2.0.1
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work
tornado==6.3.3
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1677948868469/work
traitlets==5.11.2
traittypes==0.2.1
types-python-dateutil==2.8.19.14
typing_extensions==4.8.0
tzdata==2023.3
uri-template==1.3.0
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1678635778344/work
wcwidth==0.2.8
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.4
widgetsnbextension==4.0.9
zstandard==0.19.0

Configuration ```python # configuration is unedited - installed default. # jupyterhub_config.py """ JupyterHub config for the littlest jupyterhub. """ import os from glob import glob from tljh import configurer from tljh.config import CONFIG_DIR, INSTALL_PREFIX, USER_ENV_PREFIX from tljh.user_creating_spawner import UserCreatingSpawner from tljh.utils import get_plugin_manager c = get_config() # noqa c.JupyterHub.spawner_class = UserCreatingSpawner # leave users running when the Hub restarts c.JupyterHub.cleanup_servers = False # Use a high port so users can try this on machines with a JupyterHub already present c.JupyterHub.hub_port = 15001 c.TraefikProxy.should_start = False dynamic_conf_file_path = os.path.join(INSTALL_PREFIX, "state", "rules", "rules.toml") c.TraefikFileProviderProxy.dynamic_config_file = dynamic_conf_file_path c.JupyterHub.proxy_class = "traefik_file" c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, "bin")] c.SystemdSpawner.default_shell = "/bin/bash" # Drop the '-singleuser' suffix present in the default template c.SystemdSpawner.unit_name_template = "jupyter-{USERNAME}" tljh_config = configurer.load_config() configurer.apply_config(tljh_config, c) # Let TLJH hooks modify `c` if they want # Call our custom configuration plugin pm = get_plugin_manager() pm.hook.tljh_custom_jupyterhub_config(c=c) # Load arbitrary .py config files if they exist. # This is our escape hatch extra_configs = sorted(glob(os.path.join(CONFIG_DIR, "jupyterhub_config.d", "*.py"))) for ec in extra_configs: load_subconfig(ec) ```
Logs ``` # paste relevant logs here, if any I don't see any log messages that look related. The only ones that seem even remotely possibly relevant are: Oct 18 14:10:40 xxx.xxx.xxx jupyterhub-singleuser[360391]: [W 2023-10-18 14:10:40.609 JupyterNotebookApp] 'extra_template_paths' was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in NotebookApp. Please check if you should also config these traits in ServerApp for your purpose. Oct 18 14:10:40 xxx.xxx.xxx jupyterhub-singleuser[360391]: [W 2023-10-18 14:10:40.521 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server. ```
welcome[bot] commented 9 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

kiliansinger commented 5 months ago

this isse seems to be related to https://github.com/jupyterlab/jupyterlab/issues/14752 I can confirm the problem on windows with jupyterlab-desktop version 4.0.12 and latest version.

kiliansinger commented 5 months ago

i just submitted a pull request should be fixed soon on jupyterlab

cmichal2 commented 5 months ago

Fantastic, thanks! I pasted your fix to replace those line endings into the javascript on the machines I'm running - and it does look like this solves it.