Giter VIP home page Giter VIP logo

html2markdown's Introduction

HTML2Markdown

Javascript Implementation for converting HTML to Markdown text.

Usage

Invoke it as following

    var md = HTML2Markdown("<h1>H1</h1>");

This call will return convert the html and return the mardown string like ""# H1\n\n"

Changes in this implementation

  • Added new htmldomparser. A simple html parser implementation that assumes parsing is done in browser. Shold be compatible with john Resig's parser.
  • Parser implementation provided support for ignoring tags that you do not want to convert.
  • Parser also has an option to ignore dom elements with hidden styles.
  • Added rules for parsing PRE, CODE, SPAN, DIV, TD, DL, DT
  • Added support for ignoring tags that you do not want to convert.
  • Improved "startBlock" method and renamed it to "block"
  • Added support for nested lists
  • Fixed some showdown rendering issues when a link has a nested image
  • Some readability changes like collapse whitespace, treat images as block elements, do not output text if elements are empty.
  • Added support for converting relative url's to absolute url's
  • Dropped wordwrap function as it does not seem a good idea to introduce new lines in the converter. and wordwrap behaviro was not consistents as elements can be nested.
  • Added support for refeence style images and links (option driven to choose between inline markdown formatting and refernce style formatting)
  • Added ton's of unit tests.

Known conversion issues

If HTML tag is of following form. Then, currently showdown fails to render

    <a href="/some_link">
        <h1>
                <img src="/some_image_lin"/>
        </h1>
    </a>                

html2markdown's People

Contributors

hgilani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

html2markdown's Issues

Missing <code>

Missing the tag: <code>code</code>

Here in the github comment we use it to show code.

the sign ` surounding text

<code>code</code>

Multiple paragraphs in blockquote

When converting blockquotes with multiple paragraps, only the first paragraph is converted properly.

(By the way, great work so far!)

Ordered list but

Hi have a html ordered list like that:

`


  1. Manque un bouton code

  2. Réparer la Ordered List

  3. Manque un bouton italic

  4. Miss a code button
`

But the Markdown output i get: (alway number 1)
`

  1. Manque un bouton code
  2. Réparer la Ordered List
  3. Manque un bouton italic
  4. Miss a code button
    `

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.