mdiep / MMMarkdown

An Objective-C framework for converting Markdown to HTML.
MIT License
1.25k stars 168 forks source link

How to add custom Markdown syntax? #42

Closed iosdev-republicofapps closed 9 years ago

iosdev-republicofapps commented 9 years ago

Hi,

First, thanks for MMMarkdown - it performs well and I think it's awesome! I really appreciate you making this available! :-)

I'm working on a Markdown app where I want to add a few features that are not directly supported by Markdown:

So for example, I'd like to specify some Markdown like:

# Here is a headline

Some text

---

New page (--- acts as a page break)

--- tiny

Text is now tiny due to "--- tiny" tag

I'm not married to the use of --- or --- tiny, they could be whichever characters. I just need to add these custom tags.

Can you please give me some pointers how you think it might be easiest to do this in MMMarkdown? I'm happy to code it myself and offer a pull request if you'd like to add it back to the main codebase, but I was hoping you could point me in the right direction and suggest the code path most likely to be successful. :-) Also, if you had suggestions as to which types of characters for my custom tags might work best I'd appreciate that as well.

Thanks again for making this great code available.

Best Wishes.

mdiep commented 9 years ago

If you're adding new block tags (top-level content like a list or paragraph, not inner content like emphasis or strong), then you'll want to add them to MMParser. In particular, see _parseBlockElementWithScanner: and add your new element there. You may also need to add a new type to MMElement to return for your content and then add support for it to MMGenerator.

That's a rough guideline of how I'd go about it. Feel free to ask questions if you get stuck.

iosdev-republicofapps commented 9 years ago

Thanks! I'll take a look and if I end up adding some new tags, I'd be happy to writeup a Wiki how-to for the repo's wiki if that helps.