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_cell callback doesn't pass MKD_TABLE_HEADER #604

Closed
mlambley opened this issue Feb 27, 2017 · 2 comments
Closed

table_cell callback doesn't pass MKD_TABLE_HEADER #604

mlambley opened this issue Feb 27, 2017 · 2 comments

Comments

@mlambley
Copy link

mlambley commented Feb 27, 2017

Forgive my newishness if this is a matter which I've overlooked. This is a snippet of my rb file.

class HTML < Redcarpet::Render::HTML
  include Rouge::Plugins::Redcarpet
  ...
  def table_row(content)
    "<tr>" + content + "</tr>"
  end

  def table_cell(content, alignment)
    #This part doesn't work. Alignment remains nil for both header and body cells.
    if alignment === "HEADER"
        "<th>" + content + "</th>"
    else
        "<td>" + content + "</td>"
    end
  end
  ...
end

In html.c in rndr_tablecell there is code

if (flags & MKD_TABLE_HEADER) {
	BUFPUTSL(ob, "<th");
} else {
	BUFPUTSL(ob, "<td");
}

The flags also contain MKD_TABLE_ALIGN_CENTER, MKD_TABLE_ALIGN__L, and MKD_TABLE_ALIGN__R for cell alignment.

However, the call back function which occurs in rc_render.c in rndr_tablecell only passes CSTR2SYM("left"), CSTR2SYM("right") or CSTR2SYM("center") to BLOCK_CALLBACK("table_cell", ....)

From this, and the fact that alignment remains nil whether it's a header or not, I can only conclude that the table_cell override in the rb file doesn't get told whether or not it's a header.

Could this information be included in the callback?

I'm currently going through the C code to see if I can suggest a fix for you.

@mlambley
Copy link
Author

PR created. See #605

@EricPickup
Copy link

EricPickup commented May 2, 2019

Bumping this issue, just ran into it today when trying to customize my table styling.

For now I'm manually checking if the content text matches one of my headers and adding the <th></th> tags if so, and use <td></td> otherwise.

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

No branches or pull requests

2 participants