GithubHelp home page GithubHelp logo

macmarrum / markedj Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gitbucket/markedj

0.0 0.0 0.0 155 KB

JVM port of graceful markdown processor marked.js

License: Apache License 2.0

Java 73.34% HTML 26.66%

markedj's Introduction

markedj build Maven Central License

JVM port of graceful markdown processor marked.js.

Usage

First, add following dependency into your pom.xml:

<dependencies>
  <dependency>
    <groupId>io.github.gitbucket</groupId>
    <artifactId>markedj</artifactId>
    <version>1.0.17</version>
  </dependency>
</dependencies>

You can easily use markedj via io.github.gitbucket.markedj.Marked:

import io.github.gitbucket.markedj.*;

String markdown = ...

// With default options
String html1 = Marked.marked(markdown);

// Specify options
Options options = new Options();
options.setSanitize(true);

String html2 = Marked.marked(markdown, options);

Options

io.github.gitbucket.markedj.Options has following properties to control Markdown conversion:

Name Default Description
gfm true Enable GitHub Flavored Markdown.
tables true Enable GFM tables. This option requires the gfm option to be true.
breaks false Enable GFM line breaks. This option requires the gfm option to be true.
sanitize false Ignore any HTML that has been input.
langPrefix "lang-" Prefix of class attribute of code block
headerPrefix "" Prefix of id attribute of header
safelist See Options.java Safelist of HTML tags.

By default, markedj uses Jsoup's safelist mechanism for HTML rendering. It restricts renderable tags, attributes and even protocols of attribute values. For example, the image url must be http:// or https:// by default. You can remove this restriction by customizing the safelist as follows:

String html1 = Marked.marked("![alt text](/img/some-image.png \"title\")");
  // => <p><img alt=\"alt text\" title=\"title\"></p>

Options options = new Options();
options.getSafelist().removeProtocols("img", "src", "http", "https");

String html2 = Marked.marked("![alt text](/img/some-image.png \"title\")", options);
  // => <p><img src="/img/some-image.png" alt="alt text" title="title"></p>

markedj's People

Contributors

takezoe avatar dependabot[bot] avatar xuwei-k avatar macmarrum avatar mcfoggy avatar makenowjust avatar backpaper0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.