diff --git a/STYLE.md b/STYLE.md
index 9a0242e07e3..db6a40ce5cb 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -7,7 +7,7 @@ app/styles/looknfeel
Overall look and theme of the Zeppelin notebook page can be customized here.
### Code Syntax Highlighting
-There are two parts to code highlighting. First, Zeppelin uses the Ace Editor for its note paragraphs. Color style for this can be changed by setting theme on the editor instance. Second, Zeppelin's Markdown interpreter calls markdown4j to emit HTML, and such content may contain <pre><code> tags that can be consumed by Highlight.js.
+There are two parts to code highlighting. First, Zeppelin uses the Ace Editor for its note paragraphs. Color style for this can be changed by setting theme on the editor instance. Second, Zeppelin's Markdown interpreter calls pegdown parser to emit HTML, and such content may contain <pre><code> tags that can be consumed by Highlight.js.
#### Theme on Ace Editor
app/scripts/controllers/paragraph.js
@@ -16,7 +16,7 @@ Call setTheme on the editor with the theme path/name.
[List of themes on GitHub](https://github.com/ajaxorg/ace/tree/master/lib/ace/theme)
#### Style for Markdown Code Blocks
-Highlight.js parses and converts <pre><code> blocks from markdown4j into keywords and language syntax with proper styles. It also attempts to infer the best fitting language if it is not provided. The visual style can be changed by simply including the desired [stylesheet](https://github.com/components/highlightjs/tree/master/styles) into app/index.html. See the next section on build.
+Highlight.js parses and converts <pre><code> blocks from pegdown parser into keywords and language syntax with proper styles. It also attempts to infer the best fitting language if it is not provided. The visual style can be changed by simply including the desired [stylesheet](https://github.com/components/highlightjs/tree/master/styles) into app/index.html. See the next section on build.
Note that code block background color is overriden in app/styles/notebook.css (look for .paragraph .tableDisplay .hljs).
diff --git a/docs/assets/themes/zeppelin/img/docs-img/markdown-example-markdown4j-parser.png b/docs/assets/themes/zeppelin/img/docs-img/markdown-example-pegdown-parser-plugins.png
similarity index 100%
rename from docs/assets/themes/zeppelin/img/docs-img/markdown-example-markdown4j-parser.png
rename to docs/assets/themes/zeppelin/img/docs-img/markdown-example-pegdown-parser-plugins.png
diff --git a/docs/assets/themes/zeppelin/img/docs-img/markdown-interpreter-setting.png b/docs/assets/themes/zeppelin/img/docs-img/markdown-interpreter-setting.png
index 33c13ec31ba..1d427797f60 100644
Binary files a/docs/assets/themes/zeppelin/img/docs-img/markdown-interpreter-setting.png and b/docs/assets/themes/zeppelin/img/docs-img/markdown-interpreter-setting.png differ
diff --git a/docs/install/upgrade.md b/docs/install/upgrade.md
index a203f6fc014..a29ed8db327 100644
--- a/docs/install/upgrade.md
+++ b/docs/install/upgrade.md
@@ -53,3 +53,4 @@ So, copying `notebook` and `conf` directory should be enough.
- Mapping from `%jdbc(prefix)` to `%prefix` is no longer available. Instead, you can use %[interpreter alias] with multiple interpreter setttings on GUI.
- Usage of `ZEPPELIN_PORT` is not supported in ssl mode. Instead use `ZEPPELIN_SSL_PORT` to configure the ssl port. Value from `ZEPPELIN_PORT` is used only when `ZEPPELIN_SSL` is set to `false`.
- The support on Spark 1.1.x to 1.3.x is deprecated.
+ - From 0.7, we uses `pegdown` as the `markdown.parser.type` option for the `%md` interpreter. Rendered markdown might be different from what you expected
diff --git a/docs/interpreter/markdown.md b/docs/interpreter/markdown.md
index 257e146d212..46fd1701ba3 100644
--- a/docs/interpreter/markdown.md
+++ b/docs/interpreter/markdown.md
@@ -25,14 +25,24 @@ limitations under the License.
## Overview
[Markdown](http://daringfireball.net/projects/markdown/) is a plain text formatting syntax designed so that it can be converted to HTML.
-Apache Zeppelin uses [markdown4j](https://github.com/jdcasey/markdown4j) and [pegdown](https://github.com/sirthias/pegdown) as markdown parsers.
+Apache Zeppelin uses [pegdown](https://github.com/sirthias/pegdown) and [markdown4j](https://github.com/jdcasey/markdown4j) as markdown parsers.
In Zeppelin notebook, you can use ` %md ` in the beginning of a paragraph to invoke the Markdown interpreter and generate static html from Markdown plain text.
-In Zeppelin, Markdown interpreter is enabled by default and uses the [markdown4j](https://github.com/jdcasey/markdown4j) parser.
+In Zeppelin, Markdown interpreter is enabled by default and uses the [pegdown](https://github.com/sirthias/pegdown) parser.
+## Example
+
+The following example demonstrates the basic usage of Markdown in a Zeppelin notebook.
+
+
+
+## Mathematical expression
+
+Markdown interpreter leverages %html display system internally. That means you can mix mathematical expressions with markdown syntax. For more information, please see [Mathematical Expression](../displaysystem/basicdisplaysystem.html#mathematical-expressions) section.
+
## Configuration
@@ -42,31 +52,25 @@ In Zeppelin, Markdown interpreter is enabled by default and uses the [markdown4j
| markdown.parser.type |
- markdown4j |
- Markdown Parser Type. Available values: markdown4j, pegdown. |
+ pegdown |
+ Markdown Parser Type. Available values: pegdown, markdown4j. |
-## Example
-
-The following example demonstrates the basic usage of Markdown in a Zeppelin notebook.
-
+### Pegdown Parser
-## Mathematical expression
+`pegdown` parser provides github flavored markdown.
-Markdown interpreter leverages %html display system internally. That means you can mix mathematical expressions with markdown syntax. For more information, please see [Mathematical Expression](../displaysystem/basicdisplaysystem.html#mathematical-expressions) section.
+
+`pegdown` parser provides [YUML](http://yuml.me/) and [Websequence](https://www.websequencediagrams.com/) plugins also.
+
### Markdown4j Parser
-`markdown4j` parser provides [YUML](http://yuml.me/) and [Websequence](https://www.websequencediagrams.com/) extensions
-
-
-
-### Pegdown Parser
+Since pegdown parser is more accurate and provides much more markdown syntax
+`markdown4j` option might be removed later. But keep this parser for the backward compatibility.
-`pegdown` parser provides github flavored markdown.
-
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
index a811eabaa62..c908a5449de 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown.java
@@ -33,13 +33,17 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/** MarkdownInterpreter interpreter for Zeppelin. */
+/**
+ * MarkdownInterpreter interpreter for Zeppelin.
+ */
public class Markdown extends Interpreter {
private static final Logger LOGGER = LoggerFactory.getLogger(Markdown.class);
private MarkdownParser parser;
- /** Markdown Parser Type. */
+ /**
+ * Markdown Parser Type.
+ */
public enum MarkdownParserType {
PEGDOWN {
@Override
@@ -82,7 +86,8 @@ public void open() {
}
@Override
- public void close() {}
+ public void close() {
+ }
@Override
public InterpreterResult interpret(String markdownText, InterpreterContext interpreterContext) {
@@ -99,7 +104,8 @@ public InterpreterResult interpret(String markdownText, InterpreterContext inter
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+ }
@Override
public FormType getFormType() {
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
index 68ca41b3fc9..78f81372569 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/Markdown4jParser.java
@@ -23,7 +23,9 @@
import java.io.IOException;
-/** Markdown Parser using markdown4j processor . */
+/**
+ * Markdown Parser using markdown4j processor.
+ */
public class Markdown4jParser implements MarkdownParser {
private Markdown4jProcessor processor;
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/MarkdownParser.java b/markdown/src/main/java/org/apache/zeppelin/markdown/MarkdownParser.java
index 056ca26ca80..2f8717e1a90 100644
--- a/markdown/src/main/java/org/apache/zeppelin/markdown/MarkdownParser.java
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/MarkdownParser.java
@@ -17,7 +17,9 @@
package org.apache.zeppelin.markdown;
-/** Abstract Markdown Parser. */
+/**
+ * Abstract Markdown Parser.
+ */
public interface MarkdownParser {
String render(String markdownText);
}
diff --git a/markdown/src/main/java/org/apache/zeppelin/markdown/ParamVar.java b/markdown/src/main/java/org/apache/zeppelin/markdown/ParamVar.java
new file mode 100644
index 00000000000..14828e0085f
--- /dev/null
+++ b/markdown/src/main/java/org/apache/zeppelin/markdown/ParamVar.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.markdown;
+
+import org.parboiled.support.Var;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implementation of Var to support parameter parsing.
+ *
+ * @param Key
+ * @param Value
+ */
+public class ParamVar extends Var