These are chat archives for wooorm/remark

21st
Mar 2017
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:28
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:29
It's an issue inherent to the system of documentation...
(just spewing... haven't thought this out...)
an issue that i'm trying to, at least begin a discussion regarding, with love-notes
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:31
What is love-notes?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:32
It's a literate programming environment I'm working on -literally- right now.
(sorry... that first code snippet of index.md was -whack-, yo)
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:34
I think you should share it via gist.
:laughing:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:35
good idea...
(3 files in that gist)
the markdown file is run through the love-notes tangler and produces the js files
thus, documentation as prose, and code files built from the codefences in the markdown file
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:40
that way, documentation is becomes an explanation and exploration of the mindset of the developer at the time of creation, and not a secondary/afterthought.
i'm going to start on the weaver as soon as I figure out this last bug...
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:43
I have a concern about using #. It won't be valid for all languages. How would you tackle this problem?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:43
ahh... like # is a comment in coffeescript?
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:44
Also, writing jquery code has same problem.
$('#greet')
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:45
the #section hash is only valid if it starts, and is the only thing, on a line
so that's not a concern.
const sectionTag = /^#\S+$/
as for other languages, this first iteration specifically only targets js... i didn't want to get weighed down by trying to consider -all- possibilities...
in fact, the first version specifically fulfills -my- needs... though, it's fairly robust.
my needs are: I need a static blogging suite that I can just sit down, write code and prose, and also have that code be executable on the page...
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:50
love-notes is the engine behind that idea... and love-letters will be the full blogging tool
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:51
I understand what you want. :smile:
Could you tell me the development state? Is it still a concept?
yeah... the tangler (that is, the engine that takes the different code fences and ties them together into "compile-able" source) is complete for documents that produce only one source file... there's a small bug that I'm like... -literally- working out right for multi-sourced documents
that is... right now... both index.js and math.js get tangled to the same file.
I have an extensive test suite setup to verify this as well.
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 01:57
Could you show me the code of the engine?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 01:57
sure... let me commit/push
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 02:02
the app itself doesn't do anything... still working through tests
and all the tests fail right now, lol :(
i changed the naming of things and hadn't completed it... but the source is still there
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 02:12
I'll check it soon. Thanks for sharing. :smile:
Btw, Literate programming looks quite interesting for me too.
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 02:47
Did you add the test case for generating multiple file?
Also, mocks.defaultIndex method doesn't seem to exist.
  CodeFile › CodeFile#addBlockContentsToCodeSection
  /Users/dickchoi/Code/love-notes/test/CodeFile.spec.js:40

   39:   const cf = new CodeFile('index.js')
   40:   const blocks = mocks.defaultIndex()
   41:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 05:43
yeah.. that was the rename i was talking about
@Rokt33r i made another push a few minutes ago...
multiple files works well
working on bundling the library into a single file
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 05:46
Glad to hear that. :clap:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 08:40
and... the tangler is... complete(?): https://github.com/8-uh/love-notes
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:00
@siman you around?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:09
working on the weaver...
i've got a codefence that I want to insert its contents as a raw HTML node into the MDAST directly after the codefence
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:14
<div id="canvas-container">
  <canvas id="my-canvas"></canvas>
</div>
I want to insert a node:
{
  "type": "html",
  "value": "<div id=\"canvas-container\">\n <canvas id="my-canvas"></canvas>\n</div>"
}
but i want to keep the original node as well.
is there some kind of utility that will let me easily do that?
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 10:16
Are you using visitor?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:16
i am/could be.
i am. yes.
I'm visiting code blocks.
i know there's a way to 'eat'/replace nodes.. but man... the monorepo is so huge I can't find the documentation I'm looking for
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 10:19
So, you want to do is inserting HTML node instead of replacing. Is it right?
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:19
right...
if i visit a code node....
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 10:20
I understand...I think we should find some way to access the parent.
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:23
visit(ast, 'code', currentNode => {
  const cmd = parseCommand(currentNode.lang)
  if(cmd === COMMANDS.INSERT_INTO_MDAST) {
   /**
   * 1. Create new 'html' node type
   * 2. set htmlNode.value = currentNode.alue
   * 3. Insert htmlNode into MDAST immediately following currentNode
   **/
  }
})
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 10:28
https://github.com/syntax-tree/unist-util-visit-parents
This seems to work. Access parent node and insert html node by splice.
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 10:29
that's -exactly- the conclusion I came to about 30 seconds before you responded... but it's good to know that I'm on the right track...
thanks, @Rokt33r
will report back shortly
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 10:30
:+1:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:02
when i visit a node... if I modify the node, will it remain modified?
it won't will it?
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 11:02
As long as I know, it will.
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:03
seems like it's an enscoped argument... but it's easy to find out :D
holy crap... it does... it's a reference and not a value... -neat-
Titus
@wooorm
Mar 21 2017 11:20
Yes it does
visit also gets a parent node, if you just need one: https://github.com/syntax-tree/unist-util-visit#visitnode-type-visitor-reverse
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:23
so, i need to visit each code node, determine a thing about it, if said thing is true, i need to either get the parent, and then find current node's child index, or, somehow, immediately insert a node directly after the current one.
so...
visit(ast, 'code', node => {
  if(check(node)) {
    visit(node, null, parent => {
        const idx = parent.children.find(n => n === node)
        parent.children.splice(idx, 0, u('html', {value: node.value}))
    }, true)
  }
})
or, roughly there abouts?
(whoops.. forgot to add reverse)
Titus
@wooorm
Mar 21 2017 11:28
To get the following sibling, you can do:
visit(ast, 'code', function (node, index, parent) {
  console.log(parent.children[index + 1]);
})
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:28
... i'm an idiot
Titus
@wooorm
Mar 21 2017 11:29
No :)
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:29
thank you for making this so easy... and i'm sorry for making it so hard :P
Titus
@wooorm
Mar 21 2017 11:29
haha, no problem!
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:30
look.. there it is.. right ther ein the documentation visitor(node,index, parent)
so.. if i change the tree, will visit still work properly...
This message was deleted
visit(ast, 'code',  (node, index, parent) => {
  parent.children.splice(index, 0, new Node())
will the following visited nodes have the correct index?
Titus
@wooorm
Mar 21 2017 11:48
Nope, it doesn’t unfortunately
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:48
so, i'll need to keep track of how many nodes I've inserted
Titus
@wooorm
Mar 21 2017 11:49
Can you take a step back? What do you want to do?
(more globally)
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:50
Titus
@wooorm
Mar 21 2017 11:50
You could store all applicable node, index, parent pairs
And insert them all after the complete visit
ada-lovecraft @8-uh nods
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 11:52
that's a much more efficient and functional way of doing it... thank you
less side-effects
Titus
@wooorm
Mar 21 2017 11:52
:)
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 13:49
-nice-
inline weaving is complete
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 14:00
yes.
Titus
@wooorm
Mar 21 2017 14:01
oh lol, I didn’t read the text :p
:ok_hand:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 14:02
:3
the next big problem is: atom et al recognize markdown that either has nothing or a single language token following <pre>```</pre>
er... codefences
Titus
@wooorm
Mar 21 2017 14:08
Recognise where?
As in, when using the Atom markdown syntax highlighter, it knows about fences, right?
vs
Titus
@wooorm
Mar 21 2017 14:08
ahhhh
Yeah, pff
It’s in the new version of GitHub Markdown (GFM)
As used on the site
But not for older stuff / atom
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 14:10
time for a PR i supposed :3
Titus
@wooorm
Mar 21 2017 14:10
:p
it’s really new
so it’ll take a while to bubble through everywhere
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 14:11
well, as atom is a github project...
and i'm active in the atom slack... and... (hopefully) by this time next week I'll be on the electron/atom team... i think i can make it happen, if it isn't already happening.
Titus
@wooorm
Mar 21 2017 14:13
:+1: :+1: :+1:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 14:15
breakfast... bbl
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 18:26
woop!
just got scheduling request for interview round 3 @ github
Titus
@wooorm
Mar 21 2017 18:34
:+1: Awesome
Congrats Ada!
Junyoung Choi (Sai)
@Rokt33r
Mar 21 2017 18:35
Glad to hear that. Good luck! :clap:
Ada Lovecraft
@ada-lovecraft
Mar 21 2017 18:35
Thanks, y'all..
Also: -super- big ups for helping me this morning...
Titus
@wooorm
Mar 21 2017 18:36
Sure, no problem :)