anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Markdown support feature #32

Open mcdoyaji opened 8 years ago

mcdoyaji commented 8 years ago

This is great tool. I don't know Why this tool is not famous ....

Anyway, could you make Markdown support feature?

or convert from markdown... I have a bunch of markdown document...

and the convert process is so pain.

craigdietrich commented 7 years ago

@baram204 Thanks for your note and kind words!

There's a number of markdown to HTML converters online, e.g., https://www.browserling.com/tools/markdown-to-html

Did you have something in mind as to what a built-in markdown converter might do?

scottkleinman commented 7 years ago

Here's one makeshift solution to grab some Markdown from GitHub. Place the following code in the source of your page:

<script src="https://cdn.jsdelivr.net/remarkable/1.7.1/remarkable.min.js"></script>
<div id="github-content" style="display:none;"></div>

Then add to the pages Javascript options (adding the URL of the raw Markdown document on GitHub):

$(document).ready(function(){
    $("#github-content").load("URL_OF_MARKDOWN.md", function(markdown){
      var md = new Remarkable('commonmark');
      var html = md.render(markdown);
      $("#github-content").html(html).show();
    });
  });

The Scalar user guide warns that $(document).ready() may not work, but it does in this case. Grabbing Markdown content from GitHub allows you to edit offline and get excellent version control. The downside is that your content may not be wrapped in Scalar's proprietary markup, which may be needed for some Scalar functionality (plus, it adds a couple of extra http requests). I haven't tested yet whether the imported content will be retrievable using Scalar's API, for instance.

I think these are the sort of issues that would have to be addressed to add Markdown support. Perhaps CKEditor's Markdown plugin could be enabled to allow Markdown editing online. But I'm not sure what would be required to add specific Scalar functionalities. Still, I hope this is a start.