Coder Social home page Coder Social logo

Comments (8)

gettalong avatar gettalong commented on August 30, 2024 3

You can do the following:

<div class="table-wrapper" markdown="block">
| some | table | here |

</div>

This also works if parse_block_html is false.

from kramdown.

bric3 avatar bric3 commented on August 30, 2024 2

Just a feedback, now this tweaks only works if there's blank lines before and after the markdown text. i.e. :

<div class="table-wrapper" markdown="block">

| some | table | here |

</div>

Not an expert on the topic.
Maybe there's this alternative : http://stackoverflow.com/questions/22291211/jekyll-how-to-get-markdown-parsing-inside-blocks-using-kramdown

from kramdown.

weibeld avatar weibeld commented on August 30, 2024

In kramdown v1.15.0 also works with only a blank line after the kramdown table:

<div markdown="block">
| some | table | here |

</div>

Output:

<div>
  <table>
    <tbody>
      <tr>
        <td>some</td>
        <td>table</td>
        <td>here</td>
      </tr>
    </tbody>
  </table>

</div>

However, this blank line after the kramdown table is necessary, otherwise the content of the div is not rendered by kramdown, and copied verbatim to the output.

from kramdown.

zabetak avatar zabetak commented on August 30, 2024

The suggestions proposed in the discussion so far look more like workarounds than a solution to the problem. If I have 100 markdown tables (and I want them to be scrollable) I have to add boilerplate code (div tags) everywhere. Moreover, if someone in the future adds another markdown table they need to remember to add the boilerplate code otherwise the table may not adapt well to the screen size.

Can't we have a configuration flag that allows to generate the wrapper div around tables on demand?
@gettalong It seems like a useful feature should we consider reopening this issue?

from kramdown.

gettalong avatar gettalong commented on August 30, 2024

@zabetak You wouldn't need to do it for every table, just adapt the HTML converter to your liking. Ie. add the <div> in the #convert_table method.

from kramdown.

zabetak avatar zabetak commented on August 30, 2024

@gettalong Thanks for the clarification. I am just discovering the Kramdown project (which is quite cool by the way :)) so apologies if I ask/suggest trivial things.

If I understand well you suggest to extend the HTML converter and override the behavior of convert_table method right?

Just to complete the picture we are using Kramdown via Jekyll so to achieve what you suggest it appears to me that we should add custom Jekyll plugin and plug a custom subclass of HTML converter. Seems doable but it is a bit of overhead for something which appears a common use-case.

from kramdown.

gettalong avatar gettalong commented on August 30, 2024

@zabetak As I don't use Jekyll I can recommend the correct way of adding a custom converter or overriding the standard HTML converter. So please ask at Jekyll for how to do that.

The thing is: Everybody would like to have something like this in kramdown proper but it isn't the right place. There is a standard HTML converter that does its best to generate valid XHTML, without too much fuss. It is intentional that there aren't many knobs to customize the converter because checking all those knobs would slow things down from a performance standpoint, without much benefits for most people.

from kramdown.

zabetak avatar zabetak commented on August 30, 2024

@gettalong Undestood thanks for taking the time to comment on this!

from kramdown.

Related Issues (20)

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.