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

Concurrent use of goldmark-highlighting ? #41

Open
chmike opened this issue May 25, 2024 · 1 comment
Open

Concurrent use of goldmark-highlighting ? #41

chmike opened this issue May 25, 2024 · 1 comment

Comments

@chmike
Copy link

chmike commented May 25, 2024

Apparently, according to this goldmark issue, the goldmark instance created with New can be used concurrently with multiple go routines rendering different Mardown text.

I may have misunderstood it's usage, but it seam that this property is not preserved by the use of WithCSSWriter as the same writer is shared by different concurrent Rendering operations.

It's correct or intended usage may need a clarification.

If we want to inline the css as a style in the head of the web page, we would need to support concurrent css writing. To do that it seam the the CSS writer should be passed as a context variable.

Will this option ensure that the css is written only once ?

@yuin
Copy link
Owner

yuin commented May 28, 2024

This option does not ensure that the css is written only once.
Currently, we have choices...

  • Make a CSS writer goroutine-safe yourself
  • Use 1 goldmark per goroutine

Another thoughts: Add an interface for writing CSS

type CSSWriter interface {
   WriteCSS(p []byte) (n int, err error)
}

If a writer implements a CSSWriter, goldmark-highlighting will wirte CSS using this method.
I feel more straightforward for the purpose.

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