-
Notifications
You must be signed in to change notification settings - Fork 335
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
Add include-tagged macro #151
Conversation
This macro allows you to include a portion of a file like this: ``` ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{doc-tests}/DeleteDocumentationIT.java[delete-request] -------------------------------------------------- <1> Index name <2> Type <3> Document id ``` Which can be used to extract a section of a file like this: ``` // tag::delete-request DeleteRequest request = new DeleteRequest( "index", // <1> "type", // <2> "id"); // <3> // end::delete-request ```
I gave a quick look at it (well I'm not a Python guy :) ). It looks good. I guess that automatically find what is the indentation of the tag with |
Right. We copy the indentation of the tag and strip it from all the other fields. At least, that is what I tried to do. |
resources/es-asciidoc.conf
Outdated
@@ -40,6 +41,10 @@ | |||
{passtext} | |||
</phrase> | |||
|
|||
[include-tagged-inlinemacro] | |||
# it is a nightmare to get this to work with eval3 so we're forking a new process every time.... |
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 think eval3
should be sys3
actually.
@clintongormley, do you want to have a look at this? |
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've improved the error reporting a bit to give the user more context. With that change in place, it's good to merge
indentation = m.group(1) | ||
|
||
|
||
if __name__ == '__main__': |
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 tidy up the error output a bit, to look more like this:
if __name__ == '__main__':
from sys import argv, stdout, stderr
try:
result = extract_tagged(argv[1], argv[2])
if result:
stdout.write(result)
else:
raise Exception("Couldn't find tag")
except Exception as e:
stderr.write("asciidoc: ERROR: Extracting tag `" + argv[2] + "` from file `" + argv[1]+ "`: " + e.__str__() + "\n")
exit(1)
Thanks @clintongormley! |
This macro allows you to include a portion of a file like this:
Which can be used to extract a section of a file like this: