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

Option for disabling YAML metadata support

Open raxod502 opened this issue 6 years ago • 4 comments

Expected Behavior

My Markdown files frequently have a colon in the first line. This causes that line to be fontified as a YAML block, which is undesired. Since none of my Markdown files have YAML metadata, I'd like to disable this functionality entirely. I couldn't find a configuration option for this—have I missed one?

Actual Behavior

image

Steps to Reproduce

Just create a file with the contents pictured above, or similar. I verified that this works from emacs -Q with just markdown-mode loaded via straight.el.

Software Versions

  • Markdown Mode: 2.4-dev, 668de4a965980d618637a3b5754e721b54c51e83
  • Emacs: 26.0.91 from Homebrew Cask
  • OS: macOS 10.11.6 El Capitan

raxod502 avatar Apr 06 '18 17:04 raxod502

(To be clear, I'd be fine with retaining fontification of metadata blocks that are enclosed in --- delimiters. I just don't want to have markdown-mode identify my text as metadata if it's not enclosed in those delimiters.)

My current workaround:

(defalias 'radian-advice-markdown-disable-metadata-fontification #'ignore
  "Disable fontification of YAML front-matter in `markdown-mode'.
This is an `:override' advice for
`markdown-match-generic-metadata'. See also
https://github.com/jrblevin/markdown-mode/issues/328.")

(advice-add #'markdown-match-generic-metadata :override
            #'radian-advice-markdown-disable-metadata-fontification)

raxod502 avatar Apr 06 '18 17:04 raxod502

You didn't miss the option; it just doesn't exist yet. This affects me sometimes as well. These days I think most site generators, etc. do look for YAML delimiters, so I suppose we could even set the option to false by default.

jrblevin avatar Jun 16 '18 19:06 jrblevin

The advice that I posted earlier in this thread suddenly started causing markdown-mode fontification to instantly hang Emacs. I'm not sure why, but I figured now would be a good time to ask: how would you recommend working around this problem temporarily?

raxod502 avatar Jul 16 '18 19:07 raxod502

(Actually, I've gotten it to work once again with:

(defun radian--disable-markdown-metadata-fontification (&rest _)
  "Prevent fontification of YAML metadata blocks in `markdown-mode'.
This prevents a mis-feature wherein if the first line of a
Markdown document has a colon in it, then it's distractingly and
usually wrongly fontified as a metadata block. See
https://github.com/jrblevin/markdown-mode/issues/328."
  (prog1 nil (goto-char (point-max))))

(advice-add #'markdown-match-generic-metadata :override
            #'radian--disable-markdown-metadata-fontification)

.)

raxod502 avatar Jul 16 '18 19:07 raxod502