jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
898 stars 162 forks source link

Indented tables get wrapped by fill functions #315

Open saf-dmitry opened 6 years ago

saf-dmitry commented 6 years ago

Indented pipe tables like this

    | Right | Left | Center | Default |
    |------:|:-----|:------:|---------|
    |    12 | 12   | 12     | 12      |
    |   123 | 123  | 123    | 123     |
    |     1 | 1    | 1      | 1       |

or GFM tables like this

    Right | Left | Center | Default
    -----:|:-----|:------:|--------
       12 | 12   | 12     | 12     
      123 | 123  | 123    | 123    
        1 | 1    | 1      | 1      

get wrapped by paragraph filling commands and functions like M-q (fill-paragraph).

Expected Behavior

Paragraph filling commands should ignore table lines.

Actual Behavior

Paragraph filling commands work on table lines like on ordinary text.

Suggested Solution

Add markdown-table-at-point-p predicate function to fill-nobreak-predicate hook:

(add-hook 'fill-nobreak-predicate
          #'markdown-table-at-point-p nil t)

Software Versions

vancleve commented 2 years ago

I also have this problem with tables and fill.

I'm using doom emacs and tried adding the following to my config.el, which didn't seem to work:

(setq-hook! 'markdown-mode-hook
  fill-nobreak-predicate (cons #'markdown-table-at-point-p nil t
                               fill-nobreak-predicate))