asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104 stars 101 forks source link

new extension to privatise some blocks #81

Closed JacquelinCharbonnel closed 5 years ago

JacquelinCharbonnel commented 6 years ago

This is an extension to filter (or not) paragraphes tagged 'private'.

The paragraph is passed to the output stream if its attribute is 1, else it is filtered if its attribute is 0.

If no attribute is specified, so the document attribute 'show_private' is considered, and the paragraph is shown if 'show_private' attribute is 1 else it is filtered.

Examples :

[private] no attribute, so this paragraph is filtered depending of the global document attribute :show_private: (0->filtered, 1->not filtered)

[private,1] attribute is 1, so this paragraph doesn't pass to the output stream

[private,0] attribute is 0, so this paragraph passes to the output stream

mojavelinux commented 5 years ago

Technically you could implement this using built-in behavior. There's already a comment block, which effectively filters it.

[comment]
This block is filtered out.

You could then use an attribute to control whether comment is on or off.

:private: comment

[{private}]
This block is filtered out unless the private attribute is unset (perhaps via the API).
mojavelinux commented 5 years ago

As I explained, this is already covered by built-in behavior. After reading my suggestion, if you think this block is still needed, feel free to reopen with an explanation as to why.