Skip to content

Commit 35933e1

Browse files
committed
Merge branch 'main' of github.com:bert-github/gf-markdown-awk
2 parents 70896a8 + 9b93f00 commit 35933e1

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1-
# markdown.awk
2-
Awk library to convert GitHub-flavored markdown to HTML or to plain text
1+
# gf-markdown-awk
2+
Awk library to convert GitHub-flavored markdown to HTML or to plain text.
3+
4+
To use this to make a program that converts markdown to HTML, write the following Awk code:
5+
6+
@include "markdown.awk"
7+
{ lines = lines $0 "\n" }
8+
END { printf "%s", markdown::to_html(lines) }
9+
10+
(Requires the Gnu version of Awk, because it uses ‘@include’ and namespaces.)
11+
12+
More documentation is included in the `markdown.awk` file.
13+
14+
## What is this for?
15+
There are several programs that convert markdown ([GitHub-flavored markdown](https://github.github.com/gfm/) or other dialects) to HTML and this one isn't the best (see [limitations](#limitations) below). So why this code?
16+
17+
It's not a program, but a library. (Although it only requires three lines to make it a program, see above). And in particular it is a library for *Awk.* It is meant for people who need to add markdown support to an Awk program.
18+
19+
You could, of course, call an external program from your Awk script to convert markdown to HTML. But this library provides two extra functions that may occasionally be handy and that existing programs don't provide. (At least I haven't found any.) And that is the ability to parse inline markdown only, i.e., bold, italics, links, etc., while ignoring paragraphsm lists, etc.; and the ability to strip markdown from text to retain just the plain text content.
20+
21+
The former is provided by the function `markdown::to_inline_html()`, the latter by the function `markdown::to_text()`.
22+
23+
## Limitations
24+
The code does not (yet?) implement ‘setexts headings’ (headings that are underlined instead of prefixed with one or more ‘#’ characters) and ‘tight lists’ (lists where the generated HTML looks like `<li>item</li>` instead of `<li><p>item</p></li>`).
25+
26+
## Bugs
27+
Probably.

0 commit comments

Comments
 (0)