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

No table styling in example blocks? #33

Closed
enricoflor opened this issue Mar 27, 2022 · 9 comments
Closed

No table styling in example blocks? #33

enricoflor opened this issue Mar 27, 2022 · 9 comments

Comments

@enricoflor
Copy link

Hi,

As far as I understand, literal example blocks in org-mode (#+begin_example) are meant for text that does not receive any markup. However, org-modern renders a "column" of pipes like

  |
  |
  |

as if it was part of a table (i.e. with a solid vertical line), even in literal example blocks. Is this the intended behavior?
Thanks for the great package(s)!

@minad
Copy link
Owner

minad commented Mar 27, 2022

You can quote Org syntax with comma in example blocks, see https://irreal.org/blog/?p=5503. For some reason this is required by Org for headline stars. But it seems that tables are indeed not highlighted in example blocks. Overall the treatment of Org syntax in these example blocks seems inconsistent.

#+begin_example
| a | b | c |
| a | b | c |
| a | b | c |
#+end_example

org-modern could do a bit better here. But I don't know how org-mode manages the distinction in the Org font locking setup. I'd appreciate some insight here. The same issue affects org-modern styling of lists and of other syntax elements.

EDIT: It seems that the function org-fontify-meta-lines-and-blocks is used to undo the fontification of example blocks to some extend. We could probably change how the org-modern fontification is plugged into the existing org fontification such that such issues are avoided. See 1246641 for an experiment.

minad added a commit that referenced this issue Mar 27, 2022
@enricoflor
Copy link
Author

Thanks! 1246641 solves the issue for me and I couldn't find problems with it!

@9viz
Copy link
Contributor

9viz commented Jun 25, 2022

Good day, Daniel.

I wonder if a better solution to the problem in this general area is to add org-modern's font-lock-keywords to the variable org-font-lock-extra-keywords using the hook org-font-lock-set-keywords-hook.

I use this hook in my personal configuration to fontify horizontal rules and this rule is not applied in an example block:

(defun vz/org-fontify-horizontal-break ()
  (push '("^[[:space:]]*\\(------*\\)\n"
          (0 (progn
               (put-text-property (match-beginning 1) (match-end 1)
                                  'display (make-string (- (match-end 1) (match-beginning 1)) ?\s))
               (put-text-property (match-beginning 1) (match-end 0)
                                  'face '(:strike-through t :extend t)))))
        org-font-lock-extra-keywords))

(add-hook 'org-font-lock-set-keywords-hook #'vz/org-fontify-horizontal-break)

Maybe you considered this but decided against it? Anyway, I thought this would be worth mentioning.

You can see a screenshot here: http://0x0.st/oSS0.png

@minad
Copy link
Owner

minad commented Jun 25, 2022

@Vizs Could be that this would work better. I am not that much into the org code base, so I don't recall if I considered this or not. You can probably answer this better than me. Did you test moving all (or most) org-modern--font-lock-keywords to org-font-lock-extra-keywords? If this works well we could change the approach. In that case, feel free to create a PR.

@9viz
Copy link
Contributor

9viz commented Jun 25, 2022

Sure, I will do some tests on my side and see where it leads us to.

@minad
Copy link
Owner

minad commented Jun 25, 2022

There is also org-font-lock-set-keywords-hook. Maybe that could be used as well?

@9viz
Copy link
Contributor

9viz commented Jun 25, 2022

That's what I'm doing. But now, I'm unsure how to remove the org-modern keywords when you disable the mode 🙃

@minad
Copy link
Owner

minad commented Jun 25, 2022

Ah lol yes, I didn't read your snippet.

@9viz
Copy link
Contributor

9viz commented Jun 25, 2022

That hook is called before org-mode-hook is run so doing this way would make org-modern a global minor mode instead (IIUC). But I made a new hook that was basically (setq org-font-lock-extra-keywords (all the org modern stuff here)) but that failed with errors in redisplay ... 🙃 and I am not looking forward to debugging that (i.e., if there's even a sane way to do so!).

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

3 participants