Closed rchl closed 4 years ago
I think I misunderstood your complaint. I now see in your first example you have two fences in the same Markdown.
Here's the issue. This is a Markdown parsing issue you are running into, but it is also, currently, an understood and accepted behavior. Generally in Python Markdown, blocks are separated with an empty new line.
The following wouldn't give you two paragraphs:
paragraph
paragraph
This would:
paragraph
paragraph
This applies to other blocs as well.
Python 3.3>>> markdown.markdown('test\n- list\ntest')
'<p>test\n- list\ntest</p>'
So, now I think you can see why this might not work.
My SuperFences documentation goes into syntax requirements with this in mind: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/#nested-fence-format.
Now, yes, some Markdown parsers will handle this and some won't.
In short, changing your content as follows should work:
Python 3.3>>> import mdpopups;mdpopups.show_popup(view, "```sh\nnode \"/file.js\" --stdio\n```\n\n - languages\n```json\n\n[\n {\n \"document_selector\": \"source.json\", \n \"feature_selector\": \"source.json\", \n \"language_id\": \"json\"\n }\n]\n```")
@gir-bot remove S: triage @gir-bot add T: support, S: wontfix
No, it doesn't work. The content of the second block should not be highlighted because there is no correct syntax mapped for json
(without https://github.com/facelessuser/sublime-markdown-popups/pull/97).
See, I'm getting this:
which is the same that I would get when using sh
language for the second block:
import mdpopups;mdpopups.show_popup(view, "```sh\nnode \"/file.js\" --stdio\n```\n\n - languages\n```sh\n\n[\n {\n \"document_selector\": \"source.json\", \n \"feature_selector\": \"source.json\", \n \"language_id\": \"json\"\n }\n]\n```")
If I change the first block to js
(and leave the second one with json
), notice how it also affects the highlighting of the second block (braces highlighted differently):
Since you've explained how it works, I presume that when setting the syntax in the temporary view for that second block, that fails and so the syntax is left at previously used one which is sh
.
I missed a new line before the second block:
import mdpopups;mdpopups.show_popup(view, "```sh\nnode \"/file.js\" --stdio\n```\n\n - languages\n\n```json\n\n[\n {\n \"document_selector\": \"source.json\", \n \"feature_selector\": \"source.json\", \n \"language_id\": \"json\"\n }\n]\n```")
Is this without the new JSON syntax rule you are adding or with? I'm a bit confused.
Let me run some tests to determine what syntax gets assigned in these cases.
Without. That's probably what is contributing to the issue. I would think the issue is obvious when running the examples or seeing the screenshots. I think you must be on the go or something if you can't see it. :) EDIT: Your snippet with extra newline fails in the same way.
Oh, shoot, is there no longer a Plain text
syntax in ST4?
So, if a syntax fails, we look for and assign Plain text
, but I imagine it can't verify the resourse for Plain text
as I cannot find one in Sublime anymore...
Oh, it is under Text
now.
Or maybe it has always been there...my fallback Packages/Plain text
looks wrong as it doesn't specify the package...
So moved similary to JSON syntax. I haven't noticed that myself. :)
I wonder if there is more.
EDIT: No, it seems to be the same in ST3 and ST4: Packages/Text/Plain text.tmLanguage
Yeah, I was just an idiot, and apparently no one noticed until now.
I got it working now..
@gir-bot remove S: wontfix, T: support @gir-bot add T: bug
Sublime 4081
This code shows a bug where the syntax of the first code block (
sh
) seems to be used for the second block (json
) also.There is currently no mapping for JSON syntax in ST4 which might have something to do with that. I'm fixing that in #97.
Here is an example with just the second block:
Actually, after trying those examples in order, I've noticed that the second one just uses the syntax of what was used previously, even across mdpopups invocations. So there is some global state somewhere being reused.