This project is read-only.

Is it possible to turn off default macros?

Apr 18, 2010 at 4:19 PM

I'm migrating from screwturn wiki to N2CMS. I have implemented storing content in N2 as wikimarkup and parsing it with wikiplex. But I have a banch of legacy pages using screwturn markup dialect and I'd prefer to change the way wikiplex parses some macroses rather then manually rewriting all that pages. Especially it is about urls. 

I'd like to turn off some of existing macroses and add corresponding custom implementation. Is it feasible?

Apr 18, 2010 at 11:52 PM

You have 2 ways.

1. Manually unregister them in your app startup, via Macros.Unregister<Type>. Caveat, is that this is a global change.
2. You can manually send in the list of macros you wanted used via the Render method overload.


Apr 19, 2010 at 9:10 AM

first option is clear but it may affect something significant

Could you please clarify the second one, by sending a list of custom macros in Render method I will get both native macros and custom, while as I've wrote before they are conflicting. I suppose that native would be executed first as they were registered first and custom ones would be useless. 

Apr 19, 2010 at 3:49 PM


There is an overload of IWikiEngine.Render that takes in an IEnumerable<IMacro>. When rendering, the engine will use only the macros explicitly defined, so if you wish to use a mixture of pre-existing and custom, you'll need to prepare a new list of macros to use.

var macros = new IMacro[] {
  new BoldMacro(),
  new ItalicsMacro(),
  new CustomMacro()

var engine = new WikiEngine();
string output = engine.Render(input, macros);


Apr 19, 2010 at 6:41 PM
Edited Apr 19, 2010 at 6:56 PM
Thanks, Matt. Another small question: is keeping single instance of WikiEngine preferable from performance point of view or it is ok to create new instance each time it is required to parse a markup?
Apr 19, 2010 at 6:59 PM

There's no performance impact (other than a few ctors) for re-creating the engine instance. All of the heavy-lifting work is statically cached per macro/renderer/augmenter.

Apr 19, 2010 at 9:41 PM
Cool. Thanks a lot for your answers.