-
Notifications
You must be signed in to change notification settings - Fork 0
pandoc link2span
This is the documentation for pandoc-link2span.pl .
pandoc-link2span.pl - filter which overloads link syntax to define spans.
0.001
pandoc -F pandoc-link2span.pl [PANDOC-OPTIONS] FILE_NAME ...
pandoc-link2span.pl
is a pandoc filter which overloads link syntax to define spans.
You write a 'link' where the 'URL' is an asterisk (*
) and the 'title' is an attribute spec similar to that used with headers, fenced code blocks or inline code:
[foo bar](* "#foo .bar baz=biz buz="böp" quo='it''s ok'")
This is actually converted into:
<span id="foo" class="bar" baz="biz" buz="böp" quo="it's ok">foo bar</span>
Note that reference links do what you would expect:
[quux blort][zigzag]
[plugh xyzzy][zigzag]
[zigzag]: * ".zig .zag"
<span class="zig zag">quux blort</span>
<span class="zig zag">plugh xyzzy</span>
The link text will become the content of the span. It can contain any inline constructs except links. This unfortunately means that you also cannot include a similarly defined span inside the first one!
Pandoc may have trouble with double quotes inside a title string, but you can always escape them with backslashes for clarification. The filter's parsing on the other hand is rather primitive, being based on a regular expression. Attribute values which neither contain whitespace or begin with a quote character can just be written wiithout any outer quotes. You can have multi-word attribute values (but not ids or classes) by double- or single-quoting the value after the equals sign, and quote marks of the 'opposite' kind are readily accepted inside such values, but since backslash-escaped punctuation characters would be resolved by pandoc -- and since second-level backslash-escaping (\\\"
) may be hard to keep track of -- to have quote marks of the same kind inside such a value you have to double the quote mark (either single or double), but as you can see from these examples you will probably still prefer to always use single quotes to quote attribute values to avoid having repeated backslash-escaped double quotes:
[the text]( * "title='It''s ok'")
<span title="It's ok">the text</span>
[the text]( * "title=\"Plan \"\"B\"\"\"" )
<span title="Plan "B"">the text</span>
[the text]( * "title='Plan \"B\"'")
<span title="Plan "B"">the text</span>
[viz.](* "title=videlicet")
<span title="videlicet">viz.</span>
Benct Philip Jonsson <[email protected]>, https://github.com/bpj
Copyright 2015- Benct Philip Jonsson
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.