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

frontmatter metadata is incorrectly folded #136

Closed
blaenk opened this issue May 5, 2016 · 4 comments
Closed

frontmatter metadata is incorrectly folded #136

blaenk opened this issue May 5, 2016 · 4 comments

Comments

@blaenk
Copy link

blaenk commented May 5, 2016

So I found out about markdown-use-pandoc-style-yaml-metadata which is great. I use outline-minor-mode so that I can fold up all sections for example, but it ends up treating the line right before the end of the metadata block as a header.

before

after

@syohex
Copy link
Collaborator

syohex commented May 5, 2016

outline-minor-mode uses outline-on-heading-p function for finding outline/markdown header. Its implementation is here. It used only regular expression for finding header line so that it mistakes to fold. In your case, the context, whether header line is in YAML header, should be considered for finding header line. Because it looks like outline header line but it is not actually header line.

(defun outline-on-heading-p (&optional invisible-ok)
  "Return t if point is on a (visible) heading line.
If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
  (save-excursion
    (beginning-of-line)
    (and (bolp) (or invisible-ok (not (outline-invisible-p)))
     (looking-at outline-regexp))))

We cannot control its behaviour as we expected without overwriting function or advice feature.

@blaenk
Copy link
Author

blaenk commented May 6, 2016

How about if we introduce an option to disable Setex headers (the ones underlined)? I only use ATX headers (the ones that go ## Header), and I always really see people using ATX headers. I'm not saying disable it outright, but since I never use them, I imagine it would help in a situation like this if I could personally disable them on my end.

@syohex
Copy link
Collaborator

syohex commented May 6, 2016

How about if we introduce an option to disable Setex headers (the ones underlined)?

I disagree. Because it is markdown specification. And this is outline-mode issue. (I hope it should be customizable)

However you can change it by following configuration.

(defun my/markdown-mode-hook ()
  (setq-local outline-regexp "^\\(?:\\(#+\\)[ \t]+\\(.*?\\)[ \t]*\\(#*\\)\\)$"))
(add-hook 'markdown-mode-hook #'my/markdown-mode-hook)

@jrblevin
Copy link
Owner

jrblevin commented May 6, 2016

markdown-mode has its own outline visibility cycling (section folding) functions which you should use rather than using outline-minor-mode functions directly. This is because, as you saw, the regular-expression-based approach of outline-minor-mode is too simple for Markdown documents. You can cycle visibility globally with Shift+Tab. Press it multiple times to see more or less.

The new commit (a646fea) adds code to un-hide text in the metadata block that outline-minor-mode mistakenly hides.

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