Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: [ master, main ]
tags: [ v* ]
pull_request:
workflow_dispatch:

jobs:
rake:
Expand Down
4 changes: 2 additions & 2 deletions lib/relaton/bibcollection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def <<(item)

# @param source [Nokogiri::XML::Element]
def self.from_xml(source)
title = find_text("./relaton-collection/title", source)
author = find_text(
title = find_html("./relaton-collection/title", source)
author = find_html(
"./relaton-collection/contributor[role/@type='author']/organization/"\
"name", source
)
Expand Down
4 changes: 4 additions & 0 deletions lib/relaton/element_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def find_text(xpath, element = nil)
find(xpath, element)&.text
end

def find_html(xpath, element = nil)
find(xpath, element)&.inner_html
end

def find(xpath, element = nil)
(element || document).at(apply_namespace(xpath))
end
Expand Down
2 changes: 1 addition & 1 deletion relaton-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 3.0.0"

spec.add_runtime_dependency "liquid", "~> 5"
spec.add_runtime_dependency "relaton", "~> 1.20.2"
spec.add_runtime_dependency "relaton", "~> 1.20.3"
spec.add_runtime_dependency "thor"
spec.add_runtime_dependency "thor-hollaback"

Expand Down
23 changes: 23 additions & 0 deletions spec/assets/index-with-markup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<relaton-collection xmlns="http://riboseinc.com/isoxml">
<title>Use of <strong>ActualText</strong> &amp; <strong>Reference</strong> structure elements</title>
<contributor>
<role type="author"/>
<organization>
<name>Acme &amp; Co</name>
</organization>
</contributor>
<relation type='partOf'>
<bibdata type='standard'>
<title>Sample doc title</title>
<uri>http://example.org/sample.pdf</uri>
<docidentifier primary="true">EX 1</docidentifier>
<date type='published'>
<on>2026-01-01</on>
</date>
<status><stage>Published</stage></status>
<ext>
<technical-committee>TC EX</technical-committee>
</ext>
</bibdata>
</relation>
</relaton-collection>
23 changes: 23 additions & 0 deletions spec/relaton/cli/xml_to_html_renderer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@
end
end

context "with markup and entities in the collection title and author" do
let(:html) do
renderer.render(File.read("spec/assets/index-with-markup.xml"))
end

it "preserves <strong> markup and &amp; in the coverpage title" do
expect(html).to include(
'<span class="title-first">Use of <strong>ActualText</strong> ' \
"&amp; <strong>Reference</strong> structure elements</span>",
)
end

it "strips inline tags but keeps &amp; in <head><title>" do
head_title = html[/<title>([^<]*(?:<(?!\/title)[^<]*)*)<\/title>/m, 1]
expect(head_title).to include("&amp;")
expect(head_title).not_to include("<strong>")
end

it "preserves &amp; in the rendered author" do
expect(html).to include("Acme &amp; Co")
end
end

context "with a document containing other collections" do
let(:html) do
renderer.render(File.read("spec/assets/with-collections.xml"))
Expand Down
2 changes: 1 addition & 1 deletion templates/_index.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html>
<head>
<title>{{ title }}</title>
<title>{{ title | strip_html }}</title>
<style>
<!--
{{ css }}
Expand Down
Loading