Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
298 posts
|
We have been talking about in Twitter about a new way to enable and disable extensions. Basically the idea that has been discussed it has been to add some label when extension is registered so we can enable by setting as attribute.
So for example: [source, pseudocode] ---- asciidoctor.register("securedocument", new DecryptPreProcessor()); ---- and in the document: [source, asciidoc] ---- :extension: securedocument ---- Of course this is an example to show the meaning of what has been discussed but not how it would be implemented. But I think we can even do something more complete and the label instead of being a simple label it can be a regexp somthing like PathParam in Jax-Rs. So for example: `asciidoctor.register("secure.*", new DecryptPreProcessor());` may be fit: [source, asciidoc] ---- :extension: securebook :extension: securedocument ---- but also we may introduce some kind of metaexpressions, separated by colon: `asciidoctor.register("filename:a.*\.adoc", new PreProcessor());` which means that all files to be rendered which its name starts with _a_ and finishing with _.adoc_ will enable the extension. Or for example: `asciidoctor.register("attribute:preprocessor", ...); will activate given extension when attribute preprocessor is present on document: [source, asciidoc] ---- :preprocessor: ---- WDYT? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
70 posts
|
I like the idea of the expressions.
From a groovy and possibly also ruby point of view I would prefer to even go a step further and use a predicate that decides whether an extension should be used or not. While making the code a little more ugly with Java<8 it looks very elegant in these two languages (at least in my opinion) So could be sth like `asciidoctor.register({it.filename ==~ /a.*\.adoc/}, new PreProcessor());` in Groovy or `asciidoctor.register(doc -> {doc.getFilename().matches("a.*\.adoc")}, new PreProcessor());` in Java 8 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
+1 This was certainly the idea when I added the name to an extension in 1.5.0. We haven't yet done anything with the name, but what I envisioned was something like: $ asciidoctor -a extensions=ui,social,diagram sample.adoc Of course, the API can take a more sophisticated approach, but once passed to the core we should end up with a simple list of names to enable. I filed an issue to track this feature in core here: -Dan On Tue, Sep 2, 2014 at 1:40 AM, Robert.Panzer [via Asciidoctor :: Discussion] <[hidden email]> wrote: I like the idea of the expressions. ... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |