Skip to content

Feature Request: Default Classes for each HTML element type #376

Closed
@subodhpareek18

Description

I have read the documentation and gone through some of the issues, it seems like with some effort it might be possible to make an extension that does the required job. But I feel it really makes sense to have this functionality within the core library.

A lot of people use css ui kits like bootstrap, semantic-ui, etc. And if we could pass a bindings map object like so:

const classBindings = {
  h1: '.ui.large.header',
  h2: '.ui.medium.header',
  ul: '.ui.list'
  li: '.ui.item'
}

const converter = new showdown.Converter({ classBindings });

const text = `
# 1st Heading
## 2nd Heading

- first item
- second item
`
return  converter.makeHtml(text);
<h1 class="ui large header">1st Heading</h1>
<h2 class="ui medium header">2nd Heading</h2>
<ul class="ui list">
  <li class="ui item">first item</li>
  <li class="ui item">second item</li>
</ul>

Though if you think writing an extension for consuming this mappings object will be a very easy task, then could you please guide me on the same?

If possible I'd like to have the example added to the docs as well, like a recipe of sorts, so that other people can use it for bindings with any css ui kit of their choice.

And thanks so much for this wonderful library! 😁

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions