CLJS: inline formula ends at a line break

Open Beginner friendly
#76 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
87/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
clojure
Domain
backend

Research direction

Start with the math_inline regex in src/js/markdown-it-texmath.js and the inline-formula-delimiters-test. The issue provides the failing CLJS input and expected parse; first check how the dollars rule handles line breaks and how the JVM-only test is set up. Update the regex and make that case shared, then confirm CLJS parses one formula across the line break.

Written by the indexing model from the issue text.

Description

On CLJS a $...$ formula ends at a line break. A hard-wrapped paragraph that breaks inside a formula shows the dollars as text. The JVM and Pandoc parse one formula:

(md/parse "a $x\ny$ b")
;; JVM:    [:text "a "] [:formula "x\ny"] [:text " b"]
;; CLJS:   [:text "a $x"] [:softbreak] [:text "y$ b"]
;; Pandoc: Math InlineMath "x y"

Clerk notebooks rely on this on the JVM, for example src/emmy/dual.cljc in mentat-collective/emmy, which breaks $i^2 = and -1$ over two lines.

The math_inline regex of the dollars rules in src/js/markdown-it-texmath.js uses .*?, which does not match \n. Use [\s\S]*? and make the JVM-only case in inline-formula-delimiters-test a shared test.

Dominant language
Clojure
Stars
100
Forks
11
Avg merge
2h 3m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextjournal/markdown

All issues in nextjournal/markdown

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.