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

Source block delimiter with .... (literal) #146

Closed ggrossetie closed 8 years ago

ggrossetie commented 8 years ago

Description

Source block literal with .... literal prevents the rest of the document from being correctly highlighted.

Screenshots

source-block

Syntax example

= Source block delimiter ....

== Exemple

[source,adoc]
....
:uri-homepage: http://asciidoctor.org // <1>
:uri-docs: {uri-homepage}/docs // <2>

 - {uri-docs}/user-manual
 - {uri-docs}/asciidoc-syntax-quick-reference
....
// <1> URL de base du site Asciidoctor
// <2> Réutilise la variable définie juste au dessus pour ajouter `/docs`

== Résultat

:uri-homepage: http://asciidoctor.org
:uri-docs: {uri-homepage}/docs

 - {uri-docs}/user-manual
 - {uri-docs}/asciidoc-syntax-quick-reference

---
ldez commented 8 years ago

I will fix this quickly...

ldez commented 8 years ago

but it's a real case? use source and literal delimiter ?

http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary

ggrossetie commented 8 years ago

@ldez @mojavelinux Good question, I don't know if there's another way to write this. A better exemple is:

= Source block delimiter ....

== Exemple

[source]
....
:testdir: ${project.build.testSourceDirectory} // <1>
:testpkg: {testdir}/org/asciidoctor // <2>

[source,java]
----
include::{testpkg}/WhenAttributesAreUsed.java[tag=uri-scheme] // <3>
----
<1> Positionne l'attribut permettant de masquer le schéma sur les liens
....

// <1> Utilise une variable du build Maven (filtering)
// <2> Réutilise la variable définie juste au dessus pour ajouter le package
// <3> Précise le tag à utiliser (possibilité de préciser plusieurs tag séparé par des virgules)

== Résultat

:testpkg: src/test/java/org/asciidoctor

[source,java,indent=0]
----
include::{testpkg}/WhenAttributesAreUsed.java[tags=uri-scheme]
----
<1> Positionne l'attribut permettant de masquer le schéma sur les liens

source-block-rendered2

ldez commented 8 years ago

The documentation talk about open block and listing bloc but literal...

Cool, a sample :+1:

ldez commented 8 years ago

You can do that with open block:

= Source block delimiter ....

== Exemple

[source]
--
:testdir: ${project.build.testSourceDirectory} // <1>
:testpkg: {testdir}/org/asciidoctor // <2>

[source,java]
----
include::{testpkg}/WhenAttributesAreUsed.java[tag=uri-scheme] // <3>
----
<1> Positionne l'attribut permettant de masquer le schéma sur les liens
--

// <1> Utilise une variable du build Maven (filtering)
// <2> Réutilise la variable définie juste au dessus pour ajouter le package
// <3> Précise le tag à utiliser (possibilité de préciser plusieurs tag séparé par des virgules)

== Résultat

:testpkg: src/test/java/org/asciidoctor

[source,java,indent=0]
----
include::{testpkg}/WhenAttributesAreUsed.java[tags=uri-scheme]
----
<1> Positionne l'attribut permettant de masquer le schéma sur les liens
mojavelinux commented 8 years ago

Yep, it's valid. The source style can be on listing, literal or open structural containers.

ldez commented 8 years ago

But it's explained nowhere else. :cry:

Same thing for other styles, like passthrough, admonition or quotes ??

mojavelinux commented 8 years ago

But it's explained nowhere else. :cry:

:sob:

The official ruling is that the source style can be applied to a verbatim structural container, of which there are two: listing (hyphens) and literal (dots). The open block was an experiment. I've since concluded that using open block for this purpose is not a good practice and we shouldn't support it in the grammar.

ldez commented 8 years ago

@mojavelinux Another question, in the documentation it's write that Open block doesn't act passthrough blocks.

Open block: Anonymous block that can act as any block except passthrough or table blocks.

http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary

If I do:

[pass]
--
<div>
  <u>underline me1</u>
</div>
--

foo

--
<div>
  <u>underline me2</u>
</div>
--

the rendering:

capture du 2016-05-27 10-18-57

I have misunderstood something?

ldez commented 8 years ago

@Mogztter you can prevent callout substitution for a better rendering.

[source]
....
:testdir: ${project.build.testSourceDirectory} // \<1>
:testpkg: {testdir}/org/asciidoctor // <2>
....

capture du 2016-05-27 13-15-37

lucascosti commented 8 years ago

I'm not sure if this is the same issue as this, but I am also experiencing an open block breaking highlighting.

asciidoc-language-bug

This is with language-asciidoc v. 1.4.6

ldez commented 8 years ago

@lucascosti can you open another issue? Your problem is different. In this new issue, can you provide a syntax sample? Thanks.

lucascosti commented 8 years ago

@ldez yep, sure; done as #148 .

mojavelinux commented 8 years ago

in the documentation it's write that Open block doesn't act passthrough blocks.

It can. Here's the definitive list atm: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor.rb#L275

We're still struggling a bit to decide what open block should be allowed to do, and when to use it. My current position is that an open block should be allowed "masquerade" as other complex blocks (example, sidebar, etc), but most of the time it is used simply to group blocks together with no meaning (an anonymous group so to speak) or for extensions. (I'm not a big fan of using open blocks for verbatim content).