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

How to write plugins? #10

Closed
LavirtheWhiolet opened this issue Dec 24, 2014 · 10 comments
Closed

How to write plugins? #10

LavirtheWhiolet opened this issue Dec 24, 2014 · 10 comments

Comments

@LavirtheWhiolet
Copy link

There are no any documentation or tutorial on how to write syntax plugins for Markdown-it, neither in this repository nor in internet.

@puzrin
Copy link
Member

puzrin commented Dec 24, 2014

Yes, at current time it's better to look into parser src, or existing pugins. I will add more examples & explanations, but do not expect it to be in top priority.

@puzrin
Copy link
Member

puzrin commented Dec 29, 2014

Take a look at drafts https://github.com/markdown-it/markdown-it/tree/master/docs and api doc

Will it help? Issue title is a bit abstract to decide how to solve it. I can answer particular questions and enhance docs, but can't write book "how to learn programming"

@LavirtheWhiolet
Copy link
Author

No, it doesn't help. It describes some design decisions but does not explain how to use plugin API.

Issue title is a bit abstract to decide how to solve it.

Probably, it's too concrete. Let's take an example: I want to process new tags in my text with MarkdownIt: !!red, !!blue, !!green, !!nocolor. I may want to make them inline (!!red starts red-colored text, !!nocolor restores the color back) or block (!!red(colored text) normal text)—it doesn't matter in fact. The questions are: what functions should I declare? What functions should I create? Where should I pass them? As far as I've seen, I should call MarkdownIt.use(…) to load my plugin. But what the type of the plugin object? What functions should it declare? There are prototypes ParserBlock and ParserInline, should I include them in my plugin? Should I call some functions to get them? If yes, then what functions? Et cetera, et cetera.

@puzrin
Copy link
Member

puzrin commented Dec 29, 2014

Sorry, that's like teaching programming. I can't write such tutorials. If you at least try to do something - i can help. But writing for unclear goals it out of my scope.

If your markup applied in paragraph-like content, those should be processed in inline rules. If you need pairs (open/close) - look emphasis-like rules. For plugin packing - look existing emoji plugin.

@LavirtheWhiolet
Copy link
Author

If you at least try to do something

I'm trying. I'm trying to add parsing of !!color tags at least. But the only thing I… no, any developer can see is a bunch of abstractedly named functions (like use(·), enable(·), disable(·), get(·), do(·)) without any comments, 2–3 doc. pages about design ideas and lots of spaghetti-like examples. The only thing which developers can find out without diving into implementation of MarkdownIt is that they should patch the method use(·) somehow. I can't even start to develop my plugin (without reading the entire MarkdownIt codebase of course)!

@puzrin
Copy link
Member

puzrin commented Dec 29, 2014

Man, all i see - a huge unsplitted paragraphs, difficult to read, no exact markup spec, abstract talks and abstrat issue title. If you really need help - be specific. I can't discuss theory of writing good docs and other shit.

Create ticket "how to do this markup?" and describe exactly and shortly what do you need to implement. Then i'll try to help, as i did to other devs. This ticket is closed as not enougth specific and unsolvable.

@puzrin puzrin closed this as completed Dec 29, 2014
@LavirtheWhiolet
Copy link
Author

The issue is actually about writing some doc. for your pile of code.

Well, you think it is OK to ask you on every sneeze rather than to document it once and for all.

That's fine but I wouldn't hire such a man for my job.

@puzrin
Copy link
Member

puzrin commented Dec 29, 2014

Go with your brainfucking to someone's else repo. You waste my time with idiotic posting.

@markdown-it markdown-it locked and limited conversation to collaborators Dec 29, 2014
@ixti
Copy link
Contributor

ixti commented Dec 29, 2014

Specially for @LavirtheWhiolet and anybody else with same brain decease, summarizing what has being said and by some reason ignored:

  • We have documentation for end-users, which should be enough to start using this package.
  • We know that we lack of extensive documentation on how to plugins. That's not top priority. If you really need it - we will highly appreciate pull requests with improvements to documentation.
  • Interested in a how-to tutorial. Awesome. We are not! So you can either write it yourself, or hire somebody.
  • Don't know where to start with plugins, take a look on existing plugins code, e.g. markdown-it-emoji.

The issue is actually about writing some doc. for your pile of code.

You are welcome to write some! Although I doubt you can.

That's fine but I wouldn't hire such a man for my job.

Piss off! Who told you that we are seeking for a job? Who th f**k told you that you will be able to interest us to be willing work "for you"?

NB @LavirtheWhiolet get back to your homeworks.

@puzrin
Copy link
Member

puzrin commented Dec 30, 2014

@ixti may be his mom given him coins to hire someone do his homeworks. Don't teach him how to do serious business, or you will loose opportunity to be hired.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants