Skip to content

Conversation

@1ambda
Copy link
Member

@1ambda 1ambda commented Aug 29, 2016

What is this PR for?

Support table markdown syntax issued by ZEPPELIN-1387

What type of PR is it?

[Bug Fix | Improvement]

This PR can be categorized as bug fix and improvement since it not only resolves the above issue but also support other markdown syntaxes.

Todos

  • - Check the license issue of the pegdown library introduced by this PR

What is the Jira issue?

ZEPPELIN-1387

How should this be tested?

Write markdown texts and compare them with expected html DOMs. I'v also included some tests for this PR.

Screenshots (if appropriate)

markdown

### Questions: - Does the licenses files need update? - Does coding style is appropriate? ### Additional Comments

We might solve this issue by implementing custom table plugin for markdown4j by referring the existing work of txtmark.
But I think it is not good idea in regard to coverage, maintainability and efficiency since markdown4j is currently not developed actively and it costs to implement all markdown plugins which is not supported by markdown4j.

@1ambda 1ambda changed the title [ZEPPELIN-1387] Support table in markdown interpreter [ZEPPELIN-1387] Support table syntax in markdown interpreter Aug 29, 2016
@bzz
Copy link
Member

bzz commented Aug 30, 2016

@1ambda thank you for improvement! Let me review and get back to you with it.

@AhyoungRyu
Copy link
Contributor

@1ambda Thank you for the contribution! I just shortly look through the screenshot in the description, but comparing to Github markdown support it seems Zeppelin's table doesn't have a table border. If I make the below table in Github,

| Tables   |      Are      |  Cool |
|----------|:-------------:|------:|
| col 1 is |  left-aligned | $1600 |
| col 2 is |    centered   |   $12 |
| col 3 is | right-aligned |    $1 |

it will be shown like this.

screen shot 2016-08-30 at 11 10 51 am

But in Zeppelin it doesn't have the border.
screen shot 2016-08-30 at 11 17 57 am

@bzz
Copy link
Member

bzz commented Aug 30, 2016

The change of library looks great to me, 👍 for having a test case!

Few things to take care of, before merging it:

  • for all the code, please make sure it follows project styleguide\code conventions
  • as you add a new dependency - it will become a part of the next release convenience binary for Zeppelin and in order to be included, we need to verify it's licence compatibility. Can you please add it to zeppelin-distribution/src/licence_bin/LICENSE
  • also, applying some styles for such tables, as noted by @AhyoungRyu sounds like a good improvement as well

@1ambda
Copy link
Member Author

1ambda commented Aug 30, 2016

I will refine this PR.

Thanks for the detailed and significant review :) @AhyoungRyu @bzz

@Leemoonsoo
Copy link
Member

Thanks @1ambda for the improvement.

Regarding license, 'markdown4j' section in the zeppelin-distribution/src/licence_bin/LICENSE should be removed while the library is no longer included in the binary package.

Also pegdown library does have some transitive dependencies and they also need to be addressed in zeppelin-distribution/src/licence_bin/LICENSE. @1ambda Could you take care of them if they're not already addressed in zeppelin-distribution/src/licence_bin/LICENSE?

[INFO] +- org.pegdown:pegdown:jar:1.6.0:compile
[INFO] |  \- org.parboiled:parboiled-java:jar:1.1.7:compile
[INFO] |     +- org.parboiled:parboiled-core:jar:1.1.7:compile
[INFO] |     +- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] |     +- org.ow2.asm:asm-tree:jar:5.0.3:compile
[INFO] |     +- org.ow2.asm:asm-analysis:jar:5.0.3:compile
[INFO] |     \- org.ow2.asm:asm-util:jar:5.0.3:compile

@1ambda
Copy link
Member Author

1ambda commented Aug 31, 2016

@Leemoonsoo Thanks!

I'v added missing transitive deps and removed unused markdown4j dep.

I also found that org.ow2.asm:asm:jar:3.1 is described in zeppelin-distribution/src/licence_bin/LICENSE But already denoted license is different version (3.0.1) compared to pegdown's dependency (5.0.3).

Should I updated org.ow2.asm:asm:jar:3.1 to org.ow2.asm:asm:jar:5.0.3?

@felixcheung
Copy link
Member

felixcheung commented Aug 31, 2016

Markdown4j supports YUML and Websequence, does this support the same?

@1ambda
Copy link
Member Author

1ambda commented Aug 31, 2016

@felixcheung Thanks 👍

Pegdown doesn't support YUML, Websequence and Include plugins according to Pegdown Extensions

I think we have 2 options. (or more)

  1. Use markdown4j and implement table plugins correctly.
    ** we might need small effort, but we will depend on markdown4j which is not actively developed.
    ** and other markdown syntaxes might be implemented if necessary.
  2. Use pegdown and implement YUML, Websequence.

@1ambda
Copy link
Member Author

1ambda commented Aug 31, 2016

@AhyoungRyu In regard to table style,

Using CSS (e.g github-markdown-css) would be a better solution rather than adding inline style to every DOM such astable, thead, tbody, tr and td while parsing.

- Wrap parsed DOM with div which has `markdown` class attr
- Style them with github flavored markdown style
  ([github-markdown-css](https://github.com/sindresorhus/github-markdown-css))
- add
  [github-markdown-css](https://github.com/sindresorhus/github-markdown-css) license to `zeppelin-distribution`
@1ambda
Copy link
Member Author

1ambda commented Aug 31, 2016

Now markdown tables are rendered like

screen shot 2016-09-01 at 3 03 02 am

@felixcheung
Copy link
Member

Personally YUML and Websequence is very handy - I use them quite a bit.
What do other think about this?

@AhyoungRyu
Copy link
Contributor

@1ambda Yeah it's good idea to apply github markdown style to Zeppelin. I tested again and it works well. Definitely better than before!

But I found little bit wired behavior when I made a title.

## This is second level title
### This is third level title

This title code makes a link and it's connected to Zeppelin home. Is it intended?
markdown_test

@1ambda
Copy link
Member Author

1ambda commented Sep 1, 2016

@AhyoungRyu

It was due to the ANCHORLINKS option in pegdown. I removed it.

markdown gif

@Leemoonsoo
Copy link
Member

Regarding @felixcheung's comment,

I think keeping backward compatibility is always very important.
If i add more possible options after @1ambda 's

  • Create new interpreter %pd that uses pegdown and restore %md to use markdown4j
  • Add a interpreter property that selects markdown library pegdown/markdown4j.

@AhyoungRyu
Copy link
Contributor

@1ambda Yeah tested again and it looks good👍 Thanks!
(One more thing: Zeppelin's Java block indentation size is 2 spaces :D )

@1ambda
Copy link
Member Author

1ambda commented Sep 2, 2016

@Leemoonsoo

I think option 2 (Adding a property) is a better solution. because

  1. Adding a new interpreter just for supporting another markdown parser might be confusing to users. They might misunderstand pd interpreter.
  2. Pegdown parser will be able to replace markdown4j parser soon if we implement YUML and Websequence. At that time, we can just modify the default parser property of md interpreter instead of requesting for users to change their interpreter type

@1ambda
Copy link
Member Author

1ambda commented Sep 2, 2016

I'v restored the markdown4j parser and added markdown.parser.type property to md group.
The pegdown parser will be used only when users specify pegdown value to the property.

screen shot 2016-09-03 at 1 54 12 am

Additionally,
It seems that description does't show even though i provide it to markdown/src/main/resources/interpreter-setting.json like

[
  {
    "group": "md",
    "name": "md",
    "className": "org.apache.zeppelin.markdown.MarkdownInterpreter",
    "properties": {
      "markdown.parser.type": {
        "envName": "MARKDOWN_PARSER_TYPE",
        "propertyName": "markdown.parser.type",
        "defaultValue": "markdown4j",
        "description": "Markdown Parser Type. Available values: markdown4j, pegdown. Default = markdown4j"
      }
    }
  }
]

@AhyoungRyu
Copy link
Contributor

AhyoungRyu commented Sep 4, 2016

@1ambda Great! It works well as expected 👍

If you want to add the interpreter property(markdown.parser.type) to the markdown interpreter, it would be better to provide that information via Zeppelin markdown interpreter docs with configuration table as like the other interpreters do. Nothing much needed. You can just copy and paste the below conf table to markdown.md.

## Configuration
<table class="table-configuration">
  <tr>
    <th>Name</th>
    <th>Default Value</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>markdown.parser.type</td>
    <td>markdown4j </td>
    <td>Markdown Parser Type. <br/> Available values: markdown4j, pegdown.</td>
  </tr>
</table>

Also the below sentences in Overview section need to be updated accordingly.

Markdown is a plain text formatting syntax designed so that it can be converted to HTML. Apache Zeppelin uses markdown4j. For more examples and extension support, please checkout here.

FYI, markdown.md file is under ZEPPELIN_HOME/docs/interpreter/ :)

} catch (IOException | java.lang.RuntimeException e) {
LOGGER.error("Exception in Markdown while interpret ", e);
html = parser.render(markdownText);
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to catch general Exception instead of more specific sub-classes?

@bzz
Copy link
Member

bzz commented Sep 6, 2016

@1ambda 👍 fot tests, looks great to me except for licensing issue raised by Moon and small comment above.

If you could let me know you user name in ASF JIRA I'll be happy to help assigning ZEPPELIN-1387 to you.

@1ambda
Copy link
Member Author

1ambda commented Sep 7, 2016

@Leemoonsoo I'v fixed license description. Also, now I understand when to describe licenses in licenses or bin_licenses. Thanks. :)

@bzz I think it is better to use more specific exception types in catch block as you pointed out. Could you review e08929a again?

@Leemoonsoo
Copy link
Member

Thanks @1ambda. Looks great to me.
Merge if there're no further discussions.

@AhyoungRyu
Copy link
Contributor

@1ambda Sadly the conflict needs to be resolved first before merging. But only for docs/interpreter/markdown.md this file :)

@1ambda
Copy link
Member Author

1ambda commented Sep 20, 2016

@AhyoungRyu

I'v resolved the merge conflict with 8f344db. Could you try again? :)

@1ambda
Copy link
Member Author

1ambda commented Sep 20, 2016

screen shot 2016-09-21 at 1 39 41 am

CI is failing on only the last job.

@AhyoungRyu
Copy link
Contributor

@1ambda Yeah tested locally and looks good. Thanks for your quick response! Now it's really ready to be merged I think 👍
The other PRs' CI are failing in Selenium test because of the same reason. Currently it's tracked in ZEPPELIN-1449.

@corneadoug
Copy link
Contributor

That CI failure is being handled in #1444, you should be able to rebase and have a green CI soon

@corneadoug
Copy link
Contributor

@1ambda You can rebase now :)

@1ambda
Copy link
Member Author

1ambda commented Sep 21, 2016

Now CI is failing on the third build job. :(

I checked out zeppelin/master and merged it on 1ambda/fix-zeppelin-1387.
Should I have used git rebase command instead? I thought using rebase command is not a good idea since it will overwrite
this PR history (comments, etc...)

screen shot 2016-09-21 at 11 00 10 am

screen shot 2016-09-21 at 11 00 26 am

@1ambda
Copy link
Member Author

1ambda commented Sep 21, 2016

Close PR to re-trigger CI

@1ambda 1ambda closed this Sep 21, 2016
@1ambda
Copy link
Member Author

1ambda commented Sep 21, 2016

Open PR to re-trigger CI

@1ambda 1ambda reopened this Sep 21, 2016
@corneadoug
Copy link
Contributor

Usually we prefer rebase since it doesn't pollute the commit history. But its fine, the end result is the same. We sometimes have flaky tests, I will check once the build is finished

@1ambda
Copy link
Member Author

1ambda commented Sep 21, 2016

Finally, CI is green! :)

@corneadoug
Copy link
Contributor

Awesome, Merging if there is no more discussions

@asfgit asfgit closed this in 46cd56a Sep 22, 2016
asfgit pushed a commit that referenced this pull request Sep 28, 2016
### What is this PR for?
Markdown interpreter's class name have changed from `Markdown` to `MarkdownInterpreter` in #1384 and this will bring some compatibility issue in case user have `Markdown` class specified in `conf/interpreter.json` file. This PR rollbacks markdown class name from `MarkdownInterpreter` to `Markdown` to avoid side effect

### What type of PR is it?
Hotfix

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Mina Lee <[email protected]>

Closes #1449 from minahlee/update/markdownClassName and squashes the following commits:

7bdad44 [Mina Lee] Change classname of MarkdownInterpreter -> Markdown
pedrozatta pushed a commit to pedrozatta/zeppelin that referenced this pull request Oct 27, 2016
### What is this PR for?

Support table markdown syntax issued by [ZEPPELIN-1387](https://issues.apache.org/jira/browse/ZEPPELIN-1387?jql=project%20%3D%20ZEPPELIN)

### What type of PR is it?
[Bug Fix | Improvement]

This PR can be categorized as bug fix and improvement since it not only resolves the above issue but also support other markdown syntaxes.

### Todos
* [ ] - Check the license issue of the [pegdown](https://github.com/sirthias/pegdown) library introduced by this PR

### What is the Jira issue?

[ZEPPELIN-1387](https://issues.apache.org/jira/browse/ZEPPELIN-1387?jql=project%20%3D%20ZEPPELIN)

### How should this be tested?

Write markdown texts and compare them with expected html DOMs. I'v also included some tests for this PR.

### Screenshots (if appropriate)

<img width="708" alt="markdown" src="https://cloud.githubusercontent.com/assets/4968473/18061274/1f2be526-6e5d-11e6-9f1a-3528f3958d2c.png">

### Questions:

* Does the licenses files need update?
* Does coding style is appropriate?

### Additional Comments

We might solve this issue by implementing custom table plugin for markdown4j by referring [the existing work of txtmark](zhenchuan/txtmark@1784868).
But I think it is not good idea in regard to coverage, maintainability and efficiency since markdown4j is currently not developed actively and it costs to implement all markdown plugins which is not supported by markdown4j.

Author: 1ambda <[email protected]>

Closes apache#1384 from 1ambda/fix-zeppelin-1387 and squashes the following commits:

16cda72 [1ambda] fix: Merge with 3c8158 to resolve CI failure
e6d41c8 [1ambda] fix: Resolve merge conflict with 8f344db
e08929a [1ambda] fix: Handle more specific exception in catch block
8b1e017 [1ambda] chore: Move github-markdown-css license to bin_licenses
4d1cb3c [1ambda] fix: Typo in docs/interpreter/markdown.md
85a5e3a [1ambda] fix: Use bower to install github-markdown-css
297733f [1ambda] fix: Modify github-markdown-css license
947a92a [1ambda] chore: Add license to newly created java files
d228423 [1ambda] docs: Update markdown docs config, examples
2b6516c [1ambda] feat: Support markdown.parser.type attr in md
d2d4455 [1ambda] style: Reformat using intellij-java-google-style
bf9100d [1ambda] chore: Restore markdown4j dependency
55a2f10 [1ambda] fix: Add MarkdownParser interface to support mulitple parsers
c33c715 [1ambda] fix: Remove the ANCHORLINKS option
9cf31d0 [1ambda] fix: Use markdown-body class (default)
f741949 [1ambda] fix: Add styles for markdown
603d3db [1ambda] fix: Add missing transitive deps for pegdown
7aecdcb [1ambda] chore: Add pegdown to the binary license list
fa14b3e [1ambda] style: Apply google java code style guide
029f550 [1ambda] [ZEPPELIN-1387] Support table in markdown interpreter
pedrozatta pushed a commit to pedrozatta/zeppelin that referenced this pull request Oct 27, 2016
### What is this PR for?
Markdown interpreter's class name have changed from `Markdown` to `MarkdownInterpreter` in apache#1384 and this will bring some compatibility issue in case user have `Markdown` class specified in `conf/interpreter.json` file. This PR rollbacks markdown class name from `MarkdownInterpreter` to `Markdown` to avoid side effect

### What type of PR is it?
Hotfix

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Mina Lee <[email protected]>

Closes apache#1449 from minahlee/update/markdownClassName and squashes the following commits:

7bdad44 [Mina Lee] Change classname of MarkdownInterpreter -> Markdown
asfgit pushed a commit that referenced this pull request Nov 16, 2016
### What is this PR for?

Remove unmanaged, old library markdown4j dep which exists just for Websequence and YUML plugins.
(related to #1384)

By adding Websequence and YUML plugins to pegdown

- Removing markdown4j dependency which is unmanaged library currently.
- Addtionally, we can remove `markdown.parser.type` options in **markdown interpreter**
- Fixing some bugs in Websequence and YUML plugins
- Enable others to add more plugins using pegdown sytnax.

### What type of PR is it?

Improvement

### Todos

Nothing

### What is the Jira issue?

[JIRA - ZEPPELIN-1614](https://issues.apache.org/jira/browse/ZEPPELIN-1614)

### How should this be tested?

Some functional tests are included.

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? - YES
* Is there breaking changes for older versions? - NO
* Does this needs documentation? - YES

Author: 1ambda <[email protected]>

Closes #1594 from 1ambda/feat/remove-markdown4j-dep and squashes the following commits:

5af1607 [1ambda] fix: Failed tests in InterpreterRestApiTest
c57fdcb [1ambda] docs: Update markdown.md
5c62236 [1ambda] docs: Update upgrade.md for '%md'
a1e779d [1ambda] style: Use zeppelin checkstyle.xml
13e0dc4 [1ambda] Update: interpreter setting and docs
de3549d [1ambda] chore: Cleanup duplicated markdown4j license
7c5d41e [1ambda] fix: Parse style param optionally in webseq
8831ca1 [1ambda] fix: Wrap exceptions in catch stmt
9268695 [1ambda] Revert "fix: Cleanup unused Markdown4j Parser"
33fb800 [1ambda] Revert "docs: Remove markdown.parser.type option"
fddc459 [1ambda] Revert "chore: Remove markdown4j dep and update license"
a59ebbd [1ambda] Revert "fix: Set {} to avoid 503"
4e48933 [1ambda] Revert "fix: Parse style param optionally in webseq"
8cfb2c8 [1ambda] Revert "fix: style and misspell in docs"
73956e0 [1ambda] Revert "fix: Propagate exception in YUML plugin"
1b7787f [1ambda] fix: Propagate exception in YUML plugin
c656d08 [1ambda] fix: style and misspell in docs
dc4f110 [1ambda] fix: Parse style param optionally in webseq
b43e14e [1ambda] fix: Set {} to avoid 503
c48cc53 [1ambda] chore: Remove markdown4j dep and update license
81fdfcc [1ambda] docs: Remove markdown.parser.type option
cf19f0b [1ambda] fix: Cleanup unused Markdown4j Parser
98b2809 [1ambda] fix: Add missing docs
3e9716d [1ambda] feat: Yuml markdown plugin
3247c67 [1ambda] feat: Support webseq markdown plugin
tae-jun pushed a commit to tae-jun/zeppelin that referenced this pull request Nov 23, 2016
### What is this PR for?

Remove unmanaged, old library markdown4j dep which exists just for Websequence and YUML plugins.
(related to apache#1384)

By adding Websequence and YUML plugins to pegdown

- Removing markdown4j dependency which is unmanaged library currently.
- Addtionally, we can remove `markdown.parser.type` options in **markdown interpreter**
- Fixing some bugs in Websequence and YUML plugins
- Enable others to add more plugins using pegdown sytnax.

### What type of PR is it?

Improvement

### Todos

Nothing

### What is the Jira issue?

[JIRA - ZEPPELIN-1614](https://issues.apache.org/jira/browse/ZEPPELIN-1614)

### How should this be tested?

Some functional tests are included.

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? - YES
* Is there breaking changes for older versions? - NO
* Does this needs documentation? - YES

Author: 1ambda <[email protected]>

Closes apache#1594 from 1ambda/feat/remove-markdown4j-dep and squashes the following commits:

5af1607 [1ambda] fix: Failed tests in InterpreterRestApiTest
c57fdcb [1ambda] docs: Update markdown.md
5c62236 [1ambda] docs: Update upgrade.md for '%md'
a1e779d [1ambda] style: Use zeppelin checkstyle.xml
13e0dc4 [1ambda] Update: interpreter setting and docs
de3549d [1ambda] chore: Cleanup duplicated markdown4j license
7c5d41e [1ambda] fix: Parse style param optionally in webseq
8831ca1 [1ambda] fix: Wrap exceptions in catch stmt
9268695 [1ambda] Revert "fix: Cleanup unused Markdown4j Parser"
33fb800 [1ambda] Revert "docs: Remove markdown.parser.type option"
fddc459 [1ambda] Revert "chore: Remove markdown4j dep and update license"
a59ebbd [1ambda] Revert "fix: Set {} to avoid 503"
4e48933 [1ambda] Revert "fix: Parse style param optionally in webseq"
8cfb2c8 [1ambda] Revert "fix: style and misspell in docs"
73956e0 [1ambda] Revert "fix: Propagate exception in YUML plugin"
1b7787f [1ambda] fix: Propagate exception in YUML plugin
c656d08 [1ambda] fix: style and misspell in docs
dc4f110 [1ambda] fix: Parse style param optionally in webseq
b43e14e [1ambda] fix: Set {} to avoid 503
c48cc53 [1ambda] chore: Remove markdown4j dep and update license
81fdfcc [1ambda] docs: Remove markdown.parser.type option
cf19f0b [1ambda] fix: Cleanup unused Markdown4j Parser
98b2809 [1ambda] fix: Add missing docs
3e9716d [1ambda] feat: Yuml markdown plugin
3247c67 [1ambda] feat: Support webseq markdown plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants