Skip to content

Add match group to conceal \$ #280

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

Merged
merged 2 commits into from
May 16, 2019
Merged

Conversation

jez
Copy link
Contributor

@jez jez commented May 6, 2019

When working on pandoc markdown documents that deal a lot with money, I get a
bunch of lines that look like

- \$20

which is somewhat annoying to look at. This patch sets up a conceal character
so that \$ conceals as $:

- $20

Commit summary

Review by commit.

  • Add match group to conceal $ (fc2be56)

    This is the commit that actually introduces the new behavior.

  • Equate pandocLaTeXInlineMath contains with pandocEscapedDollar (2701ab7)

    This change just propagates the pandocEscapedDollar to work in every context
    where pandocLaTeXInlineMath already works.

@alerque
Copy link
Member

alerque commented May 6, 2019

Have you considered disabling Pandoc's tex_math_dollars extension for your workflow? It sounds like you probably don't want it at all (unless you happen to be using lots of financial stuff and TeX math at the same time.

$ pandoc -t markdown <<< '$30'
\$30

$ pandoc -t markdown-tex_math_dollars <<< '$30'
$30

I'm not saying that invalidates this PR, just that there might be an even better solution if you don't need math.

@jez
Copy link
Contributor Author

jez commented May 15, 2019

Thanks for the heads up. Your proposed solution doesn’t solve the issue I’m having: I find myself escaping the dollar because otherwise my entire Markdown file is mis-highlighted. As far as I can tell from skimming the docs (and reading the source) there’s no way to tell vim-pandoc-syntax to highlight a buffer assuming that I’ll be running under -f markdown-tex_math_dollars, so escaping the dollar is the only way to get useful syntax highlighting right now.

@alerque
Copy link
Member

alerque commented May 15, 2019

It looks like Pandoc has logic to avoid needing to escape dollar signs when used for dollar values by looking at the context and guessing. Furthermore it looks sounds like some attempt was made to support this already in our syntax patterns (see tests/latex.pdc and comments on commit 56e8e41), but that it is evidently not guessing properly any more. It looks to me like you shouldn't need the escape at all and that a conceal shouldn't be necessary if following Pandoc's default behavior is our benchmark.

I'm not saying we couldn't also have a conceal option, but their is bug in here too.

@alerque
Copy link
Member

alerque commented May 16, 2019

Thanks for the contribution @jez. I've been mulling this over and poking at it a little and think that while we should actually have a proper fix for this (vis-à-vis the issue I just opened) I couldn't come up with a compelling reason to not offer a conceal for the cases where it does get used (and without expressly adding an extension the default output format of Pandoc does use the escape).

Hence I'm going to merge this and we can work on fixing the other problem separately.

@alerque alerque merged commit cc628e6 into vim-pandoc:master May 16, 2019
@jez jez deleted the jez-escaped-dollar branch May 21, 2019 06:39
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

Successfully merging this pull request may close these issues.

2 participants