These are chat archives for wooorm/remark

3rd
Mar 2017
Jonathan Haines
@BarryThePenguin
Mar 03 2017 06:19
Just been migrating our internal remark-presets to use v7
so far so good :grimacing:
first comment from colleagues is "why so many modules 😭 "
Titus
@wooorm
Mar 03 2017 10:53
hahaha
Yeah, I get that
That’s why you’re using presets!
So you only have to install one or two presets, and don’t need huge config files (other than those presets, of course)
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:51

@wooorm

var doc = unified()
  .use(markdown)
  .use(math)
  .use(remark2rehype)
  .use(katex)
  .use(html)
  .process('# Alpha\n\nBravo $$x$$ Charlie')
  .toString();

Rokt33r/remark-math#4

Your suggestion doesn't seem to work.
remark-html can't recognize element node of hast.
It transforms {type: 'element', tagName: 'p'} into {type: 'element', tagName: 'div'}just like handling an unknown node.

I don't think it is intended. I'll make a PR for remark-html to handle element node.
Titus
@wooorm
Mar 03 2017 14:53
Could you add the rest of the example?
What does html refer to?
Because I think it should be html = require('rehype-stringify'), not html = require('remark-html')
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:54
Yes, I've already checked`rehype-stringify. It works when I use it.
Titus
@wooorm
Mar 03 2017 14:55
Okay, so what’s the problem then?
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:55
var unified = require('unified');
var markdown = require('remark-parse');
var math = require('remark-math');
var remark2rehype = require('remark-rehype');
var katex = require('rehype-katex');
var html = require('remark-html');

var doc = unified()
  .use(markdown)
  .use(math)
  .use(remark2rehype)
  .use(katex)
  .use(html)
  .process('# Alpha\n\nBravo $$x$$ Charlie')
  .toString();
This was your original suggestion of the usage.
Titus
@wooorm
Mar 03 2017 14:55
Ohhh sorry
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:55
So, using remark-html is wrong. Right?
Titus
@wooorm
Mar 03 2017 14:56
-var html = require('remark-html');
+var html = require('rehype-stringify');
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:56
Looks good. :smile:
Titus
@wooorm
Mar 03 2017 14:56
:+1:
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 14:57
Btw, is it okay to make another plugin for remark-html?
like, remark-math-katex, the most original suggestion of mine.
Titus
@wooorm
Mar 03 2017 14:58
Well, remark-html basically does .use(remark2rehype).use(rehypeStringify), which is useful if you want just that, but if you want something different, then you should use remark2rehype and rehypeStringify directly, in my opinion
It’s OK though, of course — if you want to, feel free!
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:01
Okay, I'll make 2 plugins, remark-math-katex and rehype-katex. Also, I'll extract the transforming function for both of them to share same api just like mdast-util-* stuff.
Titus
@wooorm
Mar 03 2017 15:02
Awesome!
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:02
Btw, I'm afraid about the name of them. Is it good to use remark-math-katex and rehype-katex?
Titus
@wooorm
Mar 03 2017 15:02
Note: hast-util-* is for the HAST syntax, mdast-util-* for markdown
Why not remark-katex?
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:03
If it looks better for you, I'll do as your wish
Titus
@wooorm
Mar 03 2017 15:03
Haha
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:03
My English is not perfect yet. :cry:
Titus
@wooorm
Mar 03 2017 15:04
Well, if it requires remark-html, maybe remark-html-katex
Otherwise use remark-katex
require == the user needs to use it too
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:07
Okay, I'll name it remark-html-katex.
Titus
@wooorm
Mar 03 2017 15:08
:+1:
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 15:08
Thanks for the feedback. :sparkles: :sparkles:
Titus
@wooorm
Mar 03 2017 15:08
No problem!
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 18:59
@wooorm Why rehype-parse doesn't use position option?
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 19:18
I created wooorm/rehype#7 .
I thought it would be great for deep matching of hast tree with hastscript when testing.
If you don't need it, you can pass it. :fire:
Junyoung Choi (Sai)
@Rokt33r
Mar 03 2017 22:54
Remark Math v0.2 released. https://github.com/Rokt33r/remark-math