mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections. Heredoc tag names we use: languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS other: MD, TEXT/TXT, RAW, EMAIL
This commit is contained in:
parent
7c4be7f649
commit
2fc70c5572
59 changed files with 392 additions and 392 deletions
|
@ -28,13 +28,13 @@ describe PrettyText do
|
|||
end
|
||||
|
||||
it 'can replace spoilers in emails' do
|
||||
md = PrettyText.cook(<<~EOF)
|
||||
md = PrettyText.cook(<<~MD)
|
||||
hello
|
||||
|
||||
[details="Summary"]
|
||||
world
|
||||
[/details]
|
||||
EOF
|
||||
MD
|
||||
md = PrettyText.format_for_email(md, post)
|
||||
html = "<p>hello</p>\n\nSummary <a href=\"#{post.full_url}\">(click for more details)</a>"
|
||||
|
||||
|
@ -42,7 +42,7 @@ describe PrettyText do
|
|||
end
|
||||
|
||||
it 'properly handles multiple spoiler blocks in a post' do
|
||||
md = PrettyText.cook(<<~EOF)
|
||||
md = PrettyText.cook(<<~MD)
|
||||
[details="First"]
|
||||
body secret stuff very long
|
||||
[/details]
|
||||
|
@ -55,7 +55,7 @@ describe PrettyText do
|
|||
[details="Third"]
|
||||
body secret stuff very long
|
||||
[/details]
|
||||
EOF
|
||||
MD
|
||||
|
||||
md = PrettyText.format_for_email(md, post)
|
||||
expect(md).not_to include('secret stuff')
|
||||
|
@ -65,12 +65,12 @@ describe PrettyText do
|
|||
end
|
||||
|
||||
it 'escapes summary text' do
|
||||
md = PrettyText.cook(<<~EOF)
|
||||
md = PrettyText.cook(<<~MD)
|
||||
<script>alert('hello')</script>
|
||||
[details="<script>alert('hello')</script>"]
|
||||
<script>alert('hello')</script>
|
||||
[/details]
|
||||
EOF
|
||||
MD
|
||||
md = PrettyText.format_for_email(md, post)
|
||||
|
||||
expect(md).not_to include('<script>')
|
||||
|
|
|
@ -8,9 +8,9 @@ RSpec.describe "Local Dates" do
|
|||
end
|
||||
|
||||
it "should work without timezone" do
|
||||
post = Fabricate(:post, raw: <<~TXT)
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
[date=2018-05-08 time=22:00 format="L LTS" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
TXT
|
||||
MD
|
||||
|
||||
cooked = post.cooked
|
||||
|
||||
|
@ -28,9 +28,9 @@ RSpec.describe "Local Dates" do
|
|||
end
|
||||
|
||||
it "should work with timezone" do
|
||||
post = Fabricate(:post, raw: <<~TXT)
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
[date=2018-05-08 time=22:00 format="L LTS" timezone="Asia/Calcutta" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
TXT
|
||||
MD
|
||||
|
||||
cooked = post.cooked
|
||||
|
||||
|
@ -39,9 +39,9 @@ RSpec.describe "Local Dates" do
|
|||
end
|
||||
|
||||
it 'requires the right attributes to convert to a local date' do
|
||||
post = Fabricate(:post, raw: <<~TXT)
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
[date]
|
||||
TXT
|
||||
MD
|
||||
|
||||
cooked = post.cooked
|
||||
|
||||
|
@ -50,9 +50,9 @@ RSpec.describe "Local Dates" do
|
|||
end
|
||||
|
||||
it 'requires the right attributes to convert to a local date' do
|
||||
post = Fabricate(:post, raw: <<~TXT)
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
[date]
|
||||
TXT
|
||||
MD
|
||||
|
||||
cooked = post.cooked
|
||||
|
||||
|
|
|
@ -163,11 +163,11 @@ module DiscourseNarrativeBot
|
|||
def start_advanced_track
|
||||
raw = I18n.t("#{I18N_KEY}.start_message", i18n_post_args(username: @user.username))
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{raw}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
opts = {
|
||||
title: I18n.t("#{I18N_KEY}.title"),
|
||||
|
@ -197,11 +197,11 @@ module DiscourseNarrativeBot
|
|||
|
||||
fake_delay
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.edit.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
reply_to(@post, raw)
|
||||
end
|
||||
|
@ -227,11 +227,11 @@ module DiscourseNarrativeBot
|
|||
|
||||
fake_delay
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.delete.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
PostCreator.create!(self.discobot_user,
|
||||
raw: raw,
|
||||
|
@ -252,11 +252,11 @@ module DiscourseNarrativeBot
|
|||
|
||||
fake_delay
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.recover.reply", i18n_post_args(deletion_after: SiteSetting.delete_removed_posts_after))}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
PostCreator.create!(self.discobot_user,
|
||||
raw: raw,
|
||||
|
@ -279,11 +279,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(topic_id)
|
||||
|
||||
if Nokogiri::HTML5.fragment(@post.cooked).css('.hashtag').size > 0
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.category_hashtag.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
reply_to(@post, raw)
|
||||
|
@ -308,11 +308,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(@topic_id)
|
||||
|
||||
fake_delay
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.change_topic_notification_level.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -330,11 +330,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(topic_id)
|
||||
|
||||
if Nokogiri::HTML5.fragment(@post.cooked).css(".poll").size > 0
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.poll.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
reply_to(@post, raw)
|
||||
|
|
|
@ -175,11 +175,11 @@ module DiscourseNarrativeBot
|
|||
|
||||
MessageBus.publish('/new_user_narrative/tutorial_search', {}, user_ids: [@user.id])
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{post.raw}
|
||||
|
||||
#{I18n.t("#{I18N_KEY}.search.hidden_message", i18n_post_args.merge(search_answer: NewUserNarrative.search_answer))}
|
||||
RAW
|
||||
MD
|
||||
|
||||
PostRevisor.new(post, topic).revise!(
|
||||
self.discobot_user,
|
||||
|
@ -206,11 +206,11 @@ module DiscourseNarrativeBot
|
|||
)
|
||||
)
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{raw}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
title = I18n.t("#{I18N_KEY}.hello.title", title: SiteSetting.title)
|
||||
if SiteSetting.max_emojis_in_title == 0
|
||||
|
@ -259,11 +259,11 @@ module DiscourseNarrativeBot
|
|||
|
||||
profile_page_url = url_helpers(:user_url, username: @user.username)
|
||||
bookmark_url = "#{profile_page_url}/activity/bookmarks"
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.bookmark.reply", i18n_post_args(bookmark_url: bookmark_url))}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -279,11 +279,11 @@ module DiscourseNarrativeBot
|
|||
@post.post_analyzer.cook(@post.raw, {})
|
||||
|
||||
if @post.post_analyzer.found_oneboxes?
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.onebox.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -315,11 +315,11 @@ module DiscourseNarrativeBot
|
|||
fake_delay
|
||||
like_post(post)
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.images.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
reply = reply_to(@post, raw)
|
||||
enqueue_timeout_job(@user)
|
||||
|
@ -350,11 +350,11 @@ module DiscourseNarrativeBot
|
|||
set_state_data(:post_id, @post.id)
|
||||
|
||||
if get_state_data(:liked)
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.images.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
like_post(@post)
|
||||
else
|
||||
|
@ -405,11 +405,11 @@ module DiscourseNarrativeBot
|
|||
)
|
||||
|
||||
if post_liked
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.likes.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -426,11 +426,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(post_topic_id)
|
||||
|
||||
if Nokogiri::HTML5.fragment(@post.cooked).css("b", "strong", "em", "i", ".bbcode-i", ".bbcode-b").size > 0
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.formatting.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -452,11 +452,11 @@ module DiscourseNarrativeBot
|
|||
doc = Nokogiri::HTML5.fragment(@post.cooked)
|
||||
|
||||
if doc.css(".quote").size > 0
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.quoting.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -478,11 +478,11 @@ module DiscourseNarrativeBot
|
|||
doc = Nokogiri::HTML5.fragment(@post.cooked)
|
||||
|
||||
if doc.css(".emoji").size > 0
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.emoji.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -502,11 +502,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(post_topic_id)
|
||||
|
||||
if bot_mentioned?(@post)
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.mention.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
@ -552,11 +552,11 @@ module DiscourseNarrativeBot
|
|||
return unless valid_topic?(post_topic_id)
|
||||
return unless @post.user.id == -2
|
||||
|
||||
raw = <<~RAW
|
||||
raw = <<~MD
|
||||
#{I18n.t("#{I18N_KEY}.flag.reply", i18n_post_args)}
|
||||
|
||||
#{instance_eval(&@next_instructions)}
|
||||
RAW
|
||||
MD
|
||||
|
||||
fake_delay
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class Onebox::Engine::YoutubeOnebox
|
|||
# Put in the LazyYT div instead of the iframe
|
||||
escaped_title = ERB::Util.html_escape(video_title)
|
||||
|
||||
<<~EOF
|
||||
<<~HTML
|
||||
<div class="onebox lazyYT lazyYT-container"
|
||||
data-youtube-id="#{video_id}"
|
||||
data-youtube-title="#{escaped_title}"
|
||||
|
@ -49,7 +49,7 @@ class Onebox::Engine::YoutubeOnebox
|
|||
title="#{escaped_title}">
|
||||
</a>
|
||||
</div>
|
||||
EOF
|
||||
HTML
|
||||
else
|
||||
yt_onebox_to_html
|
||||
end
|
||||
|
|
|
@ -39,12 +39,12 @@ describe NewPostManager do
|
|||
end
|
||||
|
||||
it 're-validates the poll when the approve_post event is triggered' do
|
||||
invalid_raw_poll = <<~RAW
|
||||
invalid_raw_poll = <<~MD
|
||||
[poll type=multiple min=0]
|
||||
* 1
|
||||
* 2
|
||||
[/poll]
|
||||
RAW
|
||||
MD
|
||||
|
||||
result = NewPostManager.new(user, params).perform
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue