Add new R pipe support#127
Conversation
token types are PIPE and PIPEBIND
This comment was marked as resolved.
This comment was marked as resolved.
| "'$'", "'@'","'~'", "'?'", "':'", "SPECIAL" | ||
| "'$'", "'@'","'~'", "'?'", "':'", "SPECIAL", | ||
| # pipes | ||
| "PIPE", "PIPEBIND", "PLACEHOLDER" |
There was a problem hiding this comment.
Hmmm, are you sure PLACEHOLDER should be treated as infix? I would think it should maybe just go in special?
There was a problem hiding this comment.
This _ felt more like an operator to me (with +, -, <, > ...) than a special like function(), switch() or other.
Among KDE default style, dsOperator seemed the closest. dsConstant was my second choice but it is supposed to be Number related.
However, I am ok to apply dsKeyword - I don't mind changing.
However, out of curiosity, I compared with other languages which have placeholder and it seems they are not highlighted specifically.
```scala
val f = _ + _
```<div class="sourceCode" id="cb1">
<pre class="sourceCode scala"><code class="sourceCode scala">
<span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>
<span class="kw">val</span> f <span class="op">=</span> _ <span class="op">+</span> _
</span>
</code></pre>
</div>and
```python
for _ in range(10):
print "hello"
```<div class="sourceCode" id="cb1">
<pre class="sourceCode python"><code class="sourceCode python">
<span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>
<span class="cf">for</span> _ <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">10</span>):</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span> <span class="st">"hello"</span>
</span>
</code></pre>
</div>Does not seem like current KDE file does a special treatment for this _ as placeholder character.
Highlight JS also does nothing special for the above snipper.
There was a problem hiding this comment.
Hmmm maybe we should just treat it as a SYMBOL?
There was a problem hiding this comment.
| "'$'", "'@'","'~'", "'?'", "':'", "SPECIAL" | ||
| "'$'", "'@'","'~'", "'?'", "':'", "SPECIAL", | ||
| # pipes | ||
| "PIPE", "PIPEBIND" |
There was a problem hiding this comment.
Sorry, I meant you should do the transformation in this function, so we only need to do it in one place.
There was a problem hiding this comment.
Oh ok. I was under the impression you did associate some token classes from R parsed data to some chroma or pandoc classes directly. So I went with that for this one too as token_type() seemed to handle special grouping of some token type in infix, special, constant and parens groups.
I'll adapt
There was a problem hiding this comment.
Oh yeah, that's reasonable read — I think this is different because PLACEHOLDER is only a single token so it makes more sense to lump it into one of the other classes.

This PR closes #126
Parsing shows that token are
PIPEandPIPEBINDI have put them in the
infixcategory with the magrittr pipe.For new placeholder we have
PLACEHOLDERtokenNot sure which highlight class it should have. Proposal in operator too for this one.
Added tests dependent on R requirement. Snapshots seems ok to use here.