维基媒体如何转变其模型语法?
我想知道维基媒体如何将其模型语法 ({{model|options}})
转换为 html 代码。 我有一个简单模型 ({{.*?}})
的正则表达式,但对于嵌套模型则失败(例如: {{model|options 包含 {{submodel|options} }...}}
)
I would like to know how does Wikimedia transform its model syntax ({{model|options}})
into html code.
I have a regex for a simple model ({{.*?}})
but it fails for a nested model (ex: {{model|options containing a {{submodel|options}}...}}
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
记住,
也就是说,您可以阅读: 论坛标签。实现它们的最佳方法是什么? 我做了一个嵌套标签的示例,两者都带有“纯”正则表达式和“更稳定”的 C# 解析器使用了一些正则表达式,但使堆栈不受正则表达式的控制。
您可以使用
平衡组
来实现。 “基本”正则表达式(有些人不认为它们是真正的正则表达式),但我不会用正则表达式之类的东西来编程像 Wiki 这样的东西。正则表达式的问题在于,对它们进行编程非常困难。他们不会回溯(有一个选项可以做到这一点,但很难构建一个不需要回溯或只需要有限回溯的正则表达式),当他们开始回溯时,那就结束了:他们可以等待几分钟寻找正确的捕获组合。
Remember,
That said, you can read: Forum tags. What is the best way to implement them? I made an example of nested tags, both with "pure" Regex and with a "more stable" C# parser that uses a little of Regexes but keeps the stack out of the Regex hands.
You can do it with
balancing groups
. They aren't part of "base" Regex (and some persons don't consider them to be true regexes),But I wouldn't program something as big as Wiki with something like a regex. The problem of regexes is that it's quite difficult to program them so that they don't backtrack (there is an option to do it, but it's difficult to build a regex that doesn't need backtracking or that need only limited amout of backtracking), and when they begin to backtrack it's the end: they could stall for minutes searching for the right combination of captures.