diff --git a/Gemfile b/Gemfile
index b65567c22..478f81d27 100644
--- a/Gemfile
+++ b/Gemfile
@@ -38,6 +38,7 @@ gem "delayed_job_active_record", "~> 4.1"
gem "devise", "~> 4.5"
gem "draper", "~> 3.0"
gem "email_validator", "~> 1.6"
+gem "emoji_regex", "~> 1.0"
gem "envied", "~> 0.9"
gem "fastly", "~> 1.15"
gem "fastly-rails", "~> 0.8"
diff --git a/Gemfile.lock b/Gemfile.lock
index 997af028c..e4d1b4ed8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -261,6 +261,7 @@ GEM
http_parser.rb (~> 0.6.0)
email_validator (1.6.0)
activemodel
+ emoji_regex (1.0.1)
envied (0.9.1)
coercible (~> 1.0)
thor (~> 0.15)
@@ -936,6 +937,7 @@ DEPENDENCIES
devise (~> 4.5)
draper (~> 3.0)
email_validator (~> 1.6)
+ emoji_regex (~> 1.0)
envied (~> 0.9)
factory_bot_rails (~> 4.11)
fake_stripe (~> 0.2)
diff --git a/app/assets/stylesheets/article-show.scss b/app/assets/stylesheets/article-show.scss
index 8076da5f8..5e551356c 100644
--- a/app/assets/stylesheets/article-show.scss
+++ b/app/assets/stylesheets/article-show.scss
@@ -312,6 +312,12 @@ header{
code{
color:$sky-blue;
}
+ &.anchor{
+ padding-top: 50px;
+ margin-top: -50px;
+ -webkit-background-clip: content-box;
+ background-clip: content-box;
+ }
}
h1,h2,h3,h4,h5,h6{
font-family: $helvetica;
diff --git a/app/assets/stylesheets/comments.scss b/app/assets/stylesheets/comments.scss
index 6fbec919d..5b1a6f1e5 100644
--- a/app/assets/stylesheets/comments.scss
+++ b/app/assets/stylesheets/comments.scss
@@ -561,6 +561,14 @@ a.header-link{
margin-left:0%;
overflow-x:auto;
}
+ a{
+ &.anchor{
+ padding-top: 50px;
+ margin-top: -50px;
+ -webkit-background-clip: content-box;
+ background-clip: content-box;
+ }
+ }
}
.icon-img{
height:16px;
diff --git a/app/lib/redcarpet/render/html_rouge.rb b/app/lib/redcarpet/render/html_rouge.rb
index a5706f7c9..d2b51b862 100644
--- a/app/lib/redcarpet/render/html_rouge.rb
+++ b/app/lib/redcarpet/render/html_rouge.rb
@@ -15,6 +15,23 @@ module Redcarpet
end
%(#{content})
end
+
+ def header(title, header_number)
+ anchor_link = remove_emoji_and_hyphenate(title)
+ <<~HEREDOC
+
+
+
+ #{title}
+
+ HEREDOC
+ end
+
+ private
+
+ def remove_emoji_and_hyphenate(string)
+ string.downcase.gsub(EmojiRegex::Regex, "").strip.gsub(/\s/, "-")
+ end
end
end
end
diff --git a/spec/features/user_uses_the_editor_spec.rb b/spec/features/user_uses_the_editor_spec.rb
index e805e2649..28428b168 100644
--- a/spec/features/user_uses_the_editor_spec.rb
+++ b/spec/features/user_uses_the_editor_spec.rb
@@ -27,7 +27,7 @@ describe "Using the editor" do
page.evaluate_script("window.onbeforeunload = function(){}")
end
- it "fill out form with ruch content and click preview" do
+ it "fill out form with rich content and click preview" do
fill_markdown_with(read_from_file(raw_text))
page.execute_script("window.scrollTo(0, -100000)")
find("button#previewbutt").click
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index c84fa8369..de32c145f 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -210,82 +210,5 @@ RSpec.describe Comment, type: :model do
end
end
- # describe "::StreamRails::Activity(notification callbacks)" do
- # before do
- # StreamRails.enabled = true
- # allow(StreamNotifier).to receive(:new).and_call_original
- # end
-
- # after { StreamRails.enabled = false }
-
- # context "when a comment without ancestor is created" do
- # let(:test_comment) { build(:comment, commentable_id: article.id) }
-
- # before { allow(test_comment).to receive(:send_email_notification).and_call_original }
-
- # it "notifies the author" do
- # test_comment.save!
- # expect(StreamNotifier).to have_received(:new).at_least(:once)
- # end
-
- # it "does not notify author if self is author" do
- # test_comment.user = user
- # test_comment.save
- # expect(StreamNotifier).not_to have_received(:new).with(user.id)
- # expect(test_comment).not_to have_received :send_email_notification
- # end
-
- # it "does not notify anybody else" do
- # test_comment.save
- # expect(StreamNotifier).not_to have_received(:new).with(test_comment.user_id)
- # end
- # end
-
- # context "when a comment with ancestor is created" do
- # let(:nest_comment_1) { create(:comment, commentable_id: article.id) }
- # let(:nest_comment_2) do
- # create(:comment, parent_id: nest_comment_1.id, commentable_id: article.id)
- # end
- # let(:author_comment) do
- # create(:comment, parent_id: nest_comment_2.id,
- # commentable_id: article.id, user_id: user.id)
- # end
- # let(:nest_comments_authors) { [nest_comment_1.user_id, nest_comment_2.user_id] }
-
- # before do
- # StreamRails.enabled = false
- # nest_comments_authors # this needs to be evoked before StreamRails is enabled
- # StreamRails.enabled = true
- # end
-
- # it "notifies all the ancestors" do
- # create(:comment, parent_id: nest_comment_2.id, commentable_id: article.id)
- # nest_comments_authors.each do |id|
- # expect(StreamNotifier).to have_received(:new).with(id).at_least(:once)
- # end
- # end
-
- # it "does not notifies the author" do
- # create(:comment, parent_id: nest_comment_2.id, commentable_id: article.id)
- # expect(StreamNotifier).not_to have_received(:new).with(user.id)
- # end
-
- # it "notifies all ancestors even if the author is among them" do
- # create(:comment, parent_id: author_comment.id, commentable_id: article.id)
- # nest_comments_authors.push(user.id).each do |id|
- # expect(StreamNotifier).to have_received(:new).with(id).at_least(:once)
- # end
- # end
-
- # it "does not notify self if self is among the ancestors" do
- # me = create(:user)
- # test_comment = create(:comment, parent_id: author_comment.id, commentable_id: article.id, user_id: me.id)
- # create(:comment, parent_id: author_comment.id, commentable_id: article.id, user_id: me.id)
- # allow(test_comment).to receive(:send_email_notification).and_call_original
- # expect(StreamNotifier).not_to have_received(:new).with(me.id)
- # expect(test_comment).not_to have_received(:send_email_notification)
- # end
- # end
- # end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
diff --git a/spec/support/fixtures/approvals/user_preview_article_body.approved.html b/spec/support/fixtures/approvals/user_preview_article_body.approved.html
index 2df64a402..1471de467 100644
--- a/spec/support/fixtures/approvals/user_preview_article_body.approved.html
+++ b/spec/support/fixtures/approvals/user_preview_article_body.approved.html
@@ -1,16 +1,52 @@
-
h1
+
+
+
+ h1
+
-h2
+
+
+
+ h2
+
-h3
+
+
+
+ h3
+
-h4
+
+
+
+ h4
+
-h5
+
+
+
+ h5
+
-h6
+
+
+
+ h6
+
+
+
+
+
+ multiword heading
+
+
+
+
+
+ 😎 emoji heading
+
italic italic
bold bold
You can combine them
asterisks and underscores
diff --git a/spec/support/fixtures/sample_article_template_spec.txt b/spec/support/fixtures/sample_article_template_spec.txt
index b6758ab88..6b5245370 100644
--- a/spec/support/fixtures/sample_article_template_spec.txt
+++ b/spec/support/fixtures/sample_article_template_spec.txt
@@ -1,8 +1,8 @@
---
title: This is a test
published: false
-description:
-tags:
+description:
+tags:
---
# h1
@@ -11,6 +11,8 @@ tags:
#### h4
##### h5
###### h6
+# multiword heading
+# 😎 emoji heading
*italic* _italic_
**bold** __bold__