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

Table conversion fail when containing <h> tags #7

Open
littlehoneybunnytuttifruttipumpkinpie opened this issue Aug 24, 2017 · 7 comments
Labels

Comments

@littlehoneybunnytuttifruttipumpkinpie
Copy link

Breakdance is unable to convert tables that contain text with <h> heading tags.
Example:

<table>
  <tr>
    <th><h3>Firstname</h3></th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
</table>

(this converts to markdown that looks identical to the above input)

This behavior seems partially correct since <h> tags are not supported by tables.
However, total failure of conversion to markdown cannot be justified simply because tables can contain any text like '#%&@#&!", so any unsupported or unrecognizable syntax should also be treated like text.
Therefore the expected output should be:
| <h3>Firstname</h3> | Lastname | Age |

The problem is further amplified by the fact that currently Breakdance leaves the whole <table> HTML syntax in the markdown output, thus making it no longer usable as markdown. At minimum any bad syntax could be removed or replaced with a warning like:
[Unsupported HTML syntax - cannot be converted to markdown]

BTW, thanks Breakdance developers for your great contributions!

@jonschlinkert
Copy link
Member

jonschlinkert commented Aug 24, 2017

The problem is further amplified by the fact that currently Breakdance leaves the whole <table>HTML syntax in the markdown output, thus making it no longer usable as markdown.

Are there nested tables?

@jonschlinkert
Copy link
Member

thanks Breakdance developers for your great contributions!

no prob, stars are always appreciated!

@littlehoneybunnytuttifruttipumpkinpie

Are there nested tables?

Nope. (the above table example is the simplest that doesn't work)

@jonschlinkert
Copy link
Member

At minimum any bad syntax could be removed or replaced with a warning like

Yeah, that would make sense if it was intentional lol. Looks like a bug. I'll look into it, or a pr would be great. here is the table logic

@littlehoneybunnytuttifruttipumpkinpie

Oh, my JS knowledge is so basic, I have trouble looking through that :-)
But, I see some code that specifically checks for <h> tags inside the table?

if (/<h[1-6][^>]*>/.test(node.html)) {
        this.emit('\n', node);
        this.emit(node.html);
        return;
      }

@littlehoneybunnytuttifruttipumpkinpie

A possible solution could be to actually convert <h> to markup within the table before processing the table syntax. Or maybe convert <h[1-6]> to <b> as a workaround, before parsing the table. Developers could still replace that code with something else if they don't like the <b>.

@littlehoneybunnytuttifruttipumpkinpie

(I can probably do this via the "preprocess" event though)

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

No branches or pull requests

2 participants