Giter VIP home page Giter VIP logo

jscreole's People

Contributors

andreypopp avatar codeholic avatar diniscruz avatar ipeychev avatar

Stargazers

 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

jscreole's Issues

New API proposal: Implement pluggable builders

Currently jscreole builds DOM during parsing/traversing the Creole AST.

I see some people requested different API which would build a string instead of a DOM object. I think it would be great to have a some kind of pluggable builders so we can have one for DOM, another for strings. Others can implement they own builders as well. For example we would like to have a builder which produces React DOM objects (virtual DOM which later gets transformed into real browser DOM in an efficient way by the React library).

use jscreole natively on node

Hi, we use jscreole on our app to parse the Wiki into HTML, and on the new version, we need to do the parsing on the server (vs the client), and jscreole would be the perfect api (since we already use it and have written wiki text that parses ok with it).

So my first question is: 'Is there an easy way to run jscreole on node?'

I noticed that there isn't an npm package for jscreole (which would make that easier), if you want I'm happy to help in making that happen (https://www.npmjs.com/package/jscreole is waiting for you :) )

Here is how I was able to get it to work:

jscreole = require '../../poc/jscreole'
jsdom = require('jsdom').jsdom()
window = jsdom.parentWindow

describe '| poc | Wiki-Service.test |', ->
  it.only 'render wiki', ->
    wikitext = "== A title\n
                \n
                some text\n
                \n
                * a point"
    div =  window.document.createElement('div')
    global.document = window.document
    new jscreole().parse(div, wikitext)
    delete global.document
    log div.innerHTML

That uses jsdom to create an temp div (to hold the parsing text. I also had to temporarily polute the global variable with a reference to document because jscrole looks for that global object.

On that topic another question is "Is there a way to render the wiki text without an active dom?"

Add a function that just returns a string

I don't always want to write to the DOM straight away, so it would be nice if jscreole provided a function that just returned a string. I'm currently doing:

function creoleToHtml(creoleSource) {
    var parser = new creole({
        linkFormat: '#'
    });

    var div = document.createElement('div');
    parser.parse(div, creoleSource);

    return div.innerHTML;
}

but this would probably be cleaner inside jscrole.

List items parse issue

Hello Ivan!

There is an issue on parsing list items.
For example this code:

# item1
{{{
pre
}}}

won't be parsed properly. It will be turned to:
1. item1 {{{ pre }}}

According to Wiki Creole 1.0 specification:
"A list item ends at the line which begins with a * or # character (next item or sublist), blank line, heading, table, or nowiki block;"

Could you take a look, please?

Thanks!

Wiki parser introduces an unneeded list item

Hello Ivan,

I would like to notify you about an issue with parsing mixed list elements.

Let's suppose we have the following Wiki code:

* Item 1
* Item 2
## Item 2.1
## Item 2.2

The recommended output according to Wiki specification should be:

<ul>
<li>Item 1</li>
<li>Item 2
  <ol>
  <li>Item 2.1</li>
  <li>Item 2.2</li>
  </ol>
</li>
</ul>

(http://www.wikicreole.org/wiki/Lists)

The parser introduces an additional li element which wraps the whole ol element:

<ul>
<li>Item 1</li>
<li>Item 2
<li>
  <ol>
  <li>Item 2.1</li>
  <li>Item 2.2</li>
  </ol>
</li>
</li>
</ul>

This happens only when we are mixing ul with ol elements.

Could you take a look, please?

Thanks!

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.