-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add TODO lists support for Blackfriday (*.md files) #2269
Comments
Note: this is the top priority as Blackfriday is the main engine in use -- but it would be nice if this syntax was supported for both mmark and md. |
It looks like So you can just implement a custom |
Yes, we're not introducing another extension just to support TODO lists. And since implementing this means either implementing it or copying @shurcooL s lines, both of which should produce very similar results, I guess a copy of the method with a reference to the copyright owner above the method would be ok? |
No need to worry about giving me credit explicitly in the code, feel free to use my code in the most convenient way. It's trivial code anyway, just a |
So I tried to modify @shurcooL 's code but for some reason it is not adding the extra HTML. Here's the result of a small test:
Here's my code in content_renderer.go:
|
Have you looked at the sanitization code? It's possible the current policy strips out the new tags that are needed for this. If you look at my commit, it makes appropriate changes to the bluemonday sanitization policy. @@ -52,6 +52,8 @@ func Markdown(text []byte) []byte {
p.AllowAttrs("class", "name").Matching(bluemonday.SpaceSeparatedTokens).OnElements("a")
p.AllowAttrs("rel").Matching(regexp.MustCompile(`^nofollow$`)).OnElements("a")
p.AllowAttrs("aria-hidden").Matching(regexp.MustCompile(`^true$`)).OnElements("a")
+ p.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input")
+ p.AllowAttrs("checked", "disabled").Matching(regexp.MustCompile(`^$`)).OnElements("input")
p.AllowDataURIImages()
return p.SanitizeBytes(unsanitized) Does hugo also use bluemonday? If you uncomment Also,
I appreciate the nice gesture, but there's no need to pollute Go code files with such attribution comments. You have my full permission to use the (trivial) code without any comments about it. You've already given me attribution in this issue, etc. |
No, it doesn't.
Yes, the statement gets printed. |
I'm wondering if there's a place where you list out the custom methods that you've written for the renderer. You know, to register the custom methods. Maybe that's what's missing |
It's also strange that when I expect a |
@phtan I suggest you go to the Blackfriday site and read the documentation -- esp. about Bluemonday config. |
@bep I agree that the documentation should be read. But Blackfriday doesn't use Bluemonday, and as far as I can see, neither does Hugo. The documentation itself says:
https://gowalker.org/github.com/russross/blackfriday Bluemonday just isn't included/imported into Hugo, so how do I even begin to configure it? |
There is no such thing. You said it yourself that
Bluemonday was a guess. If it's not used by hugo, then it can't be the problem. What does hugo use to sanitize output? Or does it not sanitize it at all, meaning <script> would be printed as <script> rather than getting filtered out (or printed as <script>)? I suggest trying to add some print statements right after the markdown is rendered, before any further post-processing, and see if that works at preserving the task list HTML. |
Hugo doesn't do any sanitize other than what is done by Blackfriday and the Go template engine (and some URL magic). I assumed Blackfriday delegated to Bluemonday as it was mentioned here (which would not show up directly in Hugo imports). But the code path here should be pretty easy to debug. If you cannot figure it out, I may lend you an eye if you can open a PR with your code (just mark the PR with In progress or something) |
I don't know enough about the code-base to make the changes that are required for this issue. Let someone else take over the implementation of this issue. |
* Add CSS class to TODO list and list items * Add a flag to turn task list support off Fixes #2269
* Add CSS class to TODO list and list items * Add a flag to turn task list support off Fixes gohugoio#2269
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
See #2022
See shurcooL/github_flavored_markdown@2b74a5b
The text was updated successfully, but these errors were encountered: