render_markdown filter

This commit is contained in:
Clément Fournier
2018-05-25 03:16:01 +02:00
parent de080f02e4
commit c145ff5d3f
3 changed files with 12 additions and 8 deletions

View File

@ -11,13 +11,7 @@
{% capture required_label %}{% if include.required %}<span class="label label-primary">Required</span> {% endif %}{% endcapture %}
<tr>
<td><code>{{ include.options | split: ',' | mappend: arg | join: "</code><br/><code>" }}</code></td>
<td>{{ required_label }}
{{ include.description
| regex_replace: "`(.*?)`", "<code>\1</code>"
| regex_replace: "\*\*(.*?)\*\*", "<b>\1</b>"
| regex_replace: "\*(.*?)\*", "<i>\1</i>"
| regex_replace: "\[(.*?)\]\((.*?)\)", "<a href='\2'>\1</a>" }}
</td>
<td>{{ required_label }}{{ include.description | render_markdown }}</td>
<td><code>{{ include.default }}</code></td>
<td>{{ include.languages }}</td>
</tr>

View File

@ -68,6 +68,16 @@ module CustomFilters
end
end
def render_markdown(input)
if input
res = input
res = res.gsub(/`(.*?)`/, '<code>\1</code>')
res = res.gsub(/\*\*(.*?)\*\*/, '<b>\1</b>')
res = res.gsub(/\*(.*?)\*/, '<i>\1</i>')
res.gsub(/\[(.*?)\]\((.*?)\)/, '<a href="\2">\1</a>')
end
end
private

View File

@ -39,7 +39,7 @@ The tool comes with a rather extensive help text, simply running with `-help`!
{% include custom/cli_option_row.html options="-auxclasspath"
option_arg="cp"
description="Specifies the classpath for libraries used by the source code.
This is used by the type resolution. Alternatively a `file://` URL
This is used to resolve types in source files. Alternatively, a `file://` URL
to a text file containing path elements on consecutive lines can be specified."
languages="Java"
%}