cs3110 / textbook

The CS 3110 Textbook, "OCaml Programming: Correct + Efficient + Beautiful"
Other
740 stars 134 forks source link

Issue on page /chapters/hop/currying.html : Improper Highlighting with single quotes #48

Closed nbfields closed 2 years ago

nbfields commented 2 years ago

This issue appears in a few places in the book that I have noticed so far (the page on map has this as well). When the single tick/single quote character ' is used, it messes up the highlighting of either the rest of the line, or until an ensuing ' character appears, whichever comes first.

On the currying page, for instance (bolds indicate where the error occurs):

let add' t = fst t + snd t

Everything after the ' in add' is highlighted light blue. On the page for Map (https://cs3110.github.io/textbook/chapters/hop/map.html) we see this here:

let rec add1' f = function | [] -> [] | h :: t -> f h :: add1' f t

(* [add1 lst] adds 1 to each element of [lst] ) let add1 = add1' (fun x -> x + 1)

let rec concat_bang' f = function | [] -> [] | h :: t -> f h :: concat_bang' f t

(* [concat_bang lst] concatenates "!" to each element of [lst] ) let concat_bang = concat_bang' (fun x -> x ^ "!")

The error is relatively minor in the grand scheme of things, but while reading I did find myself pausing and trying for a couple minutes to figure it out before I realized it was simply a highlighting error.

Possible solutions: (0) Changing the way the code is highlighted (1) Changing the name of these functions so that the single tick character is not used (2) Something else unknown to me

clarksmr commented 2 years ago

I can confirm that I observed that behavior on the website. This is a new error. It didn't exist last semester. I tried rebuilding and redeploying the book. The error went away.

My hypothesis is that @jnfoster might not have a recent enough version of Pygments (the syntax highlighter) on his build machine -- though certainly there are other possibilities. I currently have 2.9.0 installed.

jnfoster commented 2 years ago

Whew! Thanks for tracking this down.

Though, perhaps I have a too-recent version?

Pygments                      2.11.2
clarksmr commented 2 years ago

Hm, I just updated to 2.11.2 and rebuilt. The highlighting was fine. So that's not the problem...

clarksmr commented 2 years ago

IDK if this helps but here are all my installed packages.

❯ conda list
# packages in environment at /Users/clarkson/opt/miniconda3/envs/textbook2:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                     py_0    conda-forge
anyio                     3.5.0            py39h6e9494a_0    conda-forge
appnope                   0.1.2            py39h6e9494a_2    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0           py39h89e85a6_1    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.10.0             pyha770c72_0    conda-forge
black                     21.12b0            pyhd8ed1ab_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py39h89e85a6_1003    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
ca-certificates           2021.10.8            h033912b_0    conda-forge
certifi                   2021.10.8        py39h6e9494a_1    conda-forge
cffi                      1.15.0           py39he338e87_0    conda-forge
charset-normalizer        2.0.11             pyhd8ed1ab_0    conda-forge
click                     7.1.2              pyh9f0ad1d_0    conda-forge
click-completion          0.5.2            py39h6e9494a_3    conda-forge
click-log                 0.3.2              pyh9f0ad1d_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cryptography              36.0.1           py39h209aa08_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
debugpy                   1.5.1            py39h9fcab8e_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
docutils                  0.16             py39h6e9494a_3    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
executing                 0.8.2              pyhd8ed1ab_0    conda-forge
flit-core                 3.6.0              pyhd8ed1ab_0    conda-forge
ghp-import                2.0.2              pyhd8ed1ab_0    conda-forge
gitdb                     4.0.9              pyhd8ed1ab_0    conda-forge
gitpython                 3.1.26             pyhd8ed1ab_0    conda-forge
greenlet                  1.1.2            py39h9fcab8e_1    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
imagesize                 1.3.0              pyhd8ed1ab_0    conda-forge
importlib-metadata        4.10.1           py39h6e9494a_0    conda-forge
importlib-resources       3.3.1              pyhd8ed1ab_0    conda-forge
importlib_resources       5.4.0              pyhd8ed1ab_0    conda-forge
ipykernel                 6.7.0            py39h71a6800_0    conda-forge
ipython                   8.0.1            py39h6e9494a_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.5              pyhd8ed1ab_0    conda-forge
jedi                      0.18.1           py39h6e9494a_0    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
jupyter-book              0.12.1             pyhd8ed1ab_0    conda-forge
jupyter-cache             0.4.3              pyhd8ed1ab_0    conda-forge
jupyter-server-mathjax    0.2.3              pyhd8ed1ab_0    conda-forge
jupyter-sphinx            0.3.2              pyhd8ed1ab_1    conda-forge
jupyter_client            7.1.2              pyhd8ed1ab_0    conda-forge
jupyter_core              4.9.1            py39h6e9494a_1    conda-forge
jupyter_server            1.13.4             pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.2              pyhd8ed1ab_0    conda-forge
jupytext                  1.11.5             pyh6002c4b_0    conda-forge
latexcodec                2.0.1              pyh9f0ad1d_0    conda-forge
libcxx                    12.0.1               habf9029_1    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libsodium                 1.0.18               hbcb3906_1    conda-forge
libzlib                   1.2.11            h9173be1_1013    conda-forge
linkify-it-py             1.0.3              pyhd8ed1ab_0    conda-forge
markdown-it-py            1.1.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.0.1            py39h89e85a6_1    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mdit-py-plugins           0.2.8              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py39h89e85a6_1005    conda-forge
mypy_extensions           0.4.3            py39h6e9494a_4    conda-forge
myst-nb                   0.13.1             pyhd8ed1ab_0    conda-forge
myst-parser               0.15.2             pyhd8ed1ab_0    conda-forge
nbclient                  0.5.10             pyhd8ed1ab_1    conda-forge
nbconvert                 6.4.1            py39h6e9494a_0    conda-forge
nbdime                    3.1.1              pyhd8ed1ab_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  he49afe7_0    conda-forge
nest-asyncio              1.5.4              pyhd8ed1ab_0    conda-forge
notebook                  6.4.8              pyha770c72_0    conda-forge
openssl                   1.1.1l               h0d85af4_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandoc                    2.17.1.1             h694c41f_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       22.0.2             pyhd8ed1ab_0    conda-forge
platformdirs              2.3.0              pyhd8ed1ab_0    conda-forge
prometheus_client         0.13.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.26             pyha770c72_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pybtex                    0.24.0             pyhd8ed1ab_2    conda-forge
pybtex-docutils           1.0.1            py39h6e9494a_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydata-sphinx-theme       0.7.2              pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyrsistent                0.18.1           py39h89e85a6_0    conda-forge
pysocks                   1.7.1            py39h6e9494a_4    conda-forge
python                    3.9.10          h1dd9edd_1_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.3             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0              py39h89e85a6_3    conda-forge
pyzmq                     22.3.0           py39h7fec2f1_1    conda-forge
readline                  8.1                  h05e3726_0    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                60.6.0           py39h6e9494a_0    conda-forge
shellingham               1.4.0              pyh44b312d_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
smmap                     3.0.5              pyh44b312d_0    conda-forge
sniffio                   1.2.0            py39h6e9494a_2    conda-forge
snowballstemmer           2.2.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sphinx                    4.4.0              pyh6c4a22f_1    conda-forge
sphinx-book-theme         0.1.10             pyhd8ed1ab_0    conda-forge
sphinx-comments           0.0.3              pyh9f0ad1d_0    conda-forge
sphinx-copybutton         0.4.0              pyhd8ed1ab_0    conda-forge
sphinx-external-toc       0.2.3              pyhd8ed1ab_0    conda-forge
sphinx-jupyterbook-latex  0.4.6              pyhd8ed1ab_0    conda-forge
sphinx-multitoc-numbering 0.1.3              pyhd8ed1ab_0    conda-forge
sphinx-panels             0.6.0              pyhd8ed1ab_0    conda-forge
sphinx-thebe              0.0.10             pyhd8ed1ab_0    conda-forge
sphinx-togglebutton       0.2.3              pyhd3deb0d_0    conda-forge
sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
sphinxcontrib-bibtex      2.2.1              pyhd8ed1ab_0    conda-forge
sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_0    conda-forge
sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
sphinxcontrib-serializinghtml 1.1.5              pyhd8ed1ab_1    conda-forge
sqlalchemy                1.4.31           py39h89e85a6_0    conda-forge
sqlite                    3.37.0               h23a322b_0    conda-forge
stack_data                0.1.4              pyhd8ed1ab_0    conda-forge
terminado                 0.13.1           py39h6e9494a_0    conda-forge
testpath                  0.5.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.11               h5dbffcc_1    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     1.2.2              pyhd8ed1ab_0    conda-forge
tornado                   6.1              py39h89e85a6_2    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
typed-ast                 1.5.2            py39h89e85a6_0    conda-forge
typing_extensions         4.0.1              pyha770c72_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
uc-micro-py               1.0.1              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.8             pyhd8ed1ab_1    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.2.3              pyhd8ed1ab_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.5.2            py39h6e9494a_1    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
yaml                      0.2.5                h0d85af4_2    conda-forge
zeromq                    4.3.4                he49afe7_1    conda-forge
zipp                      3.7.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h9173be1_1013    conda-forge
jnfoster commented 2 years ago

I'm afraid I never tracked this down. @clarksmr when you re-build with your sertup, I assume it will be fixed. Can we close?

clarksmr commented 2 years ago

Yes, we can close.