sparksuite / simplemde-markdown-editor

A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://simplemde.com
MIT License
9.92k stars 1.12k forks source link

YAML Frontmatter #314

Closed PhrozenByte closed 8 years ago

PhrozenByte commented 8 years ago

First of all: Great software! :+1:

SimpleMDE should support formatting YAML Frontmatters (possibly after setting a config variable). YAML Frontmatters are often used by flat-file CMS like Pico, Grav or Jekyll to store meta data of a specific page. CodeMirror already comes with both a YAML and YAML Frontmatter mode.


---
foo: bar
baz:
    - Hello
    - World

---

SimpleMDE
=========

Lorem ipsum...
WesCossick commented 8 years ago

SimpleMDE is purely a Markdown editor. If you'd like to fork SimpleMDE and convert it into some other type of formatting, you are welcome to do so.

PhrozenByte commented 8 years ago

Does SimpleMDE provide a way to hook into its processing without forking the project in whole (and therefore fragmenting your user base)?

WesCossick commented 8 years ago

SimpleMDE (the MD stands for Markdown) only focuses on Markdown. I have no plans of changing this.

PhrozenByte commented 8 years ago

Yeah, that's completely fine and I don't want to change anything about it if you don't want to, but that wasn't my question :wink: :smile:

I was asking you about any suggestions about how I can hook into SimpleMDE's processing to add the wished functionality without forking SimpleMDE - i.e. some sort of API. The goal is to leave SimpleMDE itself completely untouched and just extend its functionality from the outside (like SimpleMDE's previewRender option/hook). Forking SimpleMDE fragments the user base and is something I would like to avoid, so I'm asking you about possible different approaches without forking the project in whole.

If SimpleMDE currently doesn't provide a way to do something like this, I would like to participate in developing some sort API to extend SimpleMDE without forking the project. So I'm asking you about maybe already existing approaches or ideas about how to achieve this :smiley:

WesCossick commented 8 years ago

@PhrozenByte At the moment there is no way to adjust the processing of SimpleMDE. You can replace the preview rendering function though.

PhrozenByte commented 8 years ago

@WesCossick, so, if I open a PR implementing hooks to allow adjusting SimpleMDE's processing, will you accept it (i.e. generally speaking, do you like the idea of hooking into SimpleMDE's processing)?

WesCossick commented 8 years ago

Can you elaborate more on what you'd plan on changing?

PhrozenByte commented 8 years ago

I didn't thought about a concrete solution yet, you didn't say anything whether this even comes into question or not. However, this is prerequisite to follow up with SimpleMDE's source code and to evaluate possible solutions. It isn't mandatory for my personal use case to implement this, I could also use a second textarea just for YAML. However, I think SimpleMDE profits by a sane way to hook into its processing, so I'm willing to implement it - as long as you're interested in something like this. I don't want to waste my time with programming something you don't want - I really have no interest in forking SimpleMDE.

My first idea is to add a markdownRender callback (like the existing previewRender callback) that allows you to add a new CodeMirror mode (with CodeMirror.overlayMode()) and let SimpleMDE use this mode instead of gfm resp. spell-checker.

WesCossick commented 8 years ago

I'm not very interested in this for SimpleMDE to be honest. I'd like to stick to just Markdown to keep things simple.

PhrozenByte commented 8 years ago

Alright, I'll do the workaround with two textareas then. Thanks for your help anyway! :+1: