How to Pass Content to Jekyll Default Converter After Custom Conversion

how to pass content to jekyll default converter after custom conversion?

Here's how to do it:

module Jekyll
class MyConverter < Converter
safe :false
priority :high

def matches(ext)
ext =~ /^\.(md|markdown)$/i
end

def output_ext(ext)
".html"
end

def convert(content)
# do your own thing with the content
content = my_own_thing(content)

# Now call the standard Markdown converter
site = Jekyll::Site.new(@config)
mkconverter = site.getConverterImpl(Jekyll::Converters::Markdown)
mkconverter.convert(content)
end
end
end

Basically, you were right in using Jekyll::Converters::Markdown, but you need not specify KramdownParser, as your chosen parser will be automatically chosen from Jekyll::Site when you pass @config into the constructor.

Simple Jekyll converter plugin not working

Problem solved. It turns out that there's nothing wrong with the above code.

The problem was that at some point, the github-pages gem had been added to our Gemfile (unneeded). Apparently, with the github-pages plugin, Jekyll is always started in safe mode and the plugin_dir is a random string.

Removing the github-pages gem from our Gemfile fixed it!

Jekyll markdown converter escaping tags

Try :

{::nomarkdown}
your code here
{:/nomarkdown}

or

Remove all indentation from your generated code.
If you have four space indentation, kramdown treat this like code.

Convert Jekyll posts with Redcarpet

Looks like the way to use Redcarpet in Jekyll is by instantiating that class, and passing in site.config.

converter = Jekyll::Converters::Markdown::RedcarpetParser.new(site.config)

Convert Google Docs to Jekyll Markdown

May 2018 Update

The script originally suggested in this answer appears to no longer work and has not been updated for 5 years.

An alternative solution (which is based on the old script) can be found at https://github.com/evbacher/gd2md-html

I tried it out, it works pretty well.

Previous Answer

You can use a Google Script to do the conversion for you!

This one will let you convert to .md and it will email you the converted file. I've tested it and works fine. It works with basic tables, and if you have images in the doc, it will attach them to the email.

Instructions for installing are on the same link, in the GitHub description, but I pasted it here for ease of access:

Add the script:

  • Open your Google Drive document (http://drive.google.com)
  • Tools ->
    Script Manager > New
  • Select "Blank Project", then paste this code in
    and save.
  • Clear the myFunction() default empty function and paste the
    contents of converttomarkdown.gapps into the code editor
  • File -> Save

Run the script:

  • Tools > Script Manager
  • Select "ConvertToMarkdown" function.
  • Click Run
    button (First run will require you to authorize it. Authorize and run
    again)
  • Converted doc with images attached will be emailed to you.
    Subject will be "[MARKDOWN_MAKER]...".

Good luck!



Related Topics



Leave a reply



Submit