0

I am working with Hexo - a nodeJS based static blogging CMS, I am extending the hexo API to register a new block tag called tabblock, see here:

hexo.extend.tag.register('tabblock', function (args, content) {
    var tabNumber = NumberOfTabs(content);
    var isTabbed = (tabNumber !== 0);
    console.log("Args: " + content);
    // Where my proper logic should go
    result = '<h1> TAG </h1>';
    return result;
  }, { ends: true });

This is the source snippet I am trying to interpret:

{% tabblock %}
``` JavaScript
    console.log("Double Tap");
```
``` TypeScript
    console.log("Double Tap");
```
{% endtabblock %}

However, the console.log from the function which should be processing that source, outputs this:

Args: <!--0--> <!--1-->

??? I Assume this is because the code is being interpreted as code rather than content? So if I wrap the {% tabblock %} in {% raw %} tags then I get no output at all, however, if I put the raw tags inside the tabblock, then I get this output:

Args: {% raw

How can I get my desired content?

1 Answer 1

1

\``` code ```\ is interpreted by Hexo as a code block, that why it output a messy thing. Try with only 2 or 1 backstick, it will works; like this \`` code ``\

I created a tabbed-codeblock tag for Hexo, you should take a look how I did it. As you can see, I wrapped code with the hexo tag and I use this structure to separate code blocks to avoid conflict with source code.

<!-- tab [lang] -->
    code
<!-- endtab -->
<!-- tab [lang] -->
    code
<!-- endtab -->
Sign up to request clarification or add additional context in comments.

1 Comment

message me on stack overflow or on gitter man, if you need detailed explanations or help, it will be easier to discuss :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.