Customizing HTML output of blackfriday

I see from the source of Black Friday that there are pretty much no options for customizing HTML output. There is a fork of the project called mmark which is quite similar but has many more extensions. Maybe Hugo could use this renderer instead of/in addition to Black Friday?

The problem I’m running into that prompted me to inquire about this is that I use the table extension to Markdown often, and I’m using Bootstrap. The normal table rendering basically has no style. To apply Bootstrap’s styling, you have to add the “table” class (they required this because lots of tables are used incorrectly for things other than tabular data).

So right now I have this:

$(function() { $('table').addClass('table table-striped'); })

just run instead. It works okay but is definitely a kludge. I can’t figure out how to just apply it automatically without forking blackfriday (https://github.com/russross/blackfriday/blob/master/html.go#L293 shows how simple this would be) or building bootstrap on my own with an option to change the table-styling selector.

You don’t have to fork Blackfriday to do the above. The table func could be overridden, but you would need to do that in Hugo.

I’m facing the same issue. Can you please explain what you mean by “do that in Hugo”?

You can do similar with the other methods.

Can you elaborate on where you do this? I need to fix this issue as well and I am VERY new to hugo and completely naive in Go. Your help would be greatly appreciated!

Gus

1 Like

Hey @GusDunn. You’re including the bootstrap CSS, right? If so, you can put that anywhere in your page (in a <script> tag of course). The footer would be a good place. Depends on your template; I wrote my own layout entirely so I stuck it in layouts/partials/footer.html.

Of course, this will apply the Bootstrap table to all tables on the page. So if you’re using tables for layout instead of tabular data (bad!) then terrible things will happen.

THanks. and no, I am using grid stuff for layout. thanks so much!

Has anyone figure out how to add the table and table-striped classes without having to use the jQuery trick or forking Hugo ??

1 Like