- Shell 54.8%
- Awk 29.2%
- Vim Script 12.2%
- Makefile 3.8%
| contrib/vim | awk is back in town | |
| share/mashup | quotes and dashes | |
| src | quotes and dashes | |
| LICENSE | first | |
| Makefile | awk is back in town | |
| README.md | quotes and dashes | |
mashup
In a previous hack, mawkdown,
the shell feature that was added for fun turned out to be the best thing about it.
So here's a follow-up built entirely around that idea, and directly embedded in shell.
Usage
Mashup consists of two tools, mashup and mawkup. The former evaluates shell as in a heredoc, and the latter translates mashup markup into HTML.
# title: Mashup document
# date: 2025年08月03日
= Hello
This is a page and it was written at `date -d $MSH_DATE +'%c'`.
`echo 'This is evaluated as shell'`, $(echo ', as is this').
You can extend mashup with inline shell, or use some of the builtin functions:
Links can be created with `a -l sv https://owl.is "Owl's homepage"`. # -l is for hreflang
`blockquote -c Owl 'Mashup is the greatest thing since potatoes got mashed up.'` # -c is for <cite>
Syntax
There is no longer dedicated syntax for so many things, since the shell powers have been expanded and can be used inline, but there's the basics:
= Headings
== More headings (up to 6)
- Unordered lists
+ Ordered lists
Paragraphs with *strong*, /emphasis/, |mark|, _unarticulated annotation_,
~deleted~.
There are also footnotes^a1, that are rendered at the end of the output when
`-n` is given.
^a1 Footnote content goes at the start of any line, but is rendered at the end.
# Line comments are removed
And you can of course use shell to generate more mashup markup:
`for i in $(seq 10)
do print '- List item %d\n' "$i"
done`
Metadata
Mashup does not have a dedicated metadata format,
but you can embed metadata in comments and use shell to extract it.
For example, to extract lines in the form # xxx: yyy, which precedes any other content, into variables like MSH_XXX=yyy:
while read -r first key value
do
case "$first$key" in
\#*:) ;;
*) break
esac
uckey=$(tr '[:lower:]' '[:upper:]' <<-EOF
${key%:}
EOF
)
eval "MSH_$uckey=\$value"
done
Templates
The old trick of overriding MSH_FILE to make templates still works, and you can run the 2 passes separately:
cat post.msh
`mashup partials/header.msh | mawkup`
<main>
<article>
`mashup "$MSH_FILE" | mawkup -n`
</article>
</main>
`mashup partials/footer.msh | mawkup`
MSH_FILE=blogpost.msh mashup templates/post.msh
Dependencies and compatibility
POSIX-compatible shell and awk. Tested with busybox and GNU.