jostylr / literate-programming-lib

The library component of literate-programming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Block-less directive use?

yrashk opened this issue · comments

I have my own directive defined in reactuate that allows me to define package requirements in place. For example,

To enable React-specific features, a number of Babel plugins is required:

* [babel-plugin-react-transform@2.0.0](# ":|dependency")
* [babel-preset-react@6.3.13](# ":|dependency")
* [babel-preset-react-hmre@1.0.1](# ":|dependency")

I am, however, having a little bit of a trouble using these directives in the middle of a split blocks:

   (code)

Reactuate also allows importing CSS files with [css-loader](https://github.com/webpack/css-loader) [css-loader@0.23.1](# ":|dependency").

   (continue the code)

It just stops the production of the right after (code), and I understand why. However, I am trying to understand if it is possible at all to have a kind of a "block-less directive" that doesn't "capture" the next code block?

I think I found a workaround. If I do it like this:

Reactuate also allows importing CSS files with [css-loader](https://github.com/webpack/css-loader) [css-loader@0.23.1](# ":|dependency")[]().

Then I achieve what I need. Not sure if it is the best way, though...

What you are using is an interesting hack on the switch directive. A link with a title that starts with a colon will largely mark the beginning of a switch code block. By putting an empty link you are switching back to the main block (I think).

The define directive creates what I call commands, not directives. Commands are what comes after the pipes. The ones with names before the colons are directives. They don't necessarily take up the code block. In fact, only the switch directives do though many of them will refer to the current block if you use # for the href in the link.

What almost fits your case is the push directive. This takes a value and pushes it onto an array under the stored name. Then at the end, one can join them up and even go through them one by one first. I currently have it setup so that it reads it from a block, but I will implement it so that one can do something like [deps | core@5.0](# "push:|dependency") which would take core@5.0 and run it through dependency to become "core":"5.0" and then push that onto the array deps. Then at the end, you should be able to do _"deps| .join \n\," in a code block.

One could also use .mapc to do the dependency management later and not have to have that command executed all along. Or one could define the dependency command to take in an array and return a string.

Anyway, I need to enable the syntax of [var | value](# "push:")

Awesome, I am looking forward to the new syntax! With .mapc, I presume one would be able to do just [deps | core@5.0](# "push:")?

Should be done as of v 1.9.0. Install litpro 0.12.0

Thanks, everything works as expected!

Looks like in this syntax, whitespace is names is not allowed. Is this intentional?

Can you give an example? It should be no different than before. The leading and trailing spaces are removed, i.e., <!--+ hi everybody --> becomes hi everybody . Otherwise, any other white space removal is unintentional.

I didn't mean the comment syntax, but the [var | value] one.

I don't find any issues with white space in the new syntax. Can you give me an example of what's not working?

I tried something like [ first one | 2] and it worked fine. The leading and trailing spaces are removed, but the interior spaces are left as is. Perhaps you have a mismatch of internal spaces?