Skip to content

AndrewGotz/copy-down

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy Down

Convert HTML into Markdown with Java.

Installation

In your gradle file:

dependencies {
        compile 'io.github.furstenheim:copy_down:1.0'
}

Usage

import io.github.furstenheim.CopyDown;
public class Main {
    public static void main (String[] args) {
        CopyDown converter = new CopyDown();
        String myHtml = "<h1>Some title</h1><div>Some html<p>Another paragraph</p></div>";
        String markdown = converter.convert(myHtml);
        System.out.println(markdown);
        // Some title\n==========\n\nSome html\n\nAnother paragraph\n
    }
}

Options

It is possible to use options for converting markdown:

import io.github.furstenheim.CopyDown;
import io.github.furstenheim.Options;
import io.github.furstenheim.OptionsBuilder;

public class Main {
   public static void main (String[] args) {
       OptionsBuilder optionsBuilder = OptionsBuilder.anOptions();
       Options options = optionsBuilder
               .withBr("-")
               // more options
               .build();
       CopyDown converter = new CopyDown(options);
       String myHtml = "<h1>Some title</h1><div>Some html<p>Another paragraph</p></div>";
       String markdown = converter.convert(myHtml);
       System.out.println(markdown);
   }
}
Option Valid values Default
headingStyle SETEXT or ATX SETEXT
hr Any Thematic break * * *
bulletListMarker -, +, or * *
codeBlockStyle INDENTED or FENCED INDENTED
fence ``` or ~~~ ```
emDelimiter _ or * _
strongDelimiter ** or __ **
linkStyle INLINED or REFERENCED INLINED
linkReferenceStyle FULL, COLLAPSED, or SHORTCUT FULL

Acknowledgment

This library is a port to Java of the wonderful library Turndown.js. This library passes the same test suite as the original library to ensure same behavior.

About

Transform html to markdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 61.4%
  • HTML 38.6%