Govspeak is our markdown-derived mark-up language.
# Usage
Install the gem
gem install govspeak
or add it to your Gemfile
gem "govspeak", "~> 3.4.0"
then create a new document
require 'rubygems'
require 'govspeak'
doc = Govspeak::Document.new "^Test^"
puts doc.to_html
or alternatively, run it from the command line
$ govspeak "render-me"
$ govspeak --file render-me.md
$ echo "render-me" | govspeak
options can be passed in through `--options` as a string of JSON or a file
of JSON can be passed in as `--options-file options.json`.
if installed via bundler prefix commands with bundle exec eg `$ bundle exec govspeak "render-me"`
# Extensions
In addition to the [standard Markdown syntax](http://daringfireball.net/projects/markdown/syntax "Markdown syntax"), we have added our own extensions.
## Callouts
### Information callouts
^This is an information callout^
creates a callout with an info (i) icon.
This is an information callout
### Warning callouts
%This is a warning callout%
creates a callout with a warning or alert (!) icon
This is a warning callout
### Example callout
$E
**Example**: Open the pod bay doors
$E
creates an example box
Example: Open the pod bay doors
## Highlights
### Advisory
@This is a very important message or warning@
highlights the enclosed text in yellow
This is a very important message or warning
### Answer
{::highlight-answer}
The VAT rate is *20%*
{:/highlight-answer}
creates a large highlight box with optional preamble text and giant text denoted with `**`
The VAT rate is 20%
### Statistic headline
Used in HTML publications.
Statistic headlines highlight important numbers in content. Displays a statistic as a large number with a description. The statistic and description must make sense when read aloud. The important number must be wrapped in `**`.
```
{stat-headline}
*13.8bn* years since the big bang
{/stat-headline}
```
Creates the following:
```html
```
## Points of Contact
### Contact
$C
**Student Finance England**
**Telephone:** 0845 300 50 90
**Minicom:** 0845 604 44 34
$C
creates a contact box
## Place
$P
This is a place
$P
creates a place box
This is a place
## Information
$I
This is information
$I
creates an information box
This is information
## Additional Information
$AI
This is additional information
$AI
creates an additional information box
This is additional information
## Call to Action
$CTA
This is a call to action
$CTA
creates an additional information box
This is a call to action
## Summary
$!
This is a summary
$!
creates a summary box
This is a summary
## External Link
x[External Report](https://example.com/report)x
creates a link specified as external
External Report
## Steps
Steps can be created similar to an ordered list:
s1. numbers
s2. to the start
s3. of your list
Note that steps need an extra line break after the final step (ie. two full blank lines) or other markdown directly afterwards won't work. If you have a subhead after - add a line break after this.
## Legislative Lists
For lists where you want to specify the numbering and have multiple indent levels.
$LegislativeList
* 1. Item 1
* 2. Item 2
* a) Item 2a
* b) Item 2b
* i. Item 2 b i
* ii. Item 2 b ii
* 3. Item 3
$EndLegislativeList
(to indent, add 2 spaces)
## Priority Lists
For lists where you want to specify a number of items to be highlighted as priority.
$PriorityList:3
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
creates a list with priority items flagged with a class
Item 1
Item 2
Item 3
Item 4
Item 5
## Devolved content
:england:content goes here:england:
:scotland:content goes here:scotland:
:london:content goes here:london:
:wales:content goes here:wales:
:northern-ireland:content goes here:northern-ireland:
:england-wales:content goes here:england-wales:
will create a box for the specified locality
This section applies to England
content goes here
## Barcharts
For when you want a table to be progressively enhanced by Javascript to be
rendered as a bar chart.
|col|
|---|
|val|
{barchart}
will be rendered as
col
val
## Embedded Content
Embedded content allows authors to reference a supporting item of a document by
referencing an id. The details of this content is passed to the publishing
application to govspeak at the time of rendering.
### Attachments
To create an attachment callout
[embed:attachment:2b4d92f3-f8cd-4284-aaaa-25b3a640d26c]
with options provided
{
attachments: [
{
id: 123,
content_id: "2b4d92f3-f8cd-4284-aaaa-25b3a640d26c",
title: "Attachment Title",
url: "http://example.com/test.pdf",
order_url: "http://example.com/order",
price: 12.3,
isbn: "isbn-123",
attachment?: true,
}
]
}
will output an attachment box
### Inline Attachment
Attachments can be linked to inline as well
Details referenced in [embed:attachments:inline:34f6dda0-21b1-4e78-8120-3ff4dcea522d]
with options provided
{
attachments: [
{
content_id: "34f6dda0-21b1-4e78-8120-3ff4dcea522d",
title: "My Thorough Study",
url: "http://example.com/my-thorough-study.pdf",
}
]
}
will output an attachment within a block of text
Details referenced in My Thorough Study
### Image Attachments
Attachments can be used to embed an image within the document
[embed:attachments:image:45ee0eea-bc53-4f14-81eb-9e75d33c4d5e]
with options provided
{
attachments: [
{
content_id: "45ee0eea-bc53-4f14-81eb-9e75d33c4d5e",
title: "A lovely landscape",
url: "http://example.com/lovely-landscape.jpg",
}
]
}
will output a image section
### Link
Links to different documents can be embedded so they change when the documents
they reference change.
A link to [embed:link:c636b433-1e5c-46d4-96b0-b5a168fac26c]
with options provided
{
links: [
{
url: "http://example.com",
title: "An excellent website",
}
]
}
will output