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

Embedded code has extra characters near dollar signs #244

Open
mfp22 opened this issue Jul 18, 2023 · 4 comments
Open

Embedded code has extra characters near dollar signs #244

mfp22 opened this issue Jul 18, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@mfp22
Copy link

mfp22 commented Jul 18, 2023

Describe the bug

I want to embed a code snippet from another file into a slide. It adds extra ticks `" near dollar signs $.

Samples to Reproduce

Try to embed this code snippet into a slide:

export class CounterService {
  count$ = new BehaviorSubject(1000);

  double$ = this.count$.pipe(map((count) => count * 2));
  triple$ = this.count$.pipe(map((count) => count * 3));

  combined$ = combineLatest([this.double$, this.triple$]).pipe(
    map(([double, triple]) => double + triple)
  );

  over9000$ = this.combined$.pipe(map((combined) => combined > 9000));

  message$ = this.over9000$.pipe(
    map((over9000) => (over9000 ? "It's over 9000!" : "It's under 9000."))
  );
}

And it shows up exactly like this instead:

export class CounterService {
  count$ = new BehaviorSubject(1000);

  double`$ = this.count$`.pipe(map((count) => count * 2));
  triple`$ = this.count$`.pipe(map((count) => count * 3));

  combined`$ = combineLatest([this.double$`, this.triple$]).pipe(
    map(([double, triple]) => double + triple)
  );

  over9000`$ = this.combined$`.pipe(map((combined) => combined > 9000));

  message`$ = this.over9000$`.pipe(
    map((over9000) => (over9000 ? "It's over 9000!" : "It's under 9000."))
  );
}

Expected behavior
The embedded code should appear exactly the same in the slide

@mfp22 mfp22 added the bug Something isn't working label Jul 18, 2023
@mfp22
Copy link
Author

mfp22 commented Jul 18, 2023

Actually this happens for any code snippet in a slide. No need to embed to reproduce issue.

@booxter
Copy link

booxter commented Nov 22, 2023

In my testing, it looks like a single dollar sign per line is ok, backticks are added once the line has more than two dollars.

@jojonas
Copy link

jojonas commented Apr 8, 2024

This bug affects me too, that's why I investigated some more...

The error is in this line:

line = line.replaceAll(this.singleLine, '`$$$1$$`');

The LatexProcessor changes the content of any line containing a $ according to this regular expression: /\$(.*?)\$/g is replaced with '$$$1$$', for example foo $bar$ baz turns into foo '$bar$' baz (in the replacement pattern, $$ is the escaped version of $) . This code exists to support LaTeX math expressions in markdown, e.g.:

The circumference of a circle is $2\pi$.

But this is of course not intended within code blocks.

There used to be a (incorrect?) fix: 0e9af62, which the author promptly reverted: 6ef4847.

@tibomogul
Copy link

Pull request for a fix #315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants