Coder Social home page Coder Social logo

marked-ast's Introduction

marked-ast

A modified version of marked that can produce an abstract syntax tree for Markdown.

Usage

var marked = require('marked-ast');
var ast = marked.parse('_This is **Markdown**_, he said.');
var html = marked.render(ast);

The package is just a wrapper for marked, so the produced HTML should be identical (if it isn't it's a bug). The AST produced in the example would look like this:

[
  {
    "type": "paragraph",
    "text": [
      {
        "type": "em",
        "text": [
          "This is ",
          {
            "type": "strong",
            "text": [ "Markdown" ]
          }
        ]
      },
      ", he said."
    ]
  }
]

Development

Basic setup:

git clone https://github.com/pdubroy/marked-ast.git
cd marked-ast
npm install
git submodule update --init

Running Tests

Use npm test to run the tests. Before checking code in, run npm run prepublish.

Updating Marked

To update to a new version of marked:

cd third_party/marked
git checkout <REF>  # E.g., `git checkout v0.3.3`
cd ../..
npm run rewrite && npm test

marked-ast's People

Contributors

gabro avatar pdubroy 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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

marked-ast's Issues

Link href with parens generates incorrect ast

Hey! Thanks for a great package!
The application I'm working on ran into this issue recently where if the href for a link contains non url encoded parens (()), the ast node generated for the link doesn't contain the full href.

marked-ast version: 0.3.0

Steps to reproduce:

  1. Invoke MarkedAst._marked like so โ€”
MarkedAst._marked('[Some link](https://something.xyz/(12)/1)', {
      // use renderer with altered methods for links and images
      renderer: new MarkedAst.AstBuilder(),
      // turn on Github-flavored MD goodies
      gfm: true,
      tables: true,
      breaks: true,
      smartypants: true,
      sanitize: false
    });

Expected ast:

[
  {
    "type": "paragraph",
    "text": [
      {
        "type": "link",
        "href": "https://something.xyz/(12)/1",
        "title": null,
        "text": [
          "Some link"
        ]
      }
    ]
  }
]

Received/Actual:

[
  {
    "type": "paragraph",
    "text": [
      {
        "type": "link",
        "href": "https://something.xyz/(12",
        "title": null,
        "text": [
          "Some link"
        ]
      },
      "/1)"
    ]
  }
]

Any ideas on how we can resolve this?
Thanks in advance!

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.