govspeak 6.1.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b48fa791c90052e6ee6f2c235d3baba095c5de501f32b7e2748f05396a799899
|
4
|
+
data.tar.gz: c5e325373b8c6d20e2d59db3b38b5345ccce22a83edba93a9ec41ba03156e1cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ddd06fa6841ce2efcbfbf660ae09eeff3114b6f4e5de067ed7b09457f6be14e29caa5803b281e24dad159e7c2a49594ef9e98a7d68f54e01930a4a31932ce32
|
7
|
+
data.tar.gz: e4811322275d4f221e198bf8112040340e922d3713ab82bac32395ad386243259e4f4fca1973cb050af9df12e4c1b10b8c17a62febb7f06c2ddbbbacc857d16d
|
data/CHANGELOG.md
CHANGED
data/lib/govspeak.rb
CHANGED
@@ -3,7 +3,7 @@ require 'active_support/core_ext/array'
|
|
3
3
|
require 'erb'
|
4
4
|
require 'htmlentities'
|
5
5
|
require 'kramdown'
|
6
|
-
require 'kramdown/parser/
|
6
|
+
require 'kramdown/parser/govuk'
|
7
7
|
require 'rinku'
|
8
8
|
require 'govuk_publishing_components'
|
9
9
|
require 'govspeak/header_extractor'
|
@@ -21,14 +21,13 @@ require 'govspeak/presenters/h_card_presenter'
|
|
21
21
|
require 'govspeak/presenters/image_presenter'
|
22
22
|
require 'govspeak/presenters/attachment_image_presenter'
|
23
23
|
|
24
|
-
|
25
24
|
module Govspeak
|
26
25
|
def self.root
|
27
26
|
File.expand_path('..', File.dirname(__FILE__))
|
28
27
|
end
|
29
28
|
|
30
29
|
class Document
|
31
|
-
Parser = Kramdown::Parser::
|
30
|
+
Parser = Kramdown::Parser::Govuk
|
32
31
|
PARSER_CLASS_NAME = Parser.name.split("::").last
|
33
32
|
UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.freeze
|
34
33
|
NEW_PARAGRAPH_LOOKBEHIND = %q{(?<=\A|\n\n|\r\n\r\n)}.freeze
|
@@ -354,6 +353,8 @@ module Govspeak
|
|
354
353
|
# Content Publisher and should be considered experimental as it is likely
|
355
354
|
# to be iterated in the short term.
|
356
355
|
extension('Attachment', /#{NEW_PARAGRAPH_LOOKBEHIND}\[Attachment:\s*(.*?)\s*\]/) do |attachment_id|
|
356
|
+
next "" if attachments.none? { |a| a[:id] == attachment_id }
|
357
|
+
|
357
358
|
%{<govspeak-embed-attachment id="#{attachment_id}"></govspeak-embed-attachment>}
|
358
359
|
end
|
359
360
|
|
@@ -361,6 +362,8 @@ module Govspeak
|
|
361
362
|
# syntax is being used by Content Publisher and should be considered
|
362
363
|
# experimental
|
363
364
|
extension('AttachmentLink', /\[AttachmentLink:\s*(.*?)\s*\]/) do |attachment_id|
|
365
|
+
next "" if attachments.none? { |a| a[:id] == attachment_id }
|
366
|
+
|
364
367
|
%{<govspeak-embed-attachment-link id="#{attachment_id}"></govspeak-embed-attachment-link>}
|
365
368
|
end
|
366
369
|
|
data/lib/govspeak/version.rb
CHANGED
@@ -20,7 +20,9 @@ module Kramdown
|
|
20
20
|
end
|
21
21
|
|
22
22
|
module Parser
|
23
|
-
class
|
23
|
+
class Govuk < Kramdown::Parser::Kramdown
|
24
|
+
CUSTOM_INLINE_ELEMENTS = %w(govspeak-embed-attachment-link).freeze
|
25
|
+
|
24
26
|
def initialize(source, options)
|
25
27
|
@document_domains = options[:document_domains] || %w(www.gov.uk)
|
26
28
|
super
|
@@ -41,6 +43,12 @@ module Kramdown
|
|
41
43
|
end
|
42
44
|
super
|
43
45
|
end
|
46
|
+
|
47
|
+
def parse_block_html
|
48
|
+
return false if CUSTOM_INLINE_ELEMENTS.include?(@src[1].downcase)
|
49
|
+
|
50
|
+
super
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
@@ -22,4 +22,19 @@ class GovspeakAttachmentLinkTest < Minitest::Test
|
|
22
22
|
assert_match(/<span class="gem-c-attachment-link">/, rendered)
|
23
23
|
assert_match(%r{href="http://example.com/attachment.pdf"}, rendered)
|
24
24
|
end
|
25
|
+
|
26
|
+
test "renders an attachment link inside a paragraph" do
|
27
|
+
attachment = {
|
28
|
+
id: "attachment.pdf",
|
29
|
+
url: "http://example.com/attachment.pdf",
|
30
|
+
title: "Attachment Title",
|
31
|
+
}
|
32
|
+
|
33
|
+
rendered = render_govspeak("[AttachmentLink:attachment.pdf] test", [attachment])
|
34
|
+
root = Nokogiri::HTML.fragment(rendered).css(":root").first
|
35
|
+
|
36
|
+
assert(root.name, "p")
|
37
|
+
assert(root.css("p").size, 0)
|
38
|
+
assert_match(/Attachment Title\s*test/, root.text)
|
39
|
+
end
|
25
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govspeak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -260,7 +260,7 @@ files:
|
|
260
260
|
- lib/govspeak/structured_header_extractor.rb
|
261
261
|
- lib/govspeak/template_renderer.rb
|
262
262
|
- lib/govspeak/version.rb
|
263
|
-
- lib/kramdown/parser/
|
263
|
+
- lib/kramdown/parser/govuk.rb
|
264
264
|
- lib/templates/contact.html.erb
|
265
265
|
- locales/ar.yml
|
266
266
|
- locales/be.yml
|
@@ -344,22 +344,22 @@ signing_key:
|
|
344
344
|
specification_version: 4
|
345
345
|
summary: Markup language for single domain
|
346
346
|
test_files:
|
347
|
+
- test/govspeak_attachments_inline_test.rb
|
348
|
+
- test/govspeak_attachment_test.rb
|
347
349
|
- test/govspeak_attachment_link_test.rb
|
350
|
+
- test/govspeak_images_test.rb
|
351
|
+
- test/govspeak_link_test.rb
|
352
|
+
- test/govspeak_images_bang_test.rb
|
353
|
+
- test/govspeak_link_extractor_test.rb
|
354
|
+
- test/govspeak_contacts_test.rb
|
348
355
|
- test/test_helper.rb
|
349
|
-
- test/govspeak_button_test.rb
|
350
356
|
- test/govspeak_test.rb
|
351
|
-
- test/html_validator_test.rb
|
352
|
-
- test/govspeak_attachment_test.rb
|
353
|
-
- test/govspeak_contacts_test.rb
|
354
|
-
- test/govspeak_test_helper.rb
|
355
|
-
- test/blockquote_extra_quote_remover_test.rb
|
356
357
|
- test/govspeak_attachments_image_test.rb
|
357
|
-
- test/
|
358
|
-
- test/govspeak_link_test.rb
|
359
|
-
- test/govspeak_extract_contact_content_ids_test.rb
|
358
|
+
- test/html_validator_test.rb
|
360
359
|
- test/govspeak_structured_headers_test.rb
|
361
|
-
- test/
|
360
|
+
- test/govspeak_extract_contact_content_ids_test.rb
|
361
|
+
- test/blockquote_extra_quote_remover_test.rb
|
362
362
|
- test/presenters/h_card_presenter_test.rb
|
363
|
-
- test/
|
364
|
-
- test/
|
365
|
-
- test/
|
363
|
+
- test/govspeak_button_test.rb
|
364
|
+
- test/govspeak_test_helper.rb
|
365
|
+
- test/html_sanitizer_test.rb
|