Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables #66

Closed
wants to merge 6 commits into from
Closed

Tables #66

wants to merge 6 commits into from

Conversation

redsun82
Copy link
Contributor

Hi, I implemented simple tables for the maruku dialect (more or less following PHP Markdown Extra's implementation), as I needed them for a project of mine where I use this lib. Tests are still missing though...

A difference is that this implementation does not force cells in a row to be created up to the maximum width of the table... don't know yet if it's a big deal.

There are also some other minor changes that ended up in the code: the correction of a leaking global variable, the parameterisation of escaped characters per dialect (markdown extra apparently needs escaping for : and |), and a break statetement to exit a loop cheking for an empty dictionary.

edit: corrected typo

@ashb
Copy link
Collaborator

ashb commented Oct 31, 2012

Thanks for this.

Could we have some tests that cover at least a few common cases of tables even if they are not exhaustive?

@redsun82
Copy link
Contributor Author

Sure, I'll try to have them up by today or tomorrow.

2012/10/31 Ash Berlin notifications@github.com

Thanks for this.

Could we have some tests that cover at least a few common cases of tables
even if they are not exhaustive?


Reply to this email directly or view it on GitHubhttps://github.com//pull/66#issuecomment-9946506.

@redsun82
Copy link
Contributor Author

Here they are.

@vanthome
Copy link

Why hasn't this been merged yet?

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

Two reasons, the main one being I'd forgotten about it - sorry. The second is that the change to how escapes are checked doesn't work (i.e. the tests don't pass) - I'm looking at this now.

@ashb ashb closed this in 984a0ec Jul 26, 2013
@vanthome
Copy link

Great, will test as soon as you release this

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

@vanthome Just tidying up a few things and aiming to fix one more thing then a 0.5 will be on its way to npm

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

@vanthome v0.5.0 just published to NPM.

@redsun82 Thanks for this - sorry it took so long to merge.

@vanthome
Copy link

Hmm, are you sure that you pushed the latest version to GH?,
I'm using this version and it does not seem to work :(

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

You'll need to make sure you select the Maruku dialect - the default mode of operation is compatible with Gruber's vanilla script.

@vanthome
Copy link

Ahh ok, I document this, but it still won't work:

I'm using it in the browser and doing this:

  markdown.Markdown('Maruku');
  html = markdown.toHTML(data);

And I took my table from your test data.

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

Do you get an error or it just doesn't produce the output you expected?

@vanthome
Copy link

no error, just the tables are rendered plain

@ashb
Copy link
Collaborator

ashb commented Jul 26, 2013

Oh I see. markdown.Markdown('Maruku') creates an instance with the dialect set, but you've thrown that away.

html = markdown.toHTML(data, "Maruku");

should work for you.

@vanthome
Copy link

I tried this actually before but try to do this in the browser console of a page where markdown-js is included:

markdown.Markdown('Maruku');

you will see that it returns undefined

@evilstreak
Copy link
Owner

You need to use new markdown.Markdown('Maruku');

@vanthome
Copy link

I think this does not work in the browser.
When I try this in console, I receive a useless object:

var test = new markdown.Markdown('Maruku');
Object.keys(test);
["dialect", "em_state", "strong_state", "debug_indent"]

@evilstreak
Copy link
Owner

Sorry, my comment was a bit hasty and not all that helpful.

The exposed parse function uses this approach. It's really only necessary if you want to muck around with the intermediate trees, rather than going from a Markdown string to an HTML string.

If you just want to go from string to string with a specific dialect, then as @ashb said you just want to pass the dialect into your toHTML call.

@vanthome
Copy link

This works, excellent, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants