Skip to content

Commit

Permalink
Govspeak and CDT style quotes concurrently (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdavidhamilton authored Apr 2, 2024
1 parent 2e63765 commit 2f85a28
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/views/markup/_blockquote.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.application-notice.info-notice role='note' aria-label='Information'
== quote

p= citation
7 changes: 4 additions & 3 deletions app/views/markup/_quote.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.application-notice.info-notice role='note' aria-label='Information'
== quote
.blockquote-container
blockquote.quote
== quote

p= citation
cite= citation
24 changes: 22 additions & 2 deletions config/initializers/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CustomPreprocessor < GovukMarkdown::Preprocessor
# @return [CustomPreprocessor]
def apply_all
inject_inset_text.inject_details.two_thirds.button.external.quote.video
inject_inset_text.inject_details.two_thirds.button.external.quote.blockquote.video
end

# @example
Expand Down Expand Up @@ -69,7 +69,7 @@ def external
# This is the citation
# {/quote}
#
# @return [CustomPreprocessor]
# @return [CustomPreprocessor] CDT style
def quote
pattern = build_regexp('quote')
@output = output.gsub(pattern) do
Expand All @@ -79,6 +79,21 @@ def quote
self
end

# @example
# {blockquote}
# This is the quote and the citation
# {/blockquote}
#
# @return [CustomPreprocessor] Govspeak style
def blockquote
pattern = build_regexp('blockquote')
@output = output.gsub(pattern) do
quote, citation = split_content Regexp.last_match(1)
blockquote_template.render(nil, quote: nested_markdown(quote), citation: citation)
end
self
end

# @example
# {video}872080640{/video}
#
Expand Down Expand Up @@ -117,6 +132,11 @@ def quote_template
@quote_template ||= Slim::Template.new('app/views/markup/_quote.html.slim')
end

# @return [Slim::Template]
def blockquote_template
@blockquote_template ||= Slim::Template.new('app/views/markup/_blockquote.html.slim')
end

# @return [Slim::Template]
def video_template
@video_template ||= Slim::Template.new('app/views/markup/_video.html.slim')
Expand Down

0 comments on commit 2f85a28

Please sign in to comment.