-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fixes #39. Spaces and source-language name for language attribute #40
Conversation
adoc-mode.el
Outdated
@@ -2033,7 +2033,7 @@ START-SRC and END-SRC delimit the actual source code." | |||
(outer-brackets-and-delimiter (&rest stuff) | |||
(format "^\\[%s\\]\n\\(?2:----+\\)\n" | |||
(apply #'concat stuff))) | |||
(lang () ",\\(?1:[^],]+\\)") | |||
(lang () ",[\t ]*\\(source-language[\t ]*=[\t ]*\\)?\\(?1:[^],]+\\)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add here some comments with the snippets from the manual, so it's clear what we're matching against. Ideally we should also have some matching unit tests, but this can be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review.
The asciidoctor manual is not clear about the 2nd code block attribute. So I had a look at the Ruby code. There I misinterpreted the document attribute source-language
as block attribute. I corrected this with the last commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the source
-style is applicable to any fenced block.
At the end of the following page they use it with the open block (which is very general): https://docs.asciidoctor.org/asciidoc/latest/blocks/open-blocks/
So maybe, we should take a more general approach and just test the style of each block.
Maybe, even asciidoc-Formatters still work in source blocks whose style is not listing or literal.
We can think about this later.
The changes in this branch/pull-request are nevertheless an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rabbit-hole is quite deep: asciidoctor/asciidoctor-pdf#180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bbatsov ... and even deeper ...
:source-highlighter: pygments
:myBlock: source,ruby,subs="verbatim,quotes"
[{myBlock}]
----
class SomeClass
for i in 1..5 do
"Hello *world*".print
end
----
:saveOldBlock: {myBlock}
:myBlock: source,python,subs="verbatim,quotes"
[{myBlock}]
----
class AnotherClass
for i in 1..5 do
"Hello *world*".print
end
----
:myBlock: {saveOldBlock}
[{myBlock}]
----
class BehindTheLocalDef
for i in 1..5 do
"Hello *world*".print
end
----
Attribute substitutions are carried out in attribute lists before parsing: https://docs.asciidoctor.org/asciidoc/latest/attributes/positional-and-named-attributes/#attribute-list-parsing
73af600
to
9cb822d
Compare
…mment with adoc manual reference.
Also ignore whitespace at the end of the block attribute line.
Add ert tests for - literal code blocks (....) - ignored whitespace after leading comma of 2nd attribute and at end of attr line
9cb822d
to
4e7032e
Compare
@bbatsov As we have seen, the rabbit hole is quite deep. |
The asciidoctor manual accepts spaces at the beginning of the language attribute of code blocks. Furthermore, the language attribute can also be a named attribute
source-language
.So
is the same as
and as
Only the first version is fontified as
emacs-lisp
inorigin/master
at commitb0702bdeb8d799720661766936c36ec3b454c609
.