From f4266f99959466d4c71e63c0b261326ebc0bdcc6 Mon Sep 17 00:00:00 2001 From: Milton Mazzarri Date: Wed, 20 May 2015 03:32:16 -0400 Subject: [PATCH] Add support for fenced code blocks This includes the following: * Add the `:fenced_code` for the Hoedown parser * Add the `fenced_code_blocks` extension for Pandoc * Manually install `pandoc` v1.13.2 via `.travis.yml` As a side note, in the case of the Earmark parser the support for fenced code blocks is already included. --- .travis.yml | 3 ++- lib/ex_doc/markdown/hoedown.ex | 2 ++ lib/ex_doc/markdown/pandoc.ex | 2 +- lib/ex_doc/retriever.ex | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 236034dc3..154e10550 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ notifications: otp_release: - 17.0 before_install: - - sudo apt-get install -y pandoc + - wget -c https://github.com/jgm/pandoc/releases/download/1.13.2/pandoc-1.13.2-1-amd64.deb + - sudo dpkg -i pandoc-1.13.2-1-amd64.deb - git clone https://github.com/elixir-lang/elixir - cd elixir && make && cd .. before_script: "export PATH=`pwd`/elixir/bin:$PATH" diff --git a/lib/ex_doc/markdown/hoedown.ex b/lib/ex_doc/markdown/hoedown.ex index 27377a173..e6ff07095 100644 --- a/lib/ex_doc/markdown/hoedown.ex +++ b/lib/ex_doc/markdown/hoedown.ex @@ -7,12 +7,14 @@ defmodule ExDoc.Markdown.Hoedown do Hoedown specific options: * `:autolink` - defaults to true + * `:fenced_code` - defaults to true * `:tables` - Enables Markdown Extra style tables, defaults to true """ def to_html(text, opts \\ []) do Markdown.to_html(text, autolink: Keyword.get(opts, :autolink, true), + fenced_code: Keyword.get(opts, :fenced_code, true), tables: Keyword.get(opts, :tables, true)) end end diff --git a/lib/ex_doc/markdown/pandoc.ex b/lib/ex_doc/markdown/pandoc.ex index eed3246a1..72f1f8de7 100644 --- a/lib/ex_doc/markdown/pandoc.ex +++ b/lib/ex_doc/markdown/pandoc.ex @@ -27,7 +27,7 @@ defmodule ExDoc.Markdown.Pandoc do defp open_port(path, opts) do exe = :os.find_executable('pandoc') - args = ["--from", "markdown", + args = ["--from", "markdown+fenced_code_blocks", "--to", get_string(opts, :format, :html), "--base-header-level", get_string(opts, :header_level, 1), path] diff --git a/lib/ex_doc/retriever.ex b/lib/ex_doc/retriever.ex index 4827f2f95..c01fb4375 100644 --- a/lib/ex_doc/retriever.ex +++ b/lib/ex_doc/retriever.ex @@ -109,7 +109,7 @@ defmodule ExDoc.Retriever do moduledoc: moduledoc, docs: docs, typespecs: get_types(module), - source: source_link(source_path, source_url, line), + source: source_link(source_path, source_url, line) } end