Comments (11)
Very cool!
I like the option to specify the implementation, though I think to make this more semantic we should use an option with a default implementation and allow the attribute to override that choice.
[source%interactive,javascript]
----
const lodash = require("lodash");
lodash.camelCase('get content');
----
(This builds on the semantics of %interactive
option for checklists).
I'd also rename the runkit
attribute to runner
. That way, we have a consistent syntax if we add support for other languages.
We might also want to have a global attribute to set the runner(s).
from asciidoctor-extensions-lab.
@hsablonniere You may be interested in where this is headed.
from asciidoctor-extensions-lab.
Of course, how cool would it be to test some Asciidoctor.js in the browser as the main example that we show?
from asciidoctor-extensions-lab.
Sure – we just need to be aware code snippets within a same document can be run by different runners. Authors could definitely mix Python and JS, each of them might have a different set of options depending on the runner runtime.
And indeed I almost hesitated writing the aforementioned snippets with asciidoctor-js to render some Asciidoc with Node in the browser ;-)
from asciidoctor-extensions-lab.
we just need to be aware code snippets within a same document can be run by different runners.
Absolutely. I was thinking more along the lines of a runner per langauge. Something like:
:runner-javascript: nodeVersion:6
from asciidoctor-extensions-lab.
When Asciidoctor encounters a delimited block or paragraph with an unrecognized name while parsing the document, it looks for a BlockProcessor registered to handle this name and, if found, invokes its {Processor#process} method to build a corresponding node in the document tree.
@mojavelinux Given this fact, what is the best approach to create an extension to process a source
block ?
from asciidoctor-extensions-lab.
The best option is a Treeprocessor. Technically, there's nothing wrong with that choice in this case since we want all the normal behavior of parsing a source block, we just want to do something else with it before conversion (aka rendering).
The BlockProcessor is intended for the case when you want to influence (actually take over) the parsing. (Technically, Asciidoctor Diagram could be done with a Treeprocessor too).
from asciidoctor-extensions-lab.
In fact, I did something similar in one of the existing (somewhat poorly written) extensions in the lab. See https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/shell-session-treeprocessor/extension.rb.
The drawback of treeprocessors right now find_by misses some blocks in the tree, including blocks inside AsciiDoc table cells...so you just have to work a bit harder to find all the blocks to process. For most documents, though, the blocks are accessible.
from asciidoctor-extensions-lab.
It is out of scope of this repo so I close the issue.
I started working on it here: https://github.com/oncletom/asciidoctor-extension-interactive-runner.
from asciidoctor-extensions-lab.
👍
from asciidoctor-extensions-lab.
@oncletom The code looks really good, well done 👍
from asciidoctor-extensions-lab.
Related Issues (20)
- Is there a configuration open for using divs instead of tables for admonitions? HOT 1
- mathoid-treeprocessor and new versions of mathoid HOT 4
- npm install mathoid error: Package libffi was not found in the pkg-config search path. HOT 2
- Convert all inline example to use create_inline otherwise it gives "INFO: expected substitution value for custom inline macro to be of type Inline" HOT 5
- Integrate asciidoc-coalescer.rb as extension/converter so as to make it available in the CLI HOT 1
- sectnum offset tree processor always returns 1 or 2 HOT 1
- Make all these extensions installable with gem install HOT 4
- Add list of tables and list of figures HOT 28
- generate pdf with chart block HOT 4
- adding row name to chart HOT 3
- Add a metadata object for year HOT 1
- Add metadata object for tag message HOT 2
- man-inline-macro doesn't generate the correct output in the manpage backend HOT 5
- Section offset plugin fails when creating PDF HOT 4
- Using the Preprocessor ignores ifdef directives HOT 1
- add link to the current script location as comment into the script HOT 6
- Idea: Create file tree containing all included files HOT 2
- Graduate the asciidoc-coalescer.rb script to a separate project HOT 4
- Add macro for GitHub / BaseCamp emoji library HOT 6
- Help With Callouts: Any Examples? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciidoctor-extensions-lab.