rubygollum-wiki

How can I add an extension that uses the internal Gollum markdown processor?


Things I've tried

  1. Creating a new extension and custom renderer
    • This works except there is no reason to implement a custom processor (pandoc)
    • This would be ideal so that the Markdown name ends up in the Edit page. However, I don't think I should have to involve pandoc here
    • How in the heck do I get the edit page to default the markdown to vimwiki when editing a vimwiki extension?
    • file used: blah.vimwiki
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES

################### custom extension + renderer
# # Custom extension rendering
# ## References
# * file reference: /var/lib/gems/2.1.0/gems/github-markup-1.6.0/lib/github/markup/command_implementation.rb
# * [Adding Pandoc to Gollum - Martin Wolf's weblog [OUTDATED]](https://www.mwolf.net/2014/04/29/adding-pandoc-to-gollum/)
ci = ::GitHub::Markup::CommandImplementation.new(
     /vimwiki/,
     ["Vimwiki"],
     "pandoc -f markdown-tex_math_dollars-raw_tex",
     :vimwiki)

# bind your own extension regex (the new set of extensions will also include `.asc` and `.adoc`):
# # * file reference: /var/lib/gems/2.1.0/gems/github-markup-1.6.0/lib/github/markups.rb
Gollum::Markup.register(:vimwiki,  "Vimwiki")
Gollum::Markup.formats[:vimwiki][:regexp] = /vimwiki/
GitHub::Markup::markup_impl(:vimwiki, ci)
##################
  1. Attempt to replace the Markdown primary extension and regex.
    • I don't understand why this isn't working unless I'm misunderstanding the order of operations for matching and overrides.
    • The page will display, the extension is recognized, but the page does not format at all -scrunches everything together.
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES

# Attempt to replace the primary extension for Markdown
# remove the original markdown binding:
Gollum::Markup.formats.delete(:markdown)

# and define your own 
Gollum::Markup.formats[:thing] = {
    :name => "Markdown",
    :regexp => /thing/
}
  1. Attempt to just replace the markdown extension regex
    • Same result as attempt 2.
    • The page will display but it is not formatted correctly
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES

Gollum::Markup.formats[:markdown][:regexp] = /vimwiki|thing/

Solution

  • I'm closing the question:

    As it turns out there is no way easy way to use the markdown processor and also get the edit page to recognize that there is a different extension. The markdown processor requires the extension to be valid it it's regex of extensions found in markdown.rb.

    The bottom line is that I would need to implement something similar to what pandoc is doing anyway. So I'm just going just drop the subject and stick with pandoc -'Things I've tried #1' from the original question.

    Rather than take a bunch of space here I've posted the documentation on the project page with code examples

    Thank you to whomever spent some time thinking about this.