-
Notifications
You must be signed in to change notification settings - Fork 50
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
Support for conf-mode #71
Comments
Not sure I understand the request correctly. IIUC you want support for conf highlighting in code blocks. If that's right, you'd have to talk to chroma / whatever highlighter you use with go-org as highlighting logic is not part of this repo |
Not sure how it works here, but I know :
I thought that
EDIT (while double checking) : I think I am wrong ; Emacs (and org-mode) conf-mode is much more complicated than I thought ; it tries to auto-detect the (conf file) type, and supports many sub-types.
chroma's "Docker" is only one of them, so it won't work out of the box when an org-file will have a I am not sure what I write here makes any sense at all ; sorry if I totally misunderstood how go-org works. |
Thx for elaborating. As you said, go-org doesn't do any highlighting, it just calls chroma and passes the lang defined after I'm not sure there's anything to do inside this library - it's up to the highlighter. Either specify the language as docker or check with chroma if conf could be an alias for that / why conf is not highlighted as expected. Providing a key to override the specified language would be possible but unless babel has Support for that I'm not sure we should really add that |
Makes sense. In any case, I'd bring it up with chroma :). go-org isn't the right place to auto detect this imho |
Whatever, as you said that go-org passes the src block language as-is to chroma, I will simply use the final chroma languages suitable for my different |
I understand (and agree) this question may be closed, however me must understand this is a kind of fork with org-mode : Some source blocks (here conf blocks) are incompatible between go-org/chroma and org-mode. I think we should keep a list of those src blocks incompatibilities somewhere, that we could extend when we notice some. Does it make sense ? |
I'd disagree with keeping such a list in this repo - what languages org babel supports is configurable anyways (e.g. org-babel-load-languages) -there's no fixed target. Even if there was a fixed list of languages for org babel, this library does not handle syntax highlighting - it merely provides a hook for it. |
Well, org-babel conf src block is available in bare Emacs. Would you use When I said "keeping a list", I meant "keeping in a single place the knowledge of what can be done in some situations, when go-org/chroma does not render code as done in org-mode". If we keep such a list, it could also also help in future (for chroma or go-org - or somewhere in-between ?) if some people try to make things easier to use for casual users. I don't think this kind of list could appear in org-mode/babel documentation (they don't know about chroma), nor in chroma (they don't know about Emacs/org-mode). It could be something like : There are some differences between org-mode/babel SRC blocks rendering/exporting and go-org/chroma rendering. To get better rendering in go-org for some babel languages, you may try to replace the org-mode block language as following :
Then, we would just have to add a line every time someone notices a difference. But up to you, of course. |
I'm still not convinced this repo is the right place for such a list. As said, this is a difference between emacs and chroma. Keeping a list of differences between those two feels out of scope when go-org doesn't depend on chroma but rather uses it as an example implementation. I'd be up for keeping this open and waiting for more use cases. If this is a common thing to run into, let's add it even if out of scope. |
@niklasfasching Can go-org have it's config object that hugo passes on by parsing the user's hugo site config? [I know this will be a lot of work, but just putting my thought out here.] I faced this problem with emacs major modes doing syntax highlighting, but Chroma not working with those exact LANG identifiers. So I came up with this for ox-hugo which works really well. ox-hugo simply translates the Emacs major mode name to something that Chroma understands. I understand that it doesn't make sense to bake this translation table into go-org. But having a |
@kaushalmodi, I am not convinced we should use a 3rd dependency: _Disclaimer: I don't know/use |
I meant that this library will need a map-like config object at input. For a Hugo user, that translation map will be in the Hugo config. On the Hugo side, the config will be converted to this object and passed on to go-org. The map can be something like: # toml
[go_org]
[[go_org.src_lang_mapping]]
org = "conf"
chroma = "cfg"
[[go_org.src_lang_mapping]]
org = "ipython"
chroma = "python" or # yaml
go_org:
src_lang_mapping:
- org: conf
chroma: cfg
- org: ipython
chroma: python Above is a rough idea. The exact structure of that object will need more thought. |
I don't think the configuration file format will be the real issue here (xml, json, yaml, simple key-value, etc...), if we can find the mapping itself (how to map an unique org language like Thinking again about an acceptable approach, I am just wondering if a kind of source block metadata would not be better : It would keep full org-mode compatibility, and would just be used by go-org/chroma when it exists. Maybe something like :
I think this would be an relatively "cheap" solution, and not disruptive : no change for current go-org users, no break in org/babel as I planned to do in #71 (comment). |
|
Yes, it would be much better. I thought about it, but I was unsure about what is possible or not on params (I asked on If there is no drawback, a param would be clearly the best (and simple) option... |
I feel that will create too much chroma-related clutter in the Org source files. If there's an option of a central config, you only need to edit one config file and be done. |
For me, these are two different things: A mapping when, for a given org-mode language, there is an unique corresponding chroma language (we could use a mapping config file, or even hard-code it, as I would like to add that, even with no mapping table, the SRC block |
Alright - both the centralized mapping config and the inline language override have value. The inline override is easier to implement and more flexible (the centralized mapping breaks down for e.g. conf mode - the mapping depends on the actual content) so I'd opt for that. Name suggestions? I don't like |
Which name are you talking about ? I am not sure to understand what you mean. |
@braoult I think it's the name of the key where we specify the lang name value (see below). @niklasfasching If you are adding support for inline language override, this might work too:
Another name suggestion:
|
hmm... Imagine we have another implementation (I mean not Chroma), with totally different language mapping. How could we specify both of them with this syntax (I mean how could we have the same org file being used whatever implementation we use) ? What about something like :
Or even:
Edit: Ooops. I totally forgot we said |
Heyo, just browsing the issues and I came across this. I think I might be able to help. Org has a bunch of ways of translating (("C" . c)
("C++" . c++)
("asymptote" . asy)
("bash" . sh)
("beamer" . latex)
("calc" . fundamental)
("cpp" . c++)
("ditaa" . artist)
("desktop" . conf-desktop)
("dot" . graphviz-dot)
("elisp" . emacs-lisp)
("ocaml" . tuareg)
("screen" . shell-script)
("shell" . sh)
("sqlite" . sql)
("toml" . conf-toml)) If go-org were to support a similar customisation, just switching out the language as prescribed, I think that would be fairly reasonable. |
I'm not sure how to go about this issue. A 1:1 mapping as described would not handle the initial request of highlighting a Do I understand the consensus right as:
? I prefer @braoult what would you prefer? |
With #85 we can customize chrome behavior based on src parameters - i.e. both a 1:1 lang mapping (1) and Closing for now as no changes to go-org are required to make this work - feel free to re-open if you want to continue discussing keeping such a mapping in this repo or anything else; but doesn't feel like there's anything to be done for now. |
Could the default mapping I described in #71 (comment) be applied in this repo? |
Definitely - as long as we keep it isolated and e.g. just add a |
I am so sorry, I totally missed this comment... My preference would be (2) too. |
Sounds good. Since #85, (2) should be as simple as HighlightCodeBlock: func(source, lang string, inline bool, params map[string]string) string {
if exportLang, ok := params[":export-lang"]; ok {
lang = exportLang
}
// [...] So I'd opt for leaving that up to the user. Thoughts? |
Perfect for me, hard-coding mapping in |
It would it you tried to account for user customisation. I didn't suggest that, I suggested using the mapping that Org itself ships with. |
How would you do this ? The |
Indeed, some users do extend it, but using the default value is still sensible to use.
Sure, it won't handle all the variations, but it will handle some of them. For example, the default ("desktop" . conf-desktop)
("toml" . conf-toml) Besides which, I don't see how "this won't handle all use cases" is an argument against something that will improve some use cases. That sounds like the perfect being the enemy of the good 🙂. |
What I meant is that |
What about |
Emacs
conf-mode
is used for files likeWindows INI
,gitconfig
, etc... the block type looks like "conf", such as :The display in Emacs can look like :
org's HTML export is similar. Source code looks like :
I believe corresponding
chroma
language could be "Docker
" (tested on https://swapoff.org/chroma/playground/). I am not sure what chroma'sINI
files are, but it is something different.Output of same code on Chroma's test page :
Would it be possible to include
conf
blocks in go-org ?The text was updated successfully, but these errors were encountered: