diff --git a/README.md b/README.md index ed181d39332604f275ba29ce8e8a34aa40ea6983..c22f92632ab2186f3f6a3e637354360e1321f8a3 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,34 @@ Example: The conversion function will fetch the current branch name from git, and fail if it cannot do so. +Github customizations +===================== +`pre` tags are converted into github "fenced" code blocks, i.e. + +``` +```...''' +``` + +. If language-specific syntax highlighting is desired, +this can be achieved by adding a 'lang' attribute, e.g. + +``` +<pre lang="erlang"> +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. +</pre> +``` + +which should format like this: + +```erlang + +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. + +``` Rebar customizations ==================== diff --git a/doc/README.md b/doc/README.md index f14e1a225ad9126ec04ed40a00fd5cb7328091a6..5900de1b3f5ee08d5ade55027b8d03418bbbeee3 100644 --- a/doc/README.md +++ b/doc/README.md @@ -44,6 +44,34 @@ Example: The conversion function will fetch the current branch name from git, and fail if it cannot do so. +Github customizations +===================== +`pre` tags are converted into github "fenced" code blocks, i.e. + +``` +```...''' +``` + +. If language-specific syntax highlighting is desired, +this can be achieved by adding a 'lang' attribute, e.g. + +``` +<pre lang="erlang"> +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. +</pre> +``` + +which should format like this: + +```erlang + +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. + +``` Rebar customizations ==================== diff --git a/doc/overview.edoc b/doc/overview.edoc index c9869e654eb00b6454250167c4bca8de4df2fb3e..70737b0af382712f854e40864dcd4e0a00975fb9 100644 --- a/doc/overview.edoc +++ b/doc/overview.edoc @@ -40,6 +40,27 @@ Example: The conversion function will fetch the current branch name from git, and fail if it cannot do so. +Github customizations +===================== +`pre' tags are converted into github "fenced" code blocks, i.e. +<pre>```...'''</pre>. If language-specific syntax highlighting is desired, +this can be achieved by adding a 'lang' attribute, e.g. + +<pre><pre lang="erlang"> +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. +</pre></pre> + +which should format like this: + +<pre lang="erlang"> +incr(X) -> + %% This should be formatted with Erlang syntax highlighting + X + 1. +</pre> + + Rebar customizations ==================== A set of escripts can be found under diff --git a/src/edown_xmerl.erl b/src/edown_xmerl.erl index 181eb487159253eb29f301466da5c11b4cd7228e..2a8abe2be9f19cf53f5087c4bfe70118ff24c8e4 100644 --- a/src/edown_xmerl.erl +++ b/src/edown_xmerl.erl @@ -230,7 +230,11 @@ md_elem(Tag, Data, Attrs, Parents, E) -> %% would have written it and markdown rendering will take %% care of entity escaping so that a code block describing %% XML or HTML will get rendered properly. - ["\n```\n", Data, "\n```\n"]; + Lang = case lists:keyfind(lang, #xmlAttribute.name, Attrs) of + #xmlAttribute{value = Lang1} -> Lang1; + false -> "" + end, + ["\n```", Lang, "\n", Data, "\n```\n"]; _ -> ["\n", xmerl_lib:start_tag(Tag,Attrs),