Open-source parser code for Mediawiki markup [closed]

五迷三道 提交于 2019-11-29 10:47:41

There is a list of parsers on http://www.mediawiki.org/wiki/Alternative_parsers, but a c# parser is not included there...

Chris S

Update
Bare in mind Screwturn doesn't stick to the Mediawiki syntax but uses its own variation which does vary a bit.

The Mediawiki syntax doesn't lend itself to LALR parser (or even LL*) as it has a lot of ambiguities in its definition, and also allows HTML. There's a discussion on that in this question, you're essentially stuck with writing your own parser and tokenizer rather than simply writing a BNF file for it and then using ANTLR/Gold/Irony.

Roadkill Wiki uses a Creole parser for its Mediawiki parsing, but with limited support.


Screwturn is released under the GPL license, and has a C# parser:

The class you are after is Core.Formatter which has lots of regexs to do its work:

public static class Formatter {

}

It's not the nicest looking code "but it works".

I had some words to say about Mediawiki templates here. Interesting that there's a list of alternative parsers now, I'll have to investigate that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!