Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

org.riversun:flexmark-ext-prism-linenumber

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

org.riversun:flexmark-ext-prism-linenumber

flexmark-java extension for prism syntax highlighter.

  • 1.0.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Overview

flexmark-java extension for prism syntax highlighter.

This extension will insert 'class="line-numbers"' attribute into fenced code block.

It is licensed under MIT.

How to use

Maven

<dependency>
	<groupId>org.riversun</groupId>
	<artifactId>flexmark-ext-prism-linenumber</artifactId>
	<version>1.0.0</version>
</dependency>

This library and flexmark-java make following markdown output html

Input markdown


**Hello**

```java

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}

```

Output html

<p><strong>Hello</strong></p>
<pre class="line-numbers"><code class="language-java">

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( &quot;Hello World!&quot; );
    }
}

</code></pre>

Example code


import java.io.IOException;
import java.util.Arrays;

import org.riversun.flexmark.PrismCodeLineNumberExtension;

import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.builder.Extension;
import com.vladsch.flexmark.util.data.MutableDataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;

/**
 * 
 * Example for flexmark-java extension for prism syntax highlighter linenumber
 * rendering
 *
 */
public class Example {

  public static void main(String[] args) throws IOException {

    String srcMarkdown = "**Hello**\n" +
        "\n" +
        "```java\n" +
        "\n" +
        "/**\n" +
        " * Hello world!\n" +
        " *\n" +
        " */\n" +
        "public class App \n" +
        "{\n" +
        "    public static void main( String[] args )\n" +
        "    {\n" +
        "        System.out.println( \"Hello World!\" );\n" +
        "    }\n" +
        "}\n" +
        "\n" +
        "```";

    MutableDataHolder options = new MutableDataSet();
    options.set(Parser.EXTENSIONS, Arrays.asList(new Extension[] {
        PrismCodeLineNumberExtension.create()

    }));

    Parser parser = Parser.builder(options).build();

    Node document = parser.parse(srcMarkdown);

    HtmlRenderer renderer = HtmlRenderer.builder(options).build();

    final String html = renderer.render(document);

    System.out.println(html);

  }

FAQs

Package last updated on 04 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc