language-markdown icon indicating copy to clipboard operation
language-markdown copied to clipboard

Add R Markdown support (part deux)

Open burodepeper opened this issue 9 years ago • 7 comments

  • [ ] Add better/wider support for using functions as attribute values (ie, {r code=capture.output(dump('fivenum', ''))})
  • [ ] Use value of engine attribute to parse the contents of the code-block
  • [x] Bug: trailing space shouldn't be needed, ie: {r }

burodepeper avatar Feb 16 '16 10:02 burodepeper

The tailing space issue, I found it's more serious than it looks. See the two screenshots:

without tailing space: screen shot 2016-10-09 at 21 21 26

with tailing space at line 2: screen shot 2016-10-09 at 21 21 34

ZigZagT avatar Oct 09 '16 13:10 ZigZagT

I can't tell for sure from your minimap screenshots, but my first impression is (because that has been the case more often) that the fenced-code-block doesn't close properly until it finds a next ``` instead of the one you intended. If you feel comfortable with it, I invite you to try your hand at a fix. The code that's causing this can be found here.

burodepeper avatar Oct 09 '16 13:10 burodepeper

This should be more clear. It seems it not recognizes the whole {js}</code> pattern, until a tailing space is added. However, the <code>{r} pattern don't met this issue.

screen shot 2016-10-09 at 21 38 11

screen shot 2016-10-09 at 21 36 01

I'll try to fix it

ZigZagT avatar Oct 09 '16 13:10 ZigZagT

Yeah, that's what I meant. In your second example it detects the start of the code-block on line 10, but it doesn't detect the closing element until line 18. Let me know if you figure it out, and feel free to PR any changes into this dev-r-markdown branch.

burodepeper avatar Oct 09 '16 13:10 burodepeper

#139 fix it

ZigZagT avatar Oct 09 '16 15:10 ZigZagT

The trailing space is trivial to fix.

With the current compiled grammar, i.e. for js: https://github.com/burodepeper/language-markdown/blob/de31dac4aea668fd472f41b0a9130deee474c1b6/grammars/language-markdown.json#L3106

The regex includes the group (?=( |$|{)) after the language name, which forces a space (or $ or { after the language name. Changing this to e.g.:

(?=(}| |$|{))

fixes the trailing space problem.

kylebarron avatar Jul 03 '18 02:07 kylebarron

r without the trailing space always worked because the grammars/repositories/flavors/rmarkdown.cson file didn't require a space after {r} and that file was included before the general code.

kylebarron avatar Jul 03 '18 02:07 kylebarron