Skip to content
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

Remove @raw html decorations if target is Jupyter notebook #222

Closed
kbarros opened this issue Aug 26, 2023 · 2 comments
Closed

Remove @raw html decorations if target is Jupyter notebook #222

kbarros opened this issue Aug 26, 2023 · 2 comments

Comments

@kbarros
Copy link
Contributor

kbarros commented Aug 26, 2023

In the context of a notebook output, Literate has the helpful behavior that

```math
\int f dx
```

is replaced with

$$
\int f dx
$$

Please consider an additional transformation where

```@raw html
  <tag> ... </tag>
```

is replaced with just the raw HTML:

  <tag> ... </tag>

It appears that Jupyter notebooks follow a Markdown variant where inline HTML tags are explicitly supported: https://daringfireball.net/projects/markdown/syntax#html

@kbarros kbarros changed the title Jupyter notebook output can remove @raw html escaping Remove @raw html decorations if target is Jupyter notebook Aug 27, 2023
@fredrikekre
Copy link
Owner

fredrikekre commented Aug 27, 2023

I don't see the connection between that link and Jupyters markdown syntax?

Anyway, this would simply require another regex here:

Literate.jl/src/Literate.jl

Lines 184 to 185 in d59c8c1

# Replace Markdown stdlib math environments
push!(repls, r"```math(.*?)```"s => s"$$\1$$")
. Do you want to make PR?

@kbarros
Copy link
Contributor Author

kbarros commented Aug 27, 2023

Thanks for the link. I will make a PR.

For future reference, this link discusses the Markdown allowed in a Jupyter notebook: https://nbformat.readthedocs.io/en/latest/markup.html#what-flavor-of-markdown-does-the-notebook-format-support

Most Jupyter Notebook interfaces use the marked.js JavaScript library for rendering markdown. This supports [CommonMark and GitHub flavored Markdown].

Both of these specifications seem to follow the guidelines in the Gruber link, e.g., allow direct inlining of HTML tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants