Skip to content

How enable/add custom attributes/enable any attribute? #47

Answered by JiLiZART
wintercounter asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @wintercounter you can extend default html5 preset.

import html5Preset from "@bbob/preset-html5";
import toHTML from "@bbob/html";

const myPreset = html5Preset.extend(tags => ({
  ...tags,
  b: (node, params) => ({
    ...tags.b(node, params),
    attrs: {
      style: "font-weight: bold;"
    },
    content: JSON.stringify(node.attrs)
  })
}));

document.body.innerHTML = toHTML(`[b @class="myClass"]Text[/b]`, [myPreset()]);

Demo example
https://codesandbox.io/embed/blue-water-l0pc6

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JiLiZART
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #47 on December 10, 2020 20:44.