codeholic / jscreole Goto Github PK
View Code? Open in Web Editor NEWA JavaScript library for parsing Creole 1.0 wiki markup.
Home Page: http://www.ivan.fomichev.name/2008/04/javascript-creole-10-wiki-markup-parser.html
A JavaScript library for parsing Creole 1.0 wiki markup.
Home Page: http://www.ivan.fomichev.name/2008/04/javascript-creole-10-wiki-markup-parser.html
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!
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!
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).
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?"
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.