Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom HTML #105

Closed
ooker777 opened this issue Feb 2, 2024 · 7 comments
Closed

Allow custom HTML #105

ooker777 opened this issue Feb 2, 2024 · 7 comments

Comments

@ooker777
Copy link

ooker777 commented Feb 2, 2024

I would like this code to render my custom marker. I don't want to style everything in the style.css.

import { CSS, render } from "https://deno.land/x/gfm/mod.ts";

const body = render(`# Hello, world!
<ul style="list-style-type: '&#x1F514; ';">
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

- Normal list
- Normal list
- Normal list
`);

export default function a() {
    return <main dangerouslySetInnerHTML={{ __html: body }}>
    {body}
    </main>
} 
@deer
Copy link
Contributor

deer commented Feb 3, 2024

Again it would be great if you could provide more details. In this particular case about the current output and the expected output.

Although to keep things short, I guess you want to do something like this:

  const body = render(
    `# Hello, world!
<ul style="list-style-type: '&#x1F514; ';">
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

- Normal list
- Normal list
- Normal list
`,
    { allowedAttributes: { ul: ["style"] } },
  );

@deer
Copy link
Contributor

deer commented Feb 3, 2024

Please close this if using allowedAttributes solves your problem.

@ooker777
Copy link
Author

ooker777 commented Feb 3, 2024

It looks promising, but not working on my machine. The full code:

import { render } from "https://deno.land/x/gfm/mod.ts";

const body = render(
  `# Hello, world!
<ul style="list-style-type: '&#x1F514; ';">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ul>

- Normal list
- Normal list
- Normal list
`,
  { allowedAttributes: { ul: ["style"] } },
);

export default function a() {
  return <main dangerouslySetInnerHTML={{ __html: body }}>
  {body}
  </main>
} 

There is an error at allowedAttributes: Object literal may only specify known properties, and 'allowedAttributes' does not exist in type 'RenderOptions'.deno-ts(2353)

@deer
Copy link
Contributor

deer commented Feb 3, 2024

It's always a good idea to be explicit about versions. You likely have an old version cached. Try specifying the version like this: https://deno.land/x/gfm@0.6.0/mod.ts

@ooker777
Copy link
Author

ooker777 commented Feb 4, 2024

I see. I thought that if you don't specify the version, the runtime will check if the cache is already in the latest version or not. I also notice that the allowedAttributes option is only introduced at 0.6.0. However the release note doesn't note this. Is this normal?

@ooker777 ooker777 closed this as completed Feb 4, 2024
@deer
Copy link
Contributor

deer commented Feb 4, 2024

Blindly using the latest version can be, at worst, a huge security vulnerability and, slightly less bad, can sometimes cause your code to break. I can't really imagine a case where always using the latest is desired.

As for the caching issue, I guess if you had reran your code with -r it would have reloaded the dependencies.

For the release notes, most projects just take a list of all the PRs that have been merged. You can see I'm there:

feat: custom tags and attributes by @deer in #95

What more are you expecting?

@ooker777
Copy link
Author

ooker777 commented Feb 4, 2024

I see. Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants