Skip to content

Conversation

@goshatch
Copy link
Contributor

@goshatch goshatch commented Jan 18, 2024

Hello,

This PR adds a new lexer for the Emacs Org-Mode. It is basically a direct translation of the work done by @kaushalmodi for Go's Chroma library, which I came across in #426 (comment).

I have to say that I am familiar with neither Python nor Go; my reason for wanting this lexer is so that my forge of choice (Sourcehut) which uses pygments would syntax highlight my org files 😁

Therefore, I would like to ask for help on this PR, and I am marking it as draft. Currently, the test for the lexer is failing (I'm adding the output below). I don't know enough about the Python ecosystem to debug it myself, and I hope someone here would be able to assist.

Thank you for your consideration!

@goshatch goshatch force-pushed the master branch 2 times, most recently from 855af33 to 66e62e8 Compare January 18, 2024 21:49
@goshatch goshatch marked this pull request as ready for review January 19, 2024 11:02
@goshatch goshatch force-pushed the master branch 2 times, most recently from 755a7a7 to 66b087c Compare January 19, 2024 11:04
This is a direct translation from the work done by @kaushalmodi in
GoChroma, as per this comment:

pygments#426 (comment)

Includes improvements done to the Chroma lexer at a later date.
Comment on lines +668 to +669
# Source Code Blocks
(r'(?i)^( *#\+begin_src )([^ \n]+)(.*?\n)([\w\W]*?)(^ *#\+end_src *$)', bygroups(Comment, Comment.Special, Comment, using(this), Comment)),
Copy link
Contributor Author

@goshatch goshatch Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could certainly be improved to use the appropriate lexer to highlight the code inside the code block (like it's done in the Markdown lexer), but this is a bit beyond my expertise. I would welcome contributions.

The usual code block format is like this (lifted from my literate Emacs config):

#+begin_src emacs-lisp :tangle yes
(setq undo-limit 80000000
      evil-want-fine-undo t
      truncate-string-ellipsis "…")
#+end_src

Copy link
Contributor

@jeanas jeanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I only had the time to start a review.)

@goshatch goshatch requested a review from jeanas January 23, 2024 22:36
@goshatch
Copy link
Contributor Author

(I only had the time to start a review.)

Thank you @jeanas, I appreciate your time! I've made the changes you've requested, please let me know if anything else could be improved.

@goshatch
Copy link
Contributor Author

Hi @jeanas, I've pushed changes to address the issues raised by the last CI run. Could you please run the workflow again? Thank you!

@jeanas
Copy link
Contributor

jeanas commented Feb 1, 2024

@goshatch There are a few things I'd like to fix up in the PR before merging it, but I cannot push code here because you opened the PR from the master branch of your fork, which is write-protected. I'm going to create a different PR. (For the future, it is normally better on GitHub to create a feature branch for each PR.)

@jeanas jeanas closed this Feb 1, 2024
@jeanas jeanas mentioned this pull request Feb 1, 2024
@goshatch
Copy link
Contributor Author

goshatch commented Feb 2, 2024

Thank you @jeanas, and noted about feature branches.

@Anteru Anteru added this to the 2.18.0 milestone Apr 28, 2024
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.

3 participants