Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
1 post
|
Hi! I'm trying to write an extension where different blocks of code are put under a tab for their specific language. I'm not very experienced with Asciidoctor or Ruby, but this functionality is a requirement for the use I need it for, so that's why I'm immediately diving into writing an extension.
The following input (syntax can change to suit asciidoctor better)... [multicode] -- [code:C code] [source,c] ---- void somecrazyCcode() { } ---- [code:D code] [source,d] ---- void somecrazyDcode() { } ---- -- should roughly produce this output: <div class="tabbedcode"> <div class="listingblock" data-code="C code"> <div class="content"> <pre class="highlight"><code class="language-c" data-lang="c">void somecrazyCcode() { }</code></pre> </div> </div> <div class="listingblock" data-code="D code"> <div class="content"> <pre class="highlight"><code class="language-d" data-lang="d">void somecrazyDcode() { }</code></pre> </div> </div> </div>The rest of the tabs stuff I'll be handling with javascript. The problem is I do now know, once creating a block with create_block, how you add a class to it. I also do not know how to add an attribute to the out. The code I've got so far: require 'asciidoctor/extensions' include Asciidoctor class CustomAdmonitionBlock < Extensions::BlockProcessor use_dsl named :multicode on_contexts :open def process parent, reader, attrs create_block parent, :open, reader.lines, attrs, content_model: :compound end end class CustomAdmonitionBlockDocinfo < Extensions::DocinfoProcessor use_dsl def process doc '<style></style>' end end |
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
|
> once creating a block with create_block, how you add a class to it. You set the role attribute. You can use the add_role method to do this. Btw, there is an extension for tabs already, though it's written in Java. You can perhaps use that for ideas and guidance. Cheers, -Dan On Thu, Oct 12, 2017 at 8:40 AM, tim.movin [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi! I'm trying to write an extension where different blocks of code are put under a tab for their specific language. I'm not very experienced with Asciidoctor or Ruby, but this functionality is a requirement for the use I need it for, so that's why I'm immediately diving into writing an extension. ... [show rest of quote] Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Free forum by Nabble | Edit this page |