asciidoctor / atom-language-asciidoc

⚛ AsciiDoc language package for the Atom editor.
https://atom.io/packages/language-asciidoc
MIT License
42 stars 20 forks source link

Assigning source type to code block changes color properties of following text outside block #182

Closed r0ckarong closed 7 years ago

r0ckarong commented 7 years ago

Description

When you specify a code type for a code block, text that is outside of the block gets reformatted with different colors. This appears to have started in one of the recent releases. I didn't notice this with 1.7.0

Screenshots

Set to "java" java

Set to "javascript" javascript

No specified source type normal

Syntax example


==== Heading Level 3

[source,java]
----
final class MonoJust<T>
extends Mono<T>
    implements Fuseable.ScalarCallable<T>, Fuseable {

  final T value;

  MonoJust(T value) {
    this.value = Objects.requireNonNull(value, "value");
  }..
----

===== Heading Level 4

TIP: This is a tip

NOTE: This is a note

IMPORTANT: This is important

WARNING: This is a warning

CAUTION: Use caution

<<<

====== Heading Level 5

Lorem ipsum dolor sit amet, consectetur adipiscing elit. _Praesent eu orci_ nec justo pulvinar aliquet et vel metus. Fusce **lacinia justo sodales ipsum** suscipit, nec link:http://www.lipsum.com/feed/html[maximus massa] aliquam. Suspendisse non porta odio. Quisque condimentum, ipsum at porta ullamcorper, ante velit fermentum lectus, at dictum turpis dui eu ante. Aenean in est eu sem pulvinar dictum. Quisque nunc velit, tincidunt ac tincidunt elementum, varius ac eros. `Aliquam egestas pulvinar massa et hendrerit`.

* Maecenas porta posuere vestibulum.
** Quisque maximus enim nec cursus mollis.
*** Ut id tortor a leo aliquet lacinia sed quis mi.

- Quisque dignissim lacus eu eros malesuada euismod.
- Sed efficitur, quam nec aliquet convallis,
- neque mi suscipit quam, ac euismod tellus tortor a nisi. Cras bibendum imperdiet tincidunt. Aliquam imperdiet, ante sed tempus ullamcorper, felis ipsum mattis ex, quis ullamcorper metus eros eget nunc. Ut ut magna lacus.

https://gfycat.com/EcstaticOldBluetonguelizard

r0ckarong commented 7 years ago

Using Atom 1.15.0 on Ubuntu 16.10 LTS

ldez commented 7 years ago

Same problem with Markdown and Java language (but not reproduce with a valid JS syntax). It's a problem with Java core package of Atom.

ldez commented 7 years ago

Workaround: close the class with a }

[source,java]
----
final class MonoJust<T> extends Mono<T> implements Fuseable.ScalarCallable<T>, Fuseable {

  final T value;

  MonoJust(T value) {
    this.value = Objects.requireNonNull(value, "value");
  }
// ..
}
----
ldez commented 7 years ago

@r0ckarong in Atom, code block must be "valid" code. If you want to use ... comment the line: // .... If you open a structure, close it.

r0ckarong commented 7 years ago

I never knew that you have to properly close code. I just grabbed some random piece of code from the highlighter testpage to plug into my test document.

Does that really mean I can't grab "broken" snippets of code to display in a block? I would assume the block is self contained and the contents shouldn't matter.

ldez commented 7 years ago

The grammar parser in Atom have limit with multi-line content, if you use an element with a multi-line structure (like {}) you must close it.

r0ckarong commented 7 years ago

That's good to know. Thank you.

mojavelinux commented 7 years ago

This actually strikes me as a bit strange. We know the boundaries of the block because they are well-defined. I'm surprised that we aren't giving just the contents of the block to the syntax highlighter to highlight. In other words, the closing ---- should be a hard stop.

mojavelinux commented 7 years ago

I guess we'd have to somehow weave into every language to abort if it sees the block delimiter. But I'm not sure if and how that can be done. Because that's how Asciidoctor works.

ldez commented 7 years ago

It's not a surprise for me, it's the basic Atom parsing behavior with embedded language.

ldez commented 7 years ago

---- it's not a "hard stop", because "hard stop" doesn't exist.

mojavelinux commented 7 years ago

I'm just saying it's surprising that Atom didn't implement a hard stop...because it exists in many lightweight markup languages.