Skip to content

Attach location to Rehype's HTML elements from Remark #97

Discussion options

You must be logged in to vote

Welcome!
Assuming https://github.com/remarkjs/remark-rehype (wrapper around https://github.com/syntax-tree/mdast-util-to-hast) is being used.
The position information of the node should be carried through from MDAST to HAST.
Which could be used to set the position in the HAST/HTML based of the cursor position in the Markdown/MDAST.

An example with positional information:

const report = require('vfile-reporter')
const unified = require('unified')
const markdown = require('remark-parse')
const remark2rehype = require('remark-rehype')

unified()
  .use(markdown)
  .use(remark2rehype)
  // stringify HAST directly
  .use(function () {this.Compiler = (tree) => JSON.stringify(tree, null, 4)})
  .p…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@wooorm
Comment options

@wooorm
Comment options

@thien-do
Comment options

@leafac
Comment options

@thien-do
Comment options

Answer selected by wooorm
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants