Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add custom method to replace text when already using CodeRay ? #713

Open
chrisvel opened this issue Jul 14, 2021 · 0 comments
Open

Comments

@chrisvel
Copy link

chrisvel commented Jul 14, 2021

This is my markdown rendering code:

def markdown(text)
    coderayified = CodeRayify.new(:filter_html => false,
                                  :hard_wrap => true)
    options = {
      :fenced_code_blocks => true,
      :no_intra_emphasis => true,
      :autolink => true,
      :strikethrough => true,
      :lax_html_blocks => true,
      :superscript => true,
      :tables => true,
      :highlight => true,
      :quote => true,
      :filter_html => false,
      :safe_links_only => true
    }
    markdown_to_html = Redcarpet::Markdown.new(coderayified, options)
    markdown_to_html.render(text).html_safe
  end

I want to add a custom method to replace some text, for example:

Links like

{-[another-link](https://goessomewhere.com)-}

should be replaced with

{<a href="https://goessomewhere.com" class="custom-link">another link</a>}

Does anyone have any idea how can I achieve this, especially now that I am already using a Renderer?

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

No branches or pull requests

1 participant