[Jupyter] Some refactoring and logic fixes for Markdown import

Authored by sirgienko on Jun 10 2019, 10:04 PM.