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

Wrong language in the source block header #303

Open
jagrg opened this issue May 3, 2024 · 4 comments
Open

Wrong language in the source block header #303

jagrg opened this issue May 3, 2024 · 4 comments

Comments

@jagrg
Copy link

jagrg commented May 3, 2024

Gptel returns #+begin_src javascript when it should be #+begin_src js. Any suggestion on how to fix this?

@karthink
Copy link
Owner

karthink commented May 3, 2024

The LLM is sending this string:

```javascript
some code
```

So gptel shows #+begin_src javascript. This is working as intended.

If you anticipate this problem, you can use gptel's post-response hook to replace it afterwards. Untested:

(defun gptel-fix-src-header (beg end)
  (save-excursion
    (goto-char beg)
    (while (re-search-forward "^#\\+begin_src javascript" end t)
      (replace-match "#+begin_src js"))))

(add-hook 'gptel-post-response-functions #'gptel-fix-src-header)

@jagrg
Copy link
Author

jagrg commented May 4, 2024

It works, but since javascript is not a valid babel language (as opposed to js), perhaps the problem should be addressed internally, WDYT?

@karthink
Copy link
Owner

karthink commented May 7, 2024

I need to make the markdown -> org pipeline user-customizable first. Then gptel can provide some utility functions for mini-fixes like this without having to resort to the post-response hook, which is a bit of a bludgeon. This is a low priority for now.

Do you know where I can find the list of babel names for languages?

@jagrg
Copy link
Author

jagrg commented May 18, 2024

Should be all the ob-*.el files in https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp

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

No branches or pull requests

2 participants