joostkremers / pandoc-mode

An Emacs minor mode for interacting with Pandoc.
https://joostkremers.github.io/pandoc-mode/
174 stars 14 forks source link

Syntax Highlighting in Footnotes #105

Open RobertGoulding opened 3 years ago

RobertGoulding commented 3 years ago

When using pandoc-mode with markdown-mode, the syntax highlighting in footnotes gets messed up if there are citations there. It seems that the regexps for identifying citations are too greedy, and they also take in the footnote marker. Here is an example:

Screenshot 2021-03-16 11 56 54 AM

And now with pandoc-mode disabled:

Screenshot 2021-03-16 11 58 24 AM

joostkremers commented 3 years ago

Yes, the regexes seem to be wrong... Not just because they're too greedy, BTW. I'll have to look into this more closely.

Thanks for pointing this out.

joostkremers commented 3 years ago

The commit I just pushed is the best fix I can provide right now. It basically reduces fontification of citations to just the key. Fontifying the entire citation turned out to be problematic in the case of multiple citations (separated with ;). Details are in the commit message.

I may revisit the issue some time in the future, but for now I think it's best to just fontify the citation key, so that citations don't fontify the entire footnote.

RobertGoulding commented 3 years ago

This is still not quite working. Footnotes that have no citations in them are highlighted following markdown-mode. But footnotes WITH citations are not highlighted at all -- except for the citations.

Robert Goulding Sent from my Google Pixel 4

On Wed, Mar 17, 2021, 1:19 PM Joost Kremers @.***> wrote:

The commit I just pushed is the best fix I can provide right now. It basically reduces fontification of citations to just the key. Fontifying the entire citation turned out to be problematic in the case of multiple citations (separated with ;). Details are in the commit message.

I may revisit the issue some time in the future, but for now I think it's best to just fontify the citation key, so that citations don't fontify the entire footnote.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joostkremers/pandoc-mode/issues/105#issuecomment-801263616, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNDSDQSWY6EN4VD63EZTS3TEDQCFANCNFSM4ZI2TXGA .

RobertGoulding commented 3 years ago

Also, this now messes up some references with hyphens in them. So, my pandoc-crossref references such as @.***:kepler-simplified] are only highlighted up to (but not including) the hyphen.

On Wed, Mar 17, 2021 at 6:41 PM Robert Goulding @.***> wrote:

This is still not quite working. Footnotes that have no citations in them are highlighted following markdown-mode. But footnotes WITH citations are not highlighted at all -- except for the citations.

Robert Goulding Sent from my Google Pixel 4

On Wed, Mar 17, 2021, 1:19 PM Joost Kremers @.***> wrote:

The commit I just pushed is the best fix I can provide right now. It basically reduces fontification of citations to just the key. Fontifying the entire citation turned out to be problematic in the case of multiple citations (separated with ;). Details are in the commit message.

I may revisit the issue some time in the future, but for now I think it's best to just fontify the citation key, so that citations don't fontify the entire footnote.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joostkremers/pandoc-mode/issues/105#issuecomment-801263616, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNDSDQSWY6EN4VD63EZTS3TEDQCFANCNFSM4ZI2TXGA .

-- Robert Goulding Director, John J. Reilly Center for Science, Technology, and Values; Director, Program in History and Philosophy of Science; Assoc. Professor, Program of Liberal Studies, Fellow, Medieval Institute, University of Notre Dame.

joostkremers commented 3 years ago

Also, this now messes up some references with hyphens in them. So, my pandoc-crossref references such as @.***:kepler-simplified] are only highlighted up to (but not including) the hyphen.

That was due to an error in my regex. Should be fixed now.

joostkremers commented 3 years ago

This is still not quite working. Footnotes that have no citations in them are highlighted following markdown-mode. But footnotes WITH citations are not highlighted at all -- except for the citations. Robert Goulding Sent from my Google Pixel 4

Thanks for pointing that out. I tweaked the code a bit and now it appears to be working.

RobertGoulding commented 3 years ago

This all seems to work perfectly now - thank you!

On Wed, Mar 17, 2021 at 7:44 PM Joost Kremers @.***> wrote:

This is still not quite working. Footnotes that have no citations in them are highlighted following markdown-mode. But footnotes WITH citations are not highlighted at all -- except for the citations. Robert Goulding Sent from my Google Pixel 4

Thanks for pointing that out. I tweaked the code a bit and now it appears to be working.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joostkremers/pandoc-mode/issues/105#issuecomment-801512950, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNDSDTZSQZVIWI3XOQIXKTTEE5GXANCNFSM4ZI2TXGA .

-- Robert Goulding Director, John J. Reilly Center for Science, Technology, and Values; Director, Program in History and Philosophy of Science; Assoc. Professor, Program of Liberal Studies, Fellow, Medieval Institute, University of Notre Dame.