How do I emit a class attribute on table element #177

Open
opened 2026-01-29 14:29:31 +00:00 by claunia · 4 comments
Owner

Originally created by @markheath on GitHub (Dec 29, 2017).

First of all, huge thanks for this library - it's really helped me on a recent project.

I'm using the PipeTableExtension for tables, and I'd like the tables to be emitted with a particular class. i.e.

<table class="my-table">
    <thead> ...etc

I've had a browse through the code and it looks like there is some kind of baked in support for rendering attributes on HTML elements, but I can't work out how to configure my pipeline to do this. Is it possible?

Originally created by @markheath on GitHub (Dec 29, 2017). First of all, huge thanks for this library - it's really helped me on a recent project. I'm using the `PipeTableExtension` for tables, and I'd like the tables to be emitted with a particular class. i.e. <table class="my-table"> <thead> ...etc I've had a browse through the code and it looks like there is some kind of baked in support for rendering attributes on HTML elements, but I can't work out how to configure my pipeline to do this. Is it possible?
claunia added the questionenhancement labels 2026-01-29 14:29:31 +00:00
Author
Owner

@AdmiringWorm commented on GitHub (Dec 29, 2017):

@markheath I could be wrong, but I believe it is enabled with the following:

var pipeline = new MarkdownPipelineBuilder().UseGenericAttributes().Build();
@AdmiringWorm commented on GitHub (Dec 29, 2017): @markheath I could be wrong, but I believe it is enabled with the following: ```cs var pipeline = new MarkdownPipelineBuilder().UseGenericAttributes().Build(); ```
Author
Owner

@xoofx commented on GitHub (Dec 30, 2017):

@markheath You can have a look at the Bootstrap extension on how to add this. I will likely add an extension to perform these kind of changes in a more "generic" way.

@xoofx commented on GitHub (Dec 30, 2017): @markheath You can have a look at the [Bootstrap extension](https://github.com/lunet-io/markdig/blob/master/src/Markdig/Extensions/Bootstrap/BootstrapExtension.cs) on how to add this. I will likely add an extension to perform these kind of changes in a more "generic" way.
Author
Owner

@markheath commented on GitHub (Dec 30, 2017):

Thanks, works perfectly

@markheath commented on GitHub (Dec 30, 2017): Thanks, works perfectly
Author
Owner

@tesar-tech commented on GitHub (Dec 5, 2020):

(I know it's an old question)

Also GenericAttributesSpecs could be helpful.

@tesar-tech commented on GitHub (Dec 5, 2020): (I know it's an old question) Also [GenericAttributesSpecs](https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/GenericAttributesSpecs.md) could be helpful.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#177