Livemark extends Markdown with variety of features. Usually, a codeblock syntax is used for new functionality. For example, adding a script
word to a Python snippet's header will make it a Livemark script.
Livemark allows you to include Python and Bash tasks in your markdown documents and run them using livemark run
command. This functionality is really useful for a data-driven project where you can share the whole process of getting and transforming your data in a markdown document preserving an ability to run those scripts. It's also used for Contribution Guides and similar documents. It will be rendered as a code block with the command to run it added:
'''python task id=example
print('It is a task')
'''
$ livemark run example
print('It is a task')
You can run it using:
$ livemark run example
It is a task
Livemark process your document using the Jinja templating language. Inside templates, you can use Frictionless Framework as a frictionless
variable to work with tabular data. It's a high-level data preprocessing so you can combine Logic with other syntax, such as Table or Chart:
{% for car in frictionless.Resource('data/cars.csv').read_rows(size=5) %}
- {{ car.brand }} {{ car.model }}: ${{ car.price }}
{% endfor %}
Livemark supports CSV table rendering using DataTables, which you can see in the example below (replace the single quotes with back ticks). The data
property will be read at the build stage so in addition to DataTables options you can pass a file path as data
property (CSV/Excel/JSON are supported). Use columns
property to customize fields or their order:
'''yaml table
data: data/cars.csv
width: 600
order:
- [3, 'desc']
columns:
- data: type
- data: brand
- data: model
- data: price
- data: kmpl
- data: bhp
'''
type | brand | model | price | kmpl | bhp |
---|---|---|---|---|---|
Sedan | Volkswagen | Vento | 785 | 16.1 | 104 |
Sedan | Hyundai | Verna | 774 | 17.4 | 106 |
Sedan | Skoda | Rapid | 756 | 15.0 | 104 |
Sedan | Suzuki | Ciaz | 725 | 20.7 | 91 |
Sedan | Renault | Scala | 724 | 16.9 | 98 |
Sedan | Suzuki | SX4 | 715 | 16.5 | 103 |
Sedan | Fiat | Linea | 700 | 15.7 | 112 |
Sedan | Nissan | Sunny | 699 | 16.9 | 98 |
Sedan | Fiat | Linea Classic | 612 | 14.9 | 89 |
Sedan | Toyota | Etios | 603 | 16.8 | 89 |
Sedan | San | Storm | 595 | 16.0 | 59 |
Sedan | Chevrolet | Sail | 551 | 18.2 | 82 |
Hatchback | Volkswagen | Polo | 535 | 16.5 | 74 |
Hatchback | Hyundai | i20 | 523 | 18.6 | 82 |
Sedan | Honda | Amaze | 519 | 18.0 | 87 |
Sedan | Suzuki | Swift DZire | 508 | 19.1 | 86 |
Sedan | Ford | Classic | 506 | 14.1 | 100 |
Hatchback | Skoda | Fabia | 503 | 16.4 | 75 |
Hatchback | Toyota | Etios Liva | 500 | 17.7 | 79 |
Hatchback | Fiat | Punto Evo | 499 | 15.8 | 67 |
Sedan | Tata | Indigo | 499 | 14.0 | 65 |
Sedan | Hyundai | Xcent | 496 | 19.1 | 82 |
Sedan | Tata | Zest | 481 | 17.6 | 89 |
Hatchback | Chevrolet | Sail Hatchback | 468 | 18.2 | 82 |
Hatchback | Suzuki | Swift | 462 | 20.4 | 83 |
Hatchback | Renault | Pulse | 446 | 18.0 | 74 |
Hatchback | Suzuki | Ritz | 442 | 18.5 | 86 |
Hatchback | Chevrolet | Beat | 421 | 18.6 | 79 |
Hatchback | Honda | Brio | 421 | 19.4 | 87 |
Hatchback | Hyundai | i10 | 418 | 19.8 | 68 |
Hatchback | Ford | Figo | 414 | 15.3 | 70 |
Hatchback | Nissan | Micra | 413 | 19.5 | 67 |
Hatchback | Suzuki | Celerio | 392 | 23.1 | 67 |
Hatchback | Suzuki | Wagon-R | 363 | 20.5 | 67 |
Hatchback | Volkswagen | Up | 360 | 21.0 | 74 |
Hatchback | Chevrolet | Spark | 345 | 16.2 | 62 |
Hatchback | Suzuki | Estilo | 338 | 19.0 | 67 |
Hatchback | Suzuki | Alto | 315 | 24.1 | 67 |
Hatchback | Nissan | Datsun GO | 312 | 20.6 | 67 |
Hatchback | Hyundai | EON | 302 | 21.1 | 55 |
Hatchback | Suzuki | Alto 800 | 248 | 22.7 | 47 |
Hatchback | Tata | Nano | 199 | 23.9 | 38 |
type | brand | model | price | kmpl | bhp |
Livemark supports Vega Lite visualisations rendering (to try this example, replace the single quotes with back ticks):
'''yaml chart
data:
url: ../../data/cars.csv
mark: circle
selection:
brush:
type: interval
# other options are omitted
width: 500
height: 300
'''
Livemark supports Python/Bash script execution inside Markdown. We think of this as a lightweight version of Jupyter Notebooks. Sometimes, a declarative Logic/Table/Chart is not enough for presenting data so you might also want to include the scripts:
from pprint import pprint
from frictionless import Resource, transform, steps
brands = transform(
Resource("data/cars.csv"),
steps=[
steps.table_normalize(),
steps.table_aggregate(group_name="brand", aggregation={"price": ("price", max)}),
steps.row_sort(field_names=["price"], reverse=True),
steps.row_slice(head=5),
],
)
pprint(brands.read_rows())
[{'brand': 'Volkswagen', 'price': 785},
{'brand': 'Hyundai', 'price': 774},
{'brand': 'Skoda', 'price': 756},
{'brand': 'Suzuki', 'price': 725},
{'brand': 'Renault', 'price': 724}]
https://getbootstrap.com/docs/5.0/getting-started/introduction/
With Livemark you can use HTML inside Markdown with Bootstrap support. Here is an example of creating a responsive grid of cards:
'''html markup
<div class="w-50">
<div class="container">
<div class="row">
<div class="col-sm">
<img src="../../assets/table-package.png" title="Package">
<div class="text-center">
<p><strong>Data Package</strong></p>
<p>A simple container format for describing a coherent collection of data in a single package.</p>
</div>
</div>
<!-- other columns are omitted -->
</div>
</div>
</div>
'''
Data Package
A simple container format for describing a coherent collection of data in a single package.
Data Resource
A simple format to describe and package a single data resource such as a individual table or file.
Table Schema
A simple format to declare a schema for tabular data. The schema is designed to be expressible in JSON.
Livemark supports GeoJson visualisations rendering (to try this example, replace the single quotes with back ticks):
'''yaml map
data: data/france.json
'''
This feature renders an audio file or a SoundCloud track:
'''yaml audio/soundcloud
code: 34445479
'''
This feature adds a file from the disc with a given code syntax:
'''python file
livemark/__init__.py
'''
from .config import Config
from .document import Document
from .markup import Markup
from .plugin import Plugin
from .project import Project
from .program import program
from .server import Server
from .settings import VERSION as __version__
from .snippet import Snippet
from .system import system
from . import errors
This feature adds an image with an ability to customize dimensions and CSS class:
Hover on the heading and click "Source" to see the source
This feature renders a Frictionless Data Package:
'''yaml package
descriptor: https://raw.githubusercontent.com/fjuniorr/cicd-gh-pages-rmarkdown/main/datapackage.json
'''
Hover on the heading and click "Source" to see the source
This includes a Python function or class reference (in active development):
Livemark snippet
(input: str, *, header: List[str])
Snippet's header
List[str]
Snippet's input
str
Snippet's lang
str
Snippet's output
Optional[str]
Snippet's props
Dict[str, Any]
Snippet's type
str
Process snippet
(document: Document) -> None
Livemark document
(source, *, target=None, format=None, project=None, path=None)
Document's config
Document's content
Document's description
Document's format
Document's input
Document's keywords
Document's name
Document's output
Document's path
Document's plugins
Document's preface
Document's project
Document's source
Document's target
Document's title
Build the document
(*, diff=False, print=False)
Get document's plugin by name
(name)
Process the document
Read the document
Write the document
(*, diff=False, print=False)
This feature for including Jupyter Notebooks is being developed at the moment.
This renders an interactive Validation Report, using the Frictionless Framework:
'''yaml report
descriptor: data/invalid.report.json
'''
This feature for including Data Resource is being developed at the moment.
It renders an interactive Table Schema, using the Frictionless Framework:
'''yaml schema
descriptor: data/cars.schema.json
'''
This feature renders a video file or a YouTube video:
'''yaml video/youtube
code: NMg-eCbO6L0
'''
This feature for including Transformation Pipelines is being developed at the moment.