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

Span extensions running twice. #136

Open
Hampei opened this issue Sep 2, 2014 · 1 comment
Open

Span extensions running twice. #136

Hampei opened this issue Sep 2, 2014 · 1 comment

Comments

@Hampei
Copy link

Hampei commented Sep 2, 2014

I have an extension that adds a span around some strings, but adds the same string in again as well.
It gets run when creating the maruku object and again over the previously generated string when calling to_html, which is once to many.
I don't know if it worked differently in 0.6 or if it's just that spans where not being parsed for markdown before.

> m = Maruku.new("{{test}}")
=> md_el(:document, md_par(md_html("<span class='text_var' text_var='test'>{{test}}</span>")))
> m.to_html
=> "\n<p><span class='text_var' text_var='test'><span class='text_var' text_var='test'>{{test}}</span></span></p>\n"
MaRuKu::In::Markdown.register_span_extension(
  chars: (RUBY_VERSION >= '1.9' ? '{' : 123),
  regexp: /(\{\{)(.+?)(\}\})/,
  handler: lambda do |doc, src, con|
    m = src.read_regexp(TEXT_VAR)
    var_name = m.captures.compact[1]
    string = "<span class='text_var' text_var='#{var_name}'>{{#{var_name}}}</span>"
    con.push doc.md_html(string)
    true
  end)
@distler
Copy link
Collaborator

distler commented Sep 2, 2014

I don't know if it worked differently in 0.6 or if it's just that spans where not being parsed for markdown before.

See the resolution to Issue 31.

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

2 participants