-
Notifications
You must be signed in to change notification settings - Fork 108
Inline asterisks are not closed properly #117
Comments
Similar issue with underlines. Ex: Blah blah _ blah Everything in between those two "_"'s is highlighted as being italics, but it's correctly rendered such that they're not. |
@edent: try the |
@burodepeper that fixes the formatting - but for some reason the preview pane won't show up! |
@edent You mean the Markdown preview? Could you perhaps create an issue with as much relevant details as possible, then I'll have a look tomorrow. |
This phenomenon is due to 17a9412. The commit message is:
The second sentence is wrong in the context of GFM spec. I have no idea why this commit was accepted. Using I have tried to fix this issue, however I faced several difficulties:
And this is my attempt to fix the problem: diff --git a/grammars/gfm.cson b/grammars/gfm.cson
index 06759a1..67d95e6 100644
--- a/grammars/gfm.cson
+++ b/grammars/gfm.cson
@@ -16,8 +16,8 @@
'name': 'constant.character.escape.gfm'
}
{
- 'begin': '(?<=^|[^\\w\\d\\*])\\*\\*\\*(?!$|\\*|\\s)'
- 'end': '(?<!^|\\s)\\*\\*\\**\\*(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\*)\\*{3}(?!\\*)(?=\\w)|(?<!\\w|\\*)\\*{3}(?!$|\\s|\\*)'
+ 'end': '(?<=\\w)(?<!\\*)\\*{3}(?!\\*)|(?<!^|\\s|\\*)\\*{3}(?!\\w|\\*)'
'name': 'markup.bold.italic.gfm'
'patterns': [
{
@@ -32,8 +32,8 @@
]
}
{
- 'begin': '(?<=^|[^\\w\\d_])___(?!$|_|\\s)'
- 'end': '(?<!^|\\s)___*_(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\w|_)___(?!$|\\s|_)'
+ 'end': '(?<!^|\\s|_)___(?!\\w|_)'
'name': 'markup.bold.italic.gfm'
'patterns': [
{
@@ -48,8 +48,8 @@
]
}
{
- 'begin': '(?<=^|[^\\w\\d\\*])\\*\\*(?!$|\\*|\\s)'
- 'end': '(?<!^|\\s)\\*\\**\\*(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\*)\\*\\*(?!\\*)(?=\\w)|(?<!\\w|\\*)\\*\\*(?!$|\\s|\\*)'
+ 'end': '(?<=\\w)(?<!\\*)\\*\\*(?!\\*)|(?<!^|\\s|\\*)\\*\\*(?!\\w|\\*)'
'name': 'markup.bold.gfm'
'patterns': [
{
@@ -64,8 +64,8 @@
]
}
{
- 'begin': '(?<=^|[^\\w\\d_])__(?!$|_|\\s)'
- 'end': '(?<!^|\\s)__*_(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\w|_)__(?!$|\\s|_)'
+ 'end': '(?<!^|\\s|_)__(?!\\w|_)'
'name': 'markup.bold.gfm'
'patterns': [
{
@@ -80,8 +80,8 @@
]
}
{
- 'begin': '(?<=^|[^\\w\\d\\*])\\*(?!$|\\*|\\s)'
- 'end': '(?<!^|\\s)\\**\\*(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\*)\\*(?!\\*)(?=\\w)|(?<!\\w|\\*)\\*(?!$|\\s|\\*)'
+ 'end': '(?<=\\w)(?<!\\*)\\*(?!\\*)|(?<!^|\\s|\\*)\\*(?!\\w|\\*)'
'name': 'markup.italic.gfm'
'patterns': [
{
@@ -96,8 +96,8 @@
]
}
{
- 'begin': '(?<=^|[^\\w\\d_\\{\\}])_(?!$|_|\\s)'
- 'end': '(?<!^|\\s)_*_(?=$|[^\\w|\\d])'
+ 'begin': '(?<!\\w|_)_(?!$|\\s|_)'
+ 'end': '(?<!^|\\s|_)_(?!\\w|_)'
'name': 'markup.italic.gfm'
'patterns': [
{ Though this change can fix the issue, it is never a good solution. I ignored the characters that are none of unicode whitespaces, punctuation characters, or regex word characters. I compacted the rules into poorly readable regex expression. Not all of the rules are applied to them, and even I reinterpreted some rules to bring them into regex expression. I hope this issue to be fixed soon. It gives much inconvenience for the users. EDIT: FYI, you can test your markdown syntax in the commonmark.js dingus. |
Probably because the spec didn't exist in 2014 😉. However, I do agree that this needs to be fixed, and that language-gfm is not in a very good state at the moment. I cannot give you an ETA when I personally will be able to investigate this issue given all the other language issues that are open. |
This comment has been minimized.
This comment has been minimized.
I'm encountering this bug, and I was curious what it might take to fix it. my example:
(only I'm pretty sure the problem is that regex cannot be used to parse nested structures (asterisk regions within asterisk regions). I'm not very familiar with Atom development, but after reading the language grammars docs, it sounds like the existing language-gfm grammar is a TextMate ("legacy") implementation. Has upgrading to tree-sitter been considered? |
Use case “make first letter of a word bold or italic” works fine both in Markdown preview in Atom and on GitHub, just like in Sublime Text. But there’s a problem in GFM language module preventing proper rendering right in the editor:
Only first letters of the first two words should be bold/italic, not the whole word and especially not the rest of the text after.
The text was updated successfully, but these errors were encountered: