Comments (11)
Maybe it makes sense to add codeblock language id to <pre>/<code>
tags to enable userscript-based highlighting/rendering.
Update: this should actually work https://github.com/rsc/markdown/blob/0bf8f97ee8ef6dc359b2246680d8f48c37da77f1/code.go#L24-L39
maybe pkgsite uses old rsc.io/markdown
version.
from go.
I don't know if it's worth making the change in https://go.dev/cl/585955 if it's only going to be used by users who enable a custom script locally.
from go.
I don't know if it's worth making the change in https://go.dev/cl/585955 if it's only going to be used by users who enable a custom script locally.
Absolutely, that sounds like a more appropriate approach. By utilizing a script to generate necessary files from upstream sources, you can easily place the URL file where pkgsite can display it. This strategy enables flexibility with various tools, eliminating the need to confine yourself to just one option.
from go.
We discussed this in our triage meeting and decided that the benefit of the feature is not worth the costs and risks. Go's pkg.go.dev site was never intended to fully simulate GitHub's markdown renderer.
from go.
@adonovan @matloob What are the risks of adding a css class to the html element?
The costs and risks of adding a class attribute are very low, though the value seems low also. I would not object to https://go.dev/cl/585955, though I defer to @matloob.
The feature I was referring to as "not worth the costs and risks" is the mermaid rendering that is the subject of this issue.
from go.
Supporting Mermaid.js in pkgsite would likely introduce unnecessary complexity and potential performance issues without significant benefits for Go developers.
from go.
Change https://go.dev/cl/585955 mentions this issue: sanitizer: allow code block language class
from go.
With the change https://go.dev/cl/585955 it should be possible to enable syntax highlighting and mermaid rendering via UserScript:
// ==UserScript==
// @name pkg.go.dev syntax highlight
// @namespace Violentmonkey Scripts
// @description Adds syntax highlighting to code blocks
// @match https://pkg.go.dev/*
// @resource css https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.css
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js
// @grant GM_addStyle
// @grant GM_getResourceText
// @version 1.0
// @author https://github.com/AlexanderYastrebov
// ==/UserScript==
GM_addStyle(GM_getResourceText("css"));
(function (){
hljs.highlightAll();
mermaid.initialize({ startOnLoad: false, theme: 'dark' });
mermaid.run({ querySelector: '.language-mermaid' });
})();
from go.
Supporting Mermaid.js in pkgsite would likely introduce unnecessary complexity and potential performance issues without significant benefits for Go developers.
Given mermaid code blocks look like:
```mermaid
...
```
It seems reasonable to assume that the server/page could just not load mermaid code when there's no mermaid blocks, so I don't think this would have any overhead, no?
from go.
I don't know if it's worth making the change in https://go.dev/cl/585955 if it's only going to be used by users who enable a custom script locally.
@matloob
What is the problem or risk to enable already existing codeblock language metadata?
Userscript is the straightforward usecase but there might be others like hints to the crawlers or corporate pkgsite deployments with syntax highlight by default.
from go.
@adonovan @matloob What are the risks of adding a css class to the html element?
from go.
Related Issues (20)
- os/exec: Cmd.Wait Cmd.StderrPipe data-loss race condition go1.22.3 240525 darwin-arm64 14.5 HOT 4
- runtime: SIGSEGV after performing clone(CLONE_PARENT) via C constructor prior to runtime start [1.22 backport] HOT 1
- syscall: Setuid undefined on aix HOT 1
- cmd/link/internal/ld: TestElfBindNow/bindnow-pie-linkmode-external failures HOT 1
- runtime/cgo: cgo can't work with some old versions glibc HOT 2
- make.bash: ~/go1.4/bin/go: no such file or directory after CL 582076 HOT 3
- net/http: infinite redirect on path variable followed by trailing slash
- x/tools/gopls: export LSP types so they can be imported by external consumers HOT 2
- x/website: add more detail about GOPATH and where to clone src code in contribution guide
- cmd/go: for every test run in go/testdata/script results in windows command prompt rapidly opens and closes HOT 2
- cmd/go: internal compiler error: assertion failed: on source consisting of {panic, declaration, label} HOT 2
- math: math.Mod(Exp(63.5)*10000.0, 100.0) return different values between C exp() HOT 1
- x/tools/gopls: add control flow token support HOT 2
- x/net/http2: requests experience excessive time delays when encountering network errors HOT 1
- net/http: Inconsistent output with req.URL.RequestURI() HOT 1
- x/tools/gopls: failed to install gopls@latest with VSCode extension and Go 1.18 HOT 3
- cmd/compile: different results from runtime.Caller HOT 4
- proposal: x/sys/unix: add MmapPtr/MunmapPtr HOT 1
- runtime: unexpected return pc for github.com/pact-foundation/pact-go HOT 4
- x/net/http2: h2c requests can't be sent when *http.Request.Close is true HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.