Comments (1)
Investigating…
The code actually does find the H2 elements. The problem is that when an H2 is specified in HTML, unlike Markdown it isn’t automatically wrapped in a header anchor; we use markdown-it-anchor to do that for Markdown. So the code finds the H2 elements, but then ignores them because they don’t have an <a href class="observablehq-header-anchor">
inside.
So, you can declare a heading that is visible in the TOC like so:
<h2 id="this-is-a-test" tabindex="-1">
<a class="observablehq-header-anchor" href="#this-is-a-test">This is a test</a>
</h2>
(The tabindex
attribute is optional but recommended.)
To do this automatically, we’d need to duplicate the behavior of markdown-it-anchor for HTML H2 elements: automatically wrap them in an anchor and compute a unique slug based on the text content of the heading. Another possibility is that we require you to specify the id
attribute when specifying an H2 element in HTML (so that there is no ambiguity as to what the link should be); in general we treat HTML as a lower-level API to Markdown.
Probably this means we should not use markdown-it-anchor so we don’t have two code paths for generating heading links; instead, we let markdown-it render the ##
as a vanilla H2, and then we use the same code path for turning H2 into heading links regardless of whether it was specified as HTML or as Markdown.
from framework.
Related Issues (20)
- `observable build` should print a page size summary at the end HOT 1
- Multipart data loader archive/extractor format?
- File-based archive/extractor data loaders?
- Sidenav items do not (always) show active when they should, using cleanUrls: false HOT 3
- Destructuring Doc Suggestion HOT 1
- Deploying a file >50MB can cause a Cloudflare 520 error
- DuckDB WASM large file size HOT 1
- docs: some library examples not listed in sidebar HOT 1
- server-side includes / transclusion HOT 2
- The scripts configuration option seems broken for local scripts HOT 1
- deprecate the scripts option HOT 1
- Trouble with data in getting started example HOT 2
- `FileAttachment.lastModified` does not exist after file change (in preview mode) HOT 3
- search links aren't clickable on a small screen
- Resize helper doesn't work properly if preceded by an empty line or code block HOT 1
- Arquero import fails HOT 3
- Loading indicator may get stuck in Safari
- FileAttachement[parquet]: "Failed to bundle using Rollup"
- Data loader examples
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 framework.