adoc-mode icon indicating copy to clipboard operation
adoc-mode copied to clipboard

table colors and delimiter inconsistencies

Open fjuenger opened this issue 3 years ago • 4 comments

Hello all,

First of all, thanks @bbatsov for maintaining adoc-mode. I am using latest version of adoc-mode (20220919.659 from melpa). The colouring scheme for table delimiter seems to be not capturing more than 4 delimiters. Update (added screenshot):

2022-12-15_13h23_44

Are there any guidelines to not have more than 4 delimiter per row? I guess the issue comes from regex string starting at line 1765 in adoc-mode.el that seems to concat a fixed number of patterns. I was not able to really figure out that pattern, but I tried changing the original:

   (list (concat "^"                  "\\(" (adoc-re-cell-specifier) "\\)" "\\(|\\)"
                 "\\(?:[^|\n]*?[ \t]" "\\(" (adoc-re-cell-specifier) "\\)" "\\(|\\)"
                 "\\(?:[^|\n]*?[ \t]" "\\(" (adoc-re-cell-specifier) "\\)" "\\(|\\)"
                 "\\(?:[^|\n]*?[ \t]" "\\(" (adoc-re-cell-specifier) "\\)" "\\(|\\)" "\\)?\\)?\\)?")

to:

   (list (concat "\\(^|\\)\\(?:[^\n\|]*\\)"
                 "\\(|\\)?\\(?:[^\|\n]*\\)"
                 "\\(|\\)?\\(?:[^\|\n]*\\)"
                 "\\(|\\)?\\(?:[^\|\n]*\\)"
                 "\\(|\\)?\\(?:[^\|\n]*\\)"
                 "\\(|\\)?\\(?:[^\|\n]*\\)")

which at least shows that I was now able to capture 6 delimiters (which is ok for most of my tables).

Also the colouring of those delimiters (tested with zenburn-scheme) sticks out compared to otherwise appealing colours. So I changed the relevant markup-table-face in markup-faces.el to drop the background colors of those delimiters and use a pale green tone for dark schemes.

(defface markup-table-face
  '((default (:inherit markup-meta-face))
    (((background light)) (:foreground "royal blue"))
    (((background dark)) (:foreground "pale green")))

fjuenger avatar Dec 14 '22 14:12 fjuenger

Are there any guidelines to not have more than 4 delimiter per row?

No, that's some bug with the regexp as you've guessed. We'll have to make it more flexible.

So I changed the relevant markup-table-face in markup-faces.el to drop the background colors of those delimiters and use a pale green tone for dark schemes.

It's still on my todo to kill the dependency to markup-face and just inline all those faces in adoc-mode. I'm guessing they are also missing in zenburn, if you've seeing some weird colours. Some screenshots would be useful.

bbatsov avatar Dec 15 '22 08:12 bbatsov

@bbatsov , do I think this table is from a ReStructured Text, not AsciiDoc. In the AsciiDoc table must be defined like:

[cols="1,1"]
|===
|Cell in column 1, header row |Cell in column 2, header row 

|Cell in column 1, row 2
|Cell in column 2, row 2

|Cell in column 1, row 3
|Cell in column 2, row 3
|===

dunmaksim avatar Mar 06 '23 08:03 dunmaksim

I'm guessing there are a few different syntaxes for tables and the one you mentioned might be the newer one - we'll have to check the AsciiDoc specification for more details.

bbatsov avatar Mar 06 '23 08:03 bbatsov

The example that I referenced is from the adoc-mode table generation function. It uses adoc prefix delimited tables as in https://asciidoc-py.github.io/chunked/ch23.html which should be fine. @dunmaksim I think the only difference to your example is, that you split cell definitions into multiple lines. It is all about the | for defining a cell.

fjuenger avatar Mar 06 '23 11:03 fjuenger