JQuery / Javascript solution for converting wiki text to HTML and vice versa?

For my web interface, I have to implement subsets of wiki syntax on my system. Do I need to manually specify the rules and reinvent the wheel? Is there an existing javascript library or jquery plugin that could help with this?

For example, the user enters == Header == Since it is necessary, for example, to convert to the middle header (it is assumed that the environment is defined in this context as a range, as shown below)

 <span class="mediumHeader" id = "Header">Header</span> 

Now when the user edits the text above, I assume that this will lead to a replacement

<span...> ... </span> with ==...==

Now for every system that I design, it will be according to "my rules" and almost always have to reinvent the wheel. Is there something I could use to facilitate this wiki to / from HTML conversion using jquery / javascript? I am sure this is a problem with a known solution.

I would rather adjust what is acceptable and what is not. I do not have everything to be translated into syntax (or HTML) just as a wiki. Should I just download my own applications?

+7
source share
2 answers

Long enough that you don't need it, but yours was the best SO when I started learning it.

There are several options for javascript - you are probably watching instaview (check test / test.js), or maybe Wiky.js (all the less fully documented).

If you are not limited to Javascript, check out the comprehensive list of MediaWiki parsers at http://www.mediawiki.org/wiki/Alternative_parsers - many tools for C ++, Java, Perl, ruby, etc. This is a link to keep track of new developments.

+5
source

At the time of writing, Parsoid seems the only one that translates in both directions. It also provides a visual editor on Wikipedia. But this is not a convenient lib client base for inclusion in your application, but a full-featured parsing and conversion package. Access to the production version of Parsoid in the Wikimedia cluster is available at http://parsoid-lb.eqiad.wikimedia.org/ .

Other JavaScript libraries that translate only from WikiText to HTML (in order of popularity):

  • Wiky.js - does not support the full WikiText syntax. (from tanin47, not to be confused with Requiki's Wiki.js - a completely different project)
  • wtf_wikipedia - does not directly translate to HTML, but JSON, which leads to much more powerful features (for example, info boxes as key-value pairs). This is the most modern library and "its combination of instaview, txtwiki and uses interlanguage data from the javascript parser parser."
  • instaview - no updates for the last 2 years.

Also check out the current and complete list of alternative MediaWiki parsers .

+3
source

All Articles