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

Do not mention or emojify in a codeblock #163

Closed
parkr opened this issue Dec 1, 2014 · 9 comments · Fixed by #170
Closed

Do not mention or emojify in a codeblock #163

parkr opened this issue Dec 1, 2014 · 9 comments · Fixed by #170
Assignees

Comments

@parkr
Copy link
Contributor

parkr commented Dec 1, 2014

If the @mention or :emoji: is in a code block, do not transform it. This applies to the HTML, rather than to a Markdown, codeblock.

Related issues:

Thanks!

@jch
Copy link
Contributor

jch commented Dec 3, 2014

Could you provide a code snippet to reproduce this? See the contributing guide for details.

@parkr
Copy link
Contributor Author

parkr commented Dec 6, 2014

Input

:metal:
`:metal:`

Output

screen shot 2014-07-30 at 7 06 20 pm

Expected

The :metal: does not change inside <code> or <pre>.

@parkr
Copy link
Contributor Author

parkr commented Dec 8, 2014

@jch Here's the code snippet:

require 'html/pipeline'

#
# Emoji
#

content = <<-MD
:metal:
`:metal:`
MD
puts HTML::Pipeline::EmojiFilter.new(nil, {
  asset_root: "https://assets.github.com/images/icons/"
}).emoji_image_filter(content)

#
# Mentions
#

content = <<-MD
@jch
`@jch`
MD
puts HTML::Pipeline::MentionFilter.new(nil, {
  base_url: "https://github.com"
}).mention_link_filter(content)

@simeonwillbanks
Copy link
Contributor

@parkr the MentionFilter has IGNORE_PARENTS which filters @mentions from code blocks.

The EmojiFilter has something similar, but it doesn't use a constant.

First, we should convert the Markdown to HTML. Second, we can use the #call interface and pipeline the HTML through the EmojiFilter and MentionFilter.

By sending messages to #emoji_image_filter and #mention_link_filter, we're circumventing the next logic (skip conversion within code block).

Emoji Example Implementation

content = <<-MD
:metal:
`:metal:`
MD
puts HTML::Pipeline.new([HTML::Pipeline::MarkdownFilter,HTML::Pipeline::EmojiFilter], {
  asset_root: "https://assets.github.com/images/icons/"
}).call(content)[:output].to_s

Emoji Example Output

:metal:
:metal:

Mentions Example Implementation

content = <<-MD
@jch
`@jch`
MD
puts HTML::Pipeline.new([HTML::Pipeline::MarkdownFilter,HTML::Pipeline::MentionFilter], {
  base_url: "https://github.com"
}).call(content)[:output].to_s

Mentions Example Output

@jch
@jch

Hope this helps! 😄

@Jastrzebowski
Copy link

@parkr any news about this?

@parkr
Copy link
Contributor Author

parkr commented Jan 16, 2015

The problem is that the Emoji filter runs before the markdown is rendered.

@simeonwillbanks
Copy link
Contributor

@parkr In Jekyll, can you send HTML fragments to the Emoji filter?

As mentioned by @jch, "this (Emoji) filter is designed to run on HTML fragments, so we should assume that tags is a reasonable input to work with."

@parkr
Copy link
Contributor Author

parkr commented Jan 21, 2015

@simeonwillbanks We'll have to convert it into a Converter, rather than a Generator.

@simeonwillbanks
Copy link
Contributor

OK, cool. I'll close this issue.

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

Successfully merging a pull request may close this issue.

4 participants