App-Basis-ConvertText2

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    ~~~~{.buffer to_buffer='spark_data'}
    1,4,5,20,4,5,3,1
    ~~~~

    here is a standard sparkline

    ~~~~{.sparkline title='basic sparkline' }
    1,4,5,20,4,5,3,1
    ~~~~

    or we can draw the sparkline using buffered data

    ~~~~{.sparkline title='blue sparkline' scheme='blue' from_buffer='spark_data'}
    ~~~~

**Output**

~~~~{.buffer to_buffer='spark_data'}
1,4,5,20,4,5,3,1
~~~~

here is a standard sparkline

~~~~{.sparkline title='basic sparkline' }
1,4,5,20,4,5,3,1
~~~~

or we can draw the sparkline using buffered data

~~~~{.sparkline title='blue sparkline' scheme='blue' from_buffer='spark_data'}
~~~~

## Charts

Displaying charts is very important when creating reports, so we have a simple **chart** code-block.

The various arguments to the code-block are shown in the examples below, hopefully they are self explanatory.

~~~~{.buffer to='chart_data'}
apples,bananas,cake,cabbage,edam,fromage,tomatoes,chips
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
~~~~

We will buffer some data to start

**Example**

    ~~~~{.buffer to='chart_data'}
    apples,bananas,cake,cabbage,edam,fromage,tomatoes,chips
    1,2,3,5,11,22,33,55
    1,2,3,5,11,22,33,55
    1,2,3,5,11,22,33,55
    1,2,3,5,11,22,33,55
    ~~~~

The content comprises a number of lines of comma separated data items.
The first line of the content is the legends, the subsequent lines are numbers relating
to each of these legends.

### Pie chart

**Example**

    ~~~~{.chart format='pie' title='chart1' from_buffer='chart_data'
        size='400x400' xaxis='things xways' yaxis='Vertical things'
        legends='a,b,c,d,e,f,g,h' }
    ~~~~

**Output**

~~~~{.chart format='pie' title='chart1' from_buffer='chart_data'
    size='400x400' xaxis='things xways' yaxis='Vertical things'
    legends='a,b,c,d,e,f,g,h' }
~~~~

### Bar chart

**Example**

    ~~~~{.chart format='bars' title='chart1' from_buffer='chart_data'
        size='600x400' xaxis='things ways' yaxis='Vertical things'
        legends='a,b,c,d,e,f,g,h' }
    ~~~~

**Output**

~~~~{.chart format='bars' title='chart1' from_buffer='chart_data'
    size='600x400' xaxis='things ways' yaxis='Vertical things'
    legends='a,b,c,d,e,f,g,h' }
~~~~

### Mixed chart

**Example**

    ~~~~{.chart format='mixed' title='chart1' from_buffer='chart_data'
      size='600x400' xaxis='things xways' axis='Vertical things'
      legends='a,b,c,d,e,f,g,h' types='lines linepoints lines bars' }
    ~~~~

**Output**

~~~~{.chart format='mixed' title='chart1' from_buffer='chart_data'
  size='600x400' xaxis='things xways' axis='Vertical things'
  legends='a,b,c,d,e,f,g,h' types='lines linepoints lines bars' }
~~~~

## Message Sequence Charts - mscgen

Software (or process) engineers often want to be able to show the sequence in which a number of events take place. We use the [msc] program for this. This program needs to be installed onto your system to allow this to work

The content for this code-block is EXACTLY the same that you would use as input to [msc]

There are only optional 2 arguments

* title
    * used as the generated images 'alt' argument
* size
    * size of image, widthxheight

**Example**

    ~~~~{.mscgen  title="mscgen1" size="600x400}
    # MSC for some fictional process
    msc {
      a,b,c;

      a->b [ label = "ab()" ] ;
      b->c [ label = "bc(TRUE)"];
      c=>c [ label = "process(1)" ];
      c=>c [ label = "process(2)" ];
      ...;
      c=>c [ label = "process(n)" ];
      c=>c [ label = "process(END)" ];
      a<<=c [ label = "callback()"];
      ---  [ label = "If more to run", ID="*" ];
      a->a [ label = "next()"];
      a->c [ label = "ac1()\nac2()"];
      b<-c [ label = "cb(TRUE)"];
      b->b [ label = "stalled(...)"];
      a<-b [ label = "ab() = FALSE"];
    }
    ~~~~

**Output**

~~~~{.mscgen  title="mscgen1" size="600x400}
# MSC for some fictional process
msc {
  a,b,c;

  a->b [ label = "ab()" ] ;
  b->c [ label = "bc(TRUE)"];
  c=>c [ label = "process(1)" ];
  c=>c [ label = "process(2)" ];
  ...;
  c=>c [ label = "process(n)" ];
  c=>c [ label = "process(END)" ];
  a<<=c [ label = "callback()"];
  ---  [ label = "If more to run", ID="*" ];
  a->a [ label = "next()"];
  a->c [ label = "ac1()\nac2()"];
  b<-c [ label = "cb(TRUE)"];
  b->b [ label = "stalled(...)"];
  a<-b [ label = "ab() = FALSE"];

README.md  view on Meta::CPAN

      }

      subgraph cluster_1 {
        node [style=filled];
        b0 -> b1 -> b2 -> b3;
        label = "process #2";
        color=blue
      }
      start -> a0;
      start -> b0;
      a1 -> b3;
      b2 -> a3;
      a3 -> a0;
      a3 -> end;
      b3 -> end;

      start [shape=Mdiamond];
      end [shape=Msquare];
    }
    ~~~~

**Output**

~~~~{.graphviz  title="graphviz1" size='600x600'}
digraph G {

  subgraph cluster_0 {
    style=filled;
    color=lightgrey;
    node [style=filled,color=white];
    a0 -> a1 -> a2 -> a3;
    label = "process #1";
  }

  subgraph cluster_1 {
    node [style=filled];
    b0 -> b1 -> b2 -> b3;
    label = "process #2";
    color=blue
  }
  start -> a0;
  start -> b0;
  a1 -> b3;
  b2 -> a3;
  a3 -> a0;
  a3 -> end;
  b3 -> end;

  start [shape=Mdiamond];
  end [shape=Msquare];
}
~~~~

## Venn diagram

Creating venn diagrams may sometimes be useful, though to be honest this implementation is not great, if I could find a better way to do this then I would!

**Example**

    ~~~~{.venn  title="sample venn diagram"
        legends="team1 team2 team3" scheme="rgb" explain='1'}
    abel edward momo albert jack julien chris
    edward isabel antonio delta albert kevin jake
    gerald jake kevin lucia john edward
    ~~~~

**Output**

~~~~{.venn  title="sample venn diagram" legends="team1 team2 team3" scheme="rgb" explain='1'}
abel edward momo albert jack julien chris
edward isabel antonio delta albert kevin jake
gerald jake kevin lucia john edward
~~~~

## Barcodes

Sometimes having barcodes in your document may be useful, certainly qrcodes are popular.

The code-block only allows a single line of content. Some of the barcode types need
content of a specific length, warnings will be generated if the length is incorrect.

The arguments allowed are

* title
    * used as the generated images 'alt' argument
* height
    * height of image
* notext
    * flag to show we do not want the content text printed underneath the barcode.
* version
    * version of qrcode, defaults to '2'
* pixels
    * number of pixels that is a 'bit' in a qrcode, defaults to '2'

### Code39

**Example**

    ~~~~{.barcode type='code39'}
    123456789
    ~~~~

**Output**

~~~~{.barcode type='code39'}
123456789
~~~~

### EAN8

Only allows 8 characters

**Example**

    ~~~~{.barcode type='ean8'}
    12345678
    ~~~~

**Output**

~~~~{.barcode type='ean8'}
12345678
~~~~

### EAN13

Only allows 13 characters

**Example**

README.md  view on Meta::CPAN


Version 1 only allows 15 characters

~~~~{.qrcode height=60 version=1}
smaller text..
~~~~

To change pixel size

~~~~{.qrcode pixels=5}
smaller text..
~~~~

## YAML convert to JSON

Software engineers often use [JSON] to transfer data between systems, this often is not nice to create for documentation. [YAML] which is a superset of [JSON] is much cleaner
so we have a

**Example**

    ~~~~{.yamlasjson }
    list:
      - array: [1,2,3,7]
        channel: BBC3
        date: 2013-10-20
        time: 20:30
      - array: [1,2,3,9]
        channel: BBC4
        date: 2013-11-20
        time: 21:00

    ~~~~

**Output**

~~~~{.yamlasjson }
list:
  - array: [1,2,3,7]
    channel: BBC3
    date: 2013-10-20
    time: 20:30
  - array: [1,2,3,9]
    channel: BBC4
    date: 2013-11-20
    time: 21:00

~~~~

## Table

Create a simple table using CSV style data

* class
    * HTML/CSS class name
* id
    * HTML/CSS class
* width
    * width of the table
* style
    * style the table if not doing anything else
* legends
    * csv of headings for table, these correspond to the data sets
* separator
    * what should be used to separate cells, defaults to ','

**Example**

    ~~~~{.table separator=',' width='100%' legends=1
        from_buffer='chart_data'}
    ~~~~

**Output**

~~~~{.table separator=',' width='100%' legends=1
    from_buffer='chart_data'}
~~~~

## Links

With one code-block we can create a list of links

The code-block contents comprises a number of lines with a reference and a URL.
The reference comes first, then a '|' to separate it from the URL.

The reference may then be used elsewhere in your document if you enclose it with square ([]) brackets

There is only one argument

* class
    * CSS class to style the list

**Example**

    ~~~~{.links class='weblinks' }
    pandoc      | http://johnmacfarlane.net/pandoc
    PrinceXML   | http://www.princexml.com
    markdown    | http://daringfireball.net/projects/markdown
    msc         | http://www.mcternan.me.uk/mscgen/
    ditaa       | http://ditaa.sourceforge.net
    PlantUML    | http://plantuml.sourceforge.net
    See Salt    | http://plantuml.sourceforge.net/salt.html
    graphviz    | http://graphviz.org
    JSON        | https://en.wikipedia.org/wiki/Json
    YAML        | https://en.wikipedia.org/wiki/Yaml
    wkhtmltopdf | http://wkhtmltopdf.org/
    ~~~~

**Output**

~~~~{.links class='weblinks' }
pandoc      | http://johnmacfarlane.net/pandoc
PrinceXML   | http://www.princexml.com
markdown    | http://daringfireball.net/projects/markdown
msc         | http://www.mcternan.me.uk/mscgen/
ditaa       | http://ditaa.sourceforge.net
PlantUML    | http://plantuml.sourceforge.net
See Salt    | http://plantuml.sourceforge.net/salt.html
graphviz    | http://graphviz.org
JSON        | https://en.wikipedia.org/wiki/Json
YAML        | https://en.wikipedia.org/wiki/Yaml
wkhtmltopdf | http://wkhtmltopdf.org/
~~~~

## Version table

Documents often need revision history. I use this code-block to create a nice
table of this history.

The content for this code-block comprises a number of sections, each section then makes a row in the generated table.

    version YYYY-MM-DD
       change text
       more changes



( run in 0.973 second using v1.01-cache-2.11-cpan-39bf76dae61 )