Provide a toggle to allow $ symbols to be treated as text

Use case or problem

Text that contains multiple dollar signs interpret the material between as MathJax by default, and style them distractingly in edit mode.

The result is that text referring to financial matters is has chunks that are highlighted inappropriately in edit mode. Moreover, this treatment appears inconsistent, presumably because of the vagaries of MathJax syntax. This text (from a Congressional Budget Office web page):

The federal budget deficit was $1,048 billion in the first five months of fiscal year 2021, the Congressional Budget Office estimates—$423 billion more than the deficit recorded during the same period last year. Outlays were 25 percent higher and revenues were 5 percent higher from October through February than during the same period in fiscal year 2020.

Outlays during the first five months of fiscal year 2020 were boosted by shifts in the timing of certain payments that otherwise would have been due at the beginning of March 2020, which fell on a weekend. Those shifts increased outlays through February 2020 by $52 billion. If not for those shifts, the deficit this year (through February 2021) would have been $476 billion more than in the same period in fiscal year 2020. Three-quarters of that difference is the result of three types of spending in response to the coronavirus pandemic—unemployment compensation, refundable tax credits (consisting of the recovery rebates, the earned income tax credit, and the child tax credit), and the Small Business Administration’s Paycheck Protection Program.

Renders as follows in the help vault in edit mode:

Note that in the first paragraph, text between $ symbols is highlighted as MathJax, while text between $ symbols in the second paragraph is not. If you add a = in front of the $ in “$486 billion” in the second paragraph, the text before that and after the $ in “$52 billion” is highlighted.

This is what I mean by inconsistent. I don’t know enough about MathJax to understand what Obsidian is doing, but from this bug-graveyard post it looks like this is intentional behavior.

As @davecan noted in that post, it seems likely that more people will use a $ as a currency indicator, potentially multiple times in a block of text, than will use MathJax.

Proposed solution

Providing a setting to determine the default behavior — rendering MathJax or not — seems like a sensible approach.

A per-note override, e.g. in YAML front-matter, could help those who sometimes use MathJax and sometimes don’t.

Current workaround (optional)

Each $ symbol can be manually escaped as so: \$, but this is pretty labor-intensive and undermines the readability of the text, and makes it more difficult to use in other contexts.

Related feature requests (optional)

As noted Using multiple dollar signs in edit mode results in MathJax styling inappropriately - Bug graveyard - Obsidian Forum raised this as a bug. Given that it seems to have been rejected as something worth fixing as a bug, perhaps an alternative default can be implemented as a feature.

1 Like

You can escape it using \$.

Yes. I mentioned that under workarounds.

But it reduces readability — a core reason for using Markdown in the first place — and portability as well.

Edit: In general, it seems to me that the departure from the core Markdown syntax should be the exception; if it interferes with readability, it should be optional.

And I say that as an avid user of MultiMarkdown, which has a lot of features not included in Obsidian-flavored markdown.

1 Like

Another issue that emerges from this is code blocks being broken upon saving.

After reading an article I wanted to retain a specific SQL code block and added this:

CREATE FUNCTION deleted_record_insert() RETURNS trigger
  LANGUAGE plpgsql
AS $$
  BEGIN
    EXECUTE 'INSERT INTO deleted_record (data, object_id, table_name) VALUES ($1, $2, $3)'
      USING to_jsonb(OLD.*), OLD.id, TG_TABLE_NAME;
    RETURN OLD;
  END;
$$;

Sadly, every time it saves, the double $$ is transformed to a single $. Sure you can escape with \$\$ but it remains in view-mode resulting in a code-block you can’t copy-paste.