popmark 0.2.0 copy "popmark: ^0.2.0" to clipboard
popmark: ^0.2.0 copied to clipboard

A command-line program that populates your markdown files with the output of documented code segments.

example/example.md

Example #

Simple code segments #

Here are some simple example of popmark in action. This file originally only had the following Dart code segments, and the text segments containing the output of the code were added in by popmark by running:

popmark example/example.md

Segment 1 #

Here is some embedded Dart code...

for (var i = 1; i <= 3; i++) {
  print('$i. Hello, world!');
}
1. Hello, world!
2. Hello, world!
3. Hello, world!

Segment 2 #

... and here is some more...

print('What the heck, world?!');
What the heck, world?!

Segment 3 #

... and here is yet more...

print('Goodbye, world!');
Goodbye, world!

Segment 4 #

Who doesn't love word cycles?

final message = 'spamtapaalesrest', cycle = 4;
for (var i = 0; i < cycle; i++) {
    final buffer = StringBuffer('  ' * i);
    for (var j = i; j < message.length; j += cycle) {
        buffer.write(' ' * cycle + message[j]);
    }
    print(buffer);
}
    s    t    a    r
      p    a    l    e
        a    p    e    s
          m    a    s    t

Imports #

The following is a code segment that needs the dart:math and dart:convert libraries. For this code to run correctly, we will need to set the --imports option when calling popmark:

popmark example/example.md \
  --imports 'dart:math as math;dart:convert show json'

(Otherwise the error messages will be output in the text segment instead.)

print(math.pi);
var map = {'a': 1, 'b': 2};
print(json.encode(map));
3.141592653589793
{"a":1,"b":2}

Alternatively, we could create a template Dart file with {BODY} to mark where the code segments should appear, and then direct popmark to that file using --template [name-of-file].

1
likes
140
pub points
0%
popularity

Publisher

unverified uploader

A command-line program that populates your markdown files with the output of documented code segments.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

args

More

Packages that depend on popmark