Doing basic calculations in tables

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Doing basic calculations in tables

Ams627
Is it possible to do a basic calculation in a table (similar to summing a column of numbers in Excel)?

Thanks

A.
Reply | Threaded
Open this post in threaded view
|

Re: Doing basic calculations in tables

mojavelinux
Administrator
Not built-in. There are two possible solutions, both of which involve using extensions.

The first solution is to create an inline macro that performs calculations. Something like:

calc:[1 + 2]

However, if you wanted to be able to reference cells, you'd need to introduce some sort of reference shorthand that extracted data from the AST, so depending on what you're after, it could get rather involved.

calc:[:A1 + :A2]

A second solution is to use an custom block to integrate a separate tool that crunches numbers and produces CSV. The processor can then use the CSV to create the table for display (basically a query result). You can see an example of this in the textql extension in the extensions lab: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/textql-block.rb

I hope that helps.

Cheers,

-Dan

On Tue, May 22, 2018 at 1:46 PM, Ams627 [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Is it possible to do a basic calculation in a table (similar to summing a column of numbers in Excel)?

Thanks

A.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Doing-basic-calculations-in-tables-tp6349.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux