Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar Injection doesn't not work on multi-line content #57

Closed
mjbvz opened this issue Oct 30, 2017 · 8 comments
Closed

Grammar Injection doesn't not work on multi-line content #57

mjbvz opened this issue Oct 30, 2017 · 8 comments
Assignees

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 30, 2017

From @zh4ui on October 29, 2017 13:8

I tried to inject TOML grammar into markdown, however the TOML colorizer only works on the first line (i.e. a = "b" in the image), it doesn't work on the following line (i.e. d = "c" in the image)

begin-toml-end

My tmLanguage.json for the injection is like:

{
	"fileTypes": [],
	"injectionSelector": "text.html.markdown",
	"name": "tomlfrontmatter",
	"patterns": [
		{
			"begin": "\\Abegin\\s*",
			"end": "(^|\\G)end\\s*$",
				
				"patterns": [
					{
						"include": "source.toml"
					}
				]
		}
	],
	"scopeName": "toml.frontmatter.markdown"
}

The complete source code is at: https:/zh4ui/vscode-markdowntoml.git

  • VSCode Version: Version 1.17.2 (1.17.2)
  • OS Version: macOS 10.13 (17A405)

Steps to Reproduce:

  1. install the Better TOML for TOML colorizer
  2. git clone https:/zh4ui/vscode-markdowntoml.git
  3. cd vscode-markdowntoml && code .
  4. F5 to debug the code
  5. Create a markdown file in the [Extension Development Host]
  6. type in the content
begin a = "b"
c = "d"
end

Reproduces without extensions: No

Copied from original issue: microsoft/vscode#37098

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 30, 2017

I believe we currently only support injecting into a begin end rule. This grammar ends up getting injected into a begin while instead (meta.paragraph.markdown) and ends up not being applied after the first line

@mjbvz mjbvz removed the markdown label Oct 30, 2017
@r-laf
Copy link

r-laf commented Oct 31, 2017

@mjbvz thanks. But would you explain a little bit more about it. What is a "begin...while". TextMate's documentation language_grammars talks about "begin ... end", but it says nothing about "begin...while". What's the difference? Some document for "begin...while" would be perfect for me.

Additionally, can I take your comment for that vscode currently doesn't support multi-line grammar injection?

@r-laf
Copy link

r-laf commented Oct 31, 2017

Okay. Writing a TextMate Grammar: Some Lessons Learned gives a fairly good explanation about "begin..end" and "begin...while".

I am wondering is there a plan for vscode-textmate to support "begin...while"?

@r-laf
Copy link

r-laf commented Oct 31, 2017

Well, I've figured out another way to fullfill my need, which is using a markdown-it plugin, according to the api-markdown document.

@mjbvz I think this issue can be closed. Thanks very much.

@kumarharsh
Copy link

Related: #41

@alexdima
Copy link
Member

@zh4ui AFAIK we support "begin...while".

Closing this issue as requested.

@colinfang
Copy link

@zh4ui How does markdown-it help here? Doesn't it only deal with the markdown preview?
@alexandrudima If it is not "begin...while" issue, what went wrong?

I tried

		{
			"begin": "begin",
			"end": "end",
			"name": "AAA",
			"patterns": [
				{
					"name": "BBB",
					"match": ".+"
			    }
			]
		}

The above pattern correctly recognises each line in the body as BBB

However replacing match to .*, it only recognises the first line. The rest lines are parsed as markdown instead.

@r-laf
Copy link

r-laf commented Nov 26, 2017

@colinfang

Yes, markdown-it only deals with markdown preview. So I gave up trying.

I've got an impression that currently grammar injection is just a hack, rather than a useable feature.

david-driscoll pushed a commit to OmniSharp/vscode-textmate that referenced this issue Oct 7, 2019
Add support for out variable declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants