You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 79f0de6
Browse filesBrowse the repository at this point in the historyBrowse files
This package turns ordinary `<codeblock>` tags into editable, runnable C++ examples. It starts with a small textarea editor, upgrades to Monaco when the main bundle is ready, and runs a WebAssembly build of clangd for code help. Multiple blocks on one page share the same runtime, worker, and clangd download.
3
+
This package turns ordinary `<codeblock>` tags into editable, runnable examples. It starts with an immediate syntax-highlighted simple editor, upgrades to Monaco when the block approaches the viewport, and runs a WebAssembly build of clangd for C++ code help. Multiple blocks share one VS Code runtime, worker, clangd process, and download.
4
4
5
5
This project started as a fork of the excellent https://github.com/guyutongxue/clangd-in-browser/.
6
6
@@ -12,7 +12,7 @@ Copy the complete contents of `dist/` to one public directory, then include one
<codeblock-tabname="first.cpp"> int main() { return 1; } </codeblock-tab>
29
29
<codeblock-tabname="second.cpp"> int main() { return 2; } </codeblock-tab>
30
30
</codeblock>
31
31
```
32
32
33
-
Each tab keeps its own source. Run compiles the active tab. Use separate `<codeblock>` elements when examples need different compiler settings.
33
+
Tabs are independent examples by default. Add `multi-file` to send the inactive
34
+
tabs to Compiler Explorer as extra files. A hidden supporting tab implies
35
+
multi-file mode. Use `build-system="cmake"` and a hidden `CMakeLists.txt` tab
36
+
for a CMake request. Switching independent or grouped tabs always clears stale
37
+
output.
34
38
35
39
Supported attributes are:
36
40
37
-
-`compiler`: Compiler Explorer compiler ID, defaulting to `clang2110`.
38
-
-`args`: arguments sent unchanged to Compiler Explorer.
41
+
-`language`: editor/simple-mode and Compiler Explorer language, defaulting to `c++`.
42
+
-`compiler`: Compiler Explorer compiler ID. C++ defaults to `clang2110`; languages without an explicit default require this attribute.
43
+
-`compiler-args` (JavaScript: `compiler_args`): arguments sent to the compiler. The old `args` name remains a deprecated alias.
44
+
-`run-args` (JavaScript: `run_args`): arguments passed to the compiled program.
45
+
-`stdin`: standard input passed to the compiled program.
46
+
-`output-views`: comma-separated `execution`, `compiler`, `assembly`, or `tool:TOOL_ID` views. Requesting `execution` controls whether the compiled program runs; assembly is returned by the same compile request.
47
+
-`output-position`: `below`, `side`, or `custom`. Custom suppresses built-in output rendering.
48
+
-`live`: enable live output with a 500 ms debounce, or set the debounce as milliseconds.
49
+
-`readonly`: prevent reader edits. It has no reader-facing toggle.
50
+
-`inline`: transparent, automatically sized, read-only presentation with Monaco/clangd support. The shorter `<cb>code</cb>` tag is equivalent to an inline, read-only `<codeblock>`.
51
+
-`simple`: keep the simple editor/highlighter and never initialize Monaco or clangd. It works on both `<codeblock>` and `<cb>`.
52
+
-`src`: load source from a same-origin or CORS-enabled URL.
53
+
-`range="START[:COLUMN]-END[:COLUMN]"`: show only a source window while compiling the complete file. Columns follow C++ source-range semantics: the start is included and the end is excluded. The equivalent `start-line`, `end-line`, `start-column`, and `end-column` attributes are also available. Ranged views are read-only.
54
+
-`highlight-lines="2-4,7"`: persistently highlight source lines. Line numbers refer to the complete source file and are translated into a visible `range` automatically.
55
+
-`fit`, `fit="height"`, or `fit="width"`: fit the editor to its content in both dimensions or one dimension.
56
+
-`multi-file`: compile the active tab with the remaining tabs as extra files. `build-system="cmake"` uses the CMake API and treats `CMakeLists.txt` as the project source.
57
+
-`editable-options`: show the reader-editable compiler and execution settings, or name a comma-separated subset. Result views are selected by the output tabs; the legacy `output` field is only shown when named explicitly.
-`compiler-explorer-link`: replace the generated Compiler Explorer destination with an author-provided URL. JavaScript consumers use `compilerExplorerLinkUrl`.
60
+
-`info-name`, `info-description`, and `source-url`: customize the information popover.
61
+
-`editor-options` and `styles`: JSON objects matching the JavaScript options.
62
+
-`no-render-output`: send results only to the JavaScript callback/API.
39
63
-`ce-url`: Compiler Explorer base URL, defaulting to `https://godbolt.org/`.
40
64
-`ce-language`: language stored in the Compiler Explorer client state, defaulting to `c++`.
41
65
-`ce-compiler`: legacy fallback for the compiler when `compiler` is absent.
42
-
-`ce-options`: legacy fallback for arguments when `args` is absent.
66
+
-`ce-options`: legacy fallback for arguments when `compiler-args` is absent.
67
+
-`ce-libs`, `ce-special-outputs`, `ce-tools`, and `ce-overrides`: JSON values forwarded to Compiler Explorer.
43
68
-`ce-filters`: JSON object overriding Compiler Explorer output filters, such as `'{"intel":false,"demangle":true}'`.
44
69
-`theme`: `auto`, `light`, or `dark`.
45
-
-`debug`: show the basic/full editor and light/dark switches. These are hidden by default.
70
+
-`debug`: log editor and clangd lifecycle details to the console.
46
71
-`width`: any valid CSS width for the complete block.
47
72
-`height`: any valid CSS height for the editor area, such as `280px`, `40vh`, or `clamp(240px, 50vh, 600px)`.
48
73
-`min-height`: any valid CSS minimum height for the editor area.
@@ -74,24 +99,28 @@ Supported attributes are:
74
99
```
75
100
76
101
Call `CodeBlocks.configure(options)` before a block is upgraded to set defaults
77
-
for later blocks. The available options are `theme`, `showDebugControls`,
0 commit comments