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
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
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>
62 changes: 32 additions & 30 deletions spec/fixtures/ietf_index.rxl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<relaton-collection xmlns="https://open.ribose.com/relaton-xml"><title>Collection title</title><contributor><role type='author'/><organization><name>Ribose</name></organization></contributor><relation type='partOf'><bibdata type="standard" schema-version="v1.5.6">
<title language="en" type="main" format="text/plain">The Holy Hand Grenade of Antioch</title>
<title language="en" type="abbrev" format="text/plain">Hand Grenade of Antioch</title>
<title language="en" format="text/plain" type="main">The Holy Hand Grenade of Antioch</title>
<title language="en" format="text/plain" type="abbrev">Hand Grenade of Antioch</title>
<uri type="xml">spec/fixtures/documents/antioch.xml</uri>
<uri type="rxl">spec/fixtures/documents/antioch.rxl</uri>
<docidentifier primary="true">draft-camelot-holy-grenade-01</docidentifier>
Expand All @@ -23,7 +23,6 @@
</organization>
</contributor>
<version>

</version>
<language>en</language>
<script>Latn</script>
Expand All @@ -41,10 +40,10 @@
</copyright>
<relation type="updates">
<bibitem type="standard">
<title language="en" script="Latn" format="text/plain">The Arte of ASCII: Or, An True and Accurate Representation of an Menagerie of Thynges Fabulous and Wonderful in Ye Forme of Character</title>
<title format="text/plain" language="en" script="Latn">The Arte of ASCII: Or, An True and Accurate Representation of an Menagerie of Thynges Fabulous and Wonderful in Ye Forme of Character</title>
<uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8140.xml</uri>
<uri type="src">https://www.rfc-editor.org/info/rfc8140</uri>
<docidentifier type="IETF" primary="true">RFC 8140</docidentifier>
<docidentifier primary="true" type="IETF">RFC 8140</docidentifier>
<docidentifier type="DOI">10.17487/RFC8140</docidentifier>
<date type="published">
<on>2017-04</on>
Expand Down Expand Up @@ -72,9 +71,9 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn" format="text/plain">Ever since Gutenberg discovered and patented ASCII and the corresponding "Courier New" font with its now-famous "ten" point size, artisans and artificers have striven to represent their views of the world in print.Similarly, starting from Darwin's discovery of the hippogriff and his subsequent registration of the creature as an International Trade Mark, men (and some women) have struggled to catalog the fabulous variety that is called "nature".This document supplies a number of representations of all manner of things (both elemental and hypothetical) supplied by some of our best collectors of curios and delivered in a manner that may well be reused by the cunning document author.</abstract>
<abstract format="text/plain" language="en" script="Latn">Ever since Gutenberg discovered and patented ASCII and the corresponding "Courier New" font with its now-famous "ten" point size, artisans and artificers have striven to represent their views of the world in print.Similarly, starting from Darwin's discovery of the hippogriff and his subsequent registration of the creature as an International Trade Mark, men (and some women) have struggled to catalog the fabulous variety that is called "nature".This document supplies a number of representations of all manner of things (both elemental and hypothetical) supplied by some of our best collectors of curios and delivered in a manner that may well be reused by the cunning document author.</abstract>
<series type="main">
<title language="en" script="Latn" format="text/plain">RFC</title>
<title format="text/plain" language="en" script="Latn">RFC</title>
<number>8140</number>
</series>
<place/>
Expand All @@ -91,8 +90,8 @@
</ext>
</bibdata></relation>
<relation type='partOf'><bibdata type="standard" schema-version="v1.5.6">
<title language="en" type="main" format="text/plain">RFC XML v3 Example: A Standard for the Transmission of IP Datagrams on Avian Carriers</title>
<title language="en" type="abbrev" format="text/plain">IP Datagrams on Avian Carriers</title>
<title language="en" format="text/plain" type="main">RFC XML v3 Example: A Standard for the Transmission of IP Datagrams on Avian Carriers</title>
<title language="en" format="text/plain" type="abbrev">IP Datagrams on Avian Carriers</title>
<uri type="xml">spec/fixtures/documents/example.xml</uri>
<uri type="html">spec/fixtures/documents/example.html</uri>
<uri type="rxl">spec/fixtures/documents/example.rxl</uri>
Expand Down Expand Up @@ -131,7 +130,6 @@
</organization>
</contributor>
<version>

</version>
<language>en</language>
<script>Latn</script>
Expand All @@ -155,10 +153,10 @@
</relation>
<relation type="obsoletes">
<bibitem type="standard">
<title language="en" script="Latn" format="text/plain">Request For Comments reference guide</title>
<title format="text/plain" language="en" script="Latn">Request For Comments reference guide</title>
<uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1000.xml</uri>
<uri type="src">https://www.rfc-editor.org/info/rfc1000</uri>
<docidentifier type="IETF" primary="true">RFC 1000</docidentifier>
<docidentifier primary="true" type="IETF">RFC 1000</docidentifier>
<docidentifier type="DOI">10.17487/RFC1000</docidentifier>
<date type="published">
<on>1987-08</on>
Expand Down Expand Up @@ -200,20 +198,20 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn" format="text/plain">This RFC Reference Guide is intended to provide a historical account by categorizing and summarizing of the Request for Comments numbers 1 through 999 issued between the years 1969-1987. These documents have been crossed referenced to indicate which RFCs are current, obsolete, or revised.</abstract>
<abstract format="text/plain" language="en" script="Latn">This RFC Reference Guide is intended to provide a historical account by categorizing and summarizing of the Request for Comments numbers 1 through 999 issued between the years 1969-1987. These documents have been crossed referenced to indicate which RFCs are current, obsolete, or revised.</abstract>
<series type="main">
<title language="en" script="Latn" format="text/plain">RFC</title>
<title format="text/plain" language="en" script="Latn">RFC</title>
<number>1000</number>
</series>
<place/>
</bibitem>
</relation>
<relation type="obsoletes">
<bibitem type="standard">
<title language="en" script="Latn" format="text/plain">IAB official protocol standards</title>
<title format="text/plain" language="en" script="Latn">IAB official protocol standards</title>
<uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1200.xml</uri>
<uri type="src">https://www.rfc-editor.org/info/rfc1200</uri>
<docidentifier type="IETF" primary="true">RFC 1200</docidentifier>
<docidentifier primary="true" type="IETF">RFC 1200</docidentifier>
<docidentifier type="DOI">10.17487/RFC1200</docidentifier>
<date type="published">
<on>1991-04</on>
Expand All @@ -239,20 +237,20 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn" format="text/plain">This memo describes the state of standardization of protocols used in the Internet as determined by the Internet Activities Board (IAB). An overview of the standards procedures is presented first, followed by discussions of the standardization process and the RFC document series, then the explanation of the terms is presented, the lists of protocols in each stage of standardization follows, and finally pointers to references and contacts for further information.</abstract>
<abstract format="text/plain" language="en" script="Latn">This memo describes the state of standardization of protocols used in the Internet as determined by the Internet Activities Board (IAB). An overview of the standards procedures is presented first, followed by discussions of the standardization process and the RFC document series, then the explanation of the terms is presented, the lists of protocols in each stage of standardization follows, and finally pointers to references and contacts for further information.</abstract>
<series type="main">
<title language="en" script="Latn" format="text/plain">RFC</title>
<title format="text/plain" language="en" script="Latn">RFC</title>
<number>1200</number>
</series>
<place/>
</bibitem>
</relation>
<relation type="updates">
<bibitem type="standard">
<title language="en" script="Latn" format="text/plain">Operational Criteria for Root Name Servers</title>
<title format="text/plain" language="en" script="Latn">Operational Criteria for Root Name Servers</title>
<uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2010.xml</uri>
<uri type="src">https://www.rfc-editor.org/info/rfc2010</uri>
<docidentifier type="IETF" primary="true">RFC 2010</docidentifier>
<docidentifier primary="true" type="IETF">RFC 2010</docidentifier>
<docidentifier type="DOI">10.17487/RFC2010</docidentifier>
<date type="published">
<on>1996-10</on>
Expand Down Expand Up @@ -294,20 +292,20 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn" format="text/plain">This document specifies the operational requirements of root name servers, including host hardware capacities, name server software revisions, network connectivity, and physical environment. This memo provides information for the Internet community. This memo does not specify an Internet standard of any kind.</abstract>
<abstract format="text/plain" language="en" script="Latn">This document specifies the operational requirements of root name servers, including host hardware capacities, name server software revisions, network connectivity, and physical environment. This memo provides information for the Internet community. This memo does not specify an Internet standard of any kind.</abstract>
<series type="main">
<title language="en" script="Latn" format="text/plain">RFC</title>
<title format="text/plain" language="en" script="Latn">RFC</title>
<number>2010</number>
</series>
<place/>
</bibitem>
</relation>
<relation type="updates">
<bibitem type="standard">
<title language="en" script="Latn" format="text/plain">Managing the X.500 Root Naming Context</title>
<title format="text/plain" language="en" script="Latn">Managing the X.500 Root Naming Context</title>
<uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2120.xml</uri>
<uri type="src">https://www.rfc-editor.org/info/rfc2120</uri>
<docidentifier type="IETF" primary="true">RFC 2120</docidentifier>
<docidentifier primary="true" type="IETF">RFC 2120</docidentifier>
<docidentifier type="DOI">10.17487/RFC2120</docidentifier>
<date type="published">
<on>1997-03</on>
Expand Down Expand Up @@ -335,9 +333,9 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn" format="text/plain">This document describes the use of 1993 ISO X.500 Standard protocols for managing the root context. Whilst the ASN.1 is compatible with that of the X.500 Standard, the actual settings of the parameters are supplementary to that of the X.500 Standard. This memo defines an Experimental Protocol for the Internet community.</abstract>
<abstract format="text/plain" language="en" script="Latn">This document describes the use of 1993 ISO X.500 Standard protocols for managing the root context. Whilst the ASN.1 is compatible with that of the X.500 Standard, the actual settings of the parameters are supplementary to that of the X.500 Standard. This memo defines an Experimental Protocol for the Internet community.</abstract>
<series type="main">
<title language="en" script="Latn" format="text/plain">RFC</title>
<title format="text/plain" language="en" script="Latn">RFC</title>
<number>2120</number>
</series>
<place/>
Expand Down Expand Up @@ -380,13 +378,15 @@
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn">The menagerie of beasts and artefacts depicted in RFC8140
<abstract language="en" script="Latn">
<p>The menagerie of beasts and artefacts depicted in RFC8140
may be usefully supplemented by other renowned figures of
Internet and more general lore. This document extends the
menagerie to the seminal fable of the
"Holy Hand Grenade of Antioch", as depicted in the
Monty Python film "Monty Python and the Holy Grail",
as well as "Spamalot", the musical inspired by the movie.</abstract>
as well as "Spamalot", the musical inspired by the movie.</p>
</abstract>
<status>
<stage>Informational</stage>
</status>
Expand Down Expand Up @@ -417,7 +417,8 @@ as well as "Spamalot", the musical inspired by the movie.</abstract>
</contributor>
<language>en</language>
<script>Latn</script>
<abstract language="en" script="Latn">Avian carriers can provide high delay, low throughput, and low
<abstract language="en" script="Latn">
<p>Avian carriers can provide high delay, low throughput, and low
altitude service. The connection topology is limited to a single
point-to-point path for each carrier, used with standard carriers,
but many carriers can be used without significant interference with
Expand All @@ -427,7 +428,8 @@ IEEE802.3. The carriers have an intrinsic collision avoidance
system, which increases availability. Unlike some network
technologies, such as packet radio, communication is not limited to
line-of-sight distance. Connection oriented service is available in
some cities, usually based upon a central hub topology.</abstract>
some cities, usually based upon a central hub topology.</p>
</abstract>
<status>
<stage>Published</stage>
</status>
Expand Down
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
52 changes: 26 additions & 26 deletions spec/vcr_cassettes/iso_2146.yml

Large diffs are not rendered by default.

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