submark: Extract a part from CommonMark/Markdown docs

[ gpl, library, program, text ] [ Propose Tags ]
Versions 0.1.0
Change log
Dependencies base (>=4.7 && <5), cmark (>=0.5.6 && <0.6.0), optparse‑applicative (>= && <, submark, text (==1.*) [details]
License GPL-3.0-only
Copyright (c) 2017 Hong Minhee
Author Hong Minhee
Category Text
Home page
Bug tracker
Source repo head: git clone
Uploaded by hongminhee at Sun Sep 24 10:35:58 UTC 2017
Distributions NixOS:0.1.0
Executables submark
Downloads 185 total (6 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-09-24 [all 1 reports]
Hackage Matrix CI

[Skip to Readme]





Static link


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for submark-0.1.0

[back to package description]

submark: Extract a part from CommonMark/Markdown docs


submark is a CLI program to extract some particular section from a givne CommonMark/Markdown document. I use it for myself to extract the latest version section from the file, and then reuse the text for the corresponding release note on GitHub releases, during automated release process which is run on CI.

Usage examples

The following examples use John Gruber's original Markdown introduction:

$ wget

Extracting an H3 heading Command-Line:

$ submark --h3 "Command-Line" index.text
### Command-Line

Use the `--html4tags` command-line switch to produce HTML output from a
Unix-style command line. E.g.:

    % perl --html4tags foo.text

Type `perldoc`, or read the POD documentation within the source code for more information.

Note that its textual style differ from the original text. Since submark internally builds an abstract syntax tree from the given input text and then render again the result tree, it doesn't maintain trivial styles (e.g., whitespaces, ATX vs. Setext headings) but only the semantics.

There are options from --h1 to --h6:

$ submark --h2 "Download" index.text
## Download

[Markdown 1.0.1](
(18 KB) -- 17 Dec 2004

The leading heading can be omitted:

$ submark --h2 "Download" --omit-heading index.text
[Markdown 1.0.1](
(18 KB) -- 17 Dec 2004

By Unix convention, - means pipe:

$ submark --h2 "Download" - < index.text
## Download

[Markdown 1.0.1](
(18 KB) -- 17 Dec 2004

There's -o/--out-file option as well:

$ submark -o --h2 "Download" index.text