question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-code info blocks

See original GitHub issue

Hello!

Before I go and write my own extension, I want to validate if there is already a way to extend something existing to create non-code info blocks.

Currently info blocks are something like this:

~~~info
my code
~~~

which converts into

<pre><code class="language-info"> 
my code
</code>
</pre>

Where as I am looking to make something that will do:

<p class="my-info">
my code
</p>

The intention is to standardize how we do alerts, warnings and other non-code call-outs within documentation.

Many thanks for any advice on what’s the right path for this.

Cheers, Olya

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
vschcommented, Sep 5, 2017

@olyas, there is not an extension for this but you can easily create an extension with a custom fenced code renderer that renders only info tagged ones and passes the rest to the core renderer.

You can use PegdownCustomLinkResolverOptions as an example but change the rendering part to:

@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<NodeRenderingHandler<?>>();
    set.add(new NodeRenderingHandler<FencedCodeBlock>(FencedCodeBlock.class, new CustomNodeRenderer<FencedCodeBlock>() {
        @Override
        public void render(FencedCodeBlock node, NodeRendererContext context, HtmlWriter html) {
            // test the node to see if it needs overriding
            if (node.getInfo().equals("info")) {
                html.attr("class", "my-info").withAttr().tag("p").line();
                html.text(node.getContentChars().normalizeEOL());
                html.closeTag("p").line();
            } else {
                context.delegateRender();
            }
        }
    }));
    return set;
}

Only use what you need from the sample. It is made for pegdown migration sample so you don’t need any of the pegdown related stuff.

0reactions
olyascommented, Sep 15, 2017

Thank you! With some more clean up and great help from a coworker as well as your comment we got it to work. It’s delightful 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

NONCODE: an integrated knowledge database of non-coding ...
NONCODE is an integrated knowledge database dedicated to non-coding RNAs (ncRNAs), that is to say, RNAs that function without being translated into proteins ......
Read more >
Detail infomation of NONHSAG004140.2--NONCODE
NONCODE ID SNP ID Source PMID NONHSAG004140.3 rs2796269 21886157 NONHSAG004140.3 rs2796269 21829388 NONHSAG004140.3 rs2796269 19060906
Read more >
non code studio (@noncodestudio) / Twitter
@noncodestudio. ◽️ How to best integrate Notion & other no-code tools on startups and corporate clients. ... Block by Block 2022 is kicking...
Read more >
NONCODE v2.0: decoding the non-coding - ResearchGate
PDF | The NONCODE database is an integrated knowledge database designed for the analysis of non-coding RNAs (ncRNAs).
Read more >
Working with non-code files - GitHub Docs
For more information, see "Creating diagrams." Rendering CSV and TSV data. GitHub supports rendering tabular data in the form of .csv (comma-separated) and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found