summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/asciidoctor.rb5
-rw-r--r--lib/asciidoctor/backends/_stylesheets.rb3
-rw-r--r--lib/asciidoctor/backends/html5.rb15
-rw-r--r--lib/asciidoctor/document.rb12
4 files changed, 22 insertions, 13 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 63169603..2f3408a4 100755
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -875,8 +875,9 @@ module Asciidoctor
end
# NOTE document cannot control this behavior if safe >= SafeMode::SERVER
- if !stream_output && doc.attr?('basebackend-html') && doc.attr?('copycss') &&
- doc.attr?('linkcss') && DEFAULT_STYLESHEET_KEYS.include?(doc.attr('stylesheet'))
+ if !stream_output && doc.safe < SafeMode::SECURE && doc.attr?('basebackend-html') &&
+ doc.attr?('copycss') && doc.attr?('linkcss') &&
+ DEFAULT_STYLESHEET_KEYS.include?(doc.attr('stylesheet'))
Helpers.require_library 'fileutils'
outdir = doc.attr('outdir')
stylesdir = doc.normalize_system_path(doc.attr('stylesdir'), outdir,
diff --git a/lib/asciidoctor/backends/_stylesheets.rb b/lib/asciidoctor/backends/_stylesheets.rb
index 4750eb80..92e0229b 100644
--- a/lib/asciidoctor/backends/_stylesheets.rb
+++ b/lib/asciidoctor/backends/_stylesheets.rb
@@ -212,7 +212,8 @@ table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { font-si
pre { color: inherit; font-family: Consolas, "Liberation Mono", Courier, monospace; overflow-x: auto; line-height: 1.6; }
.verseblock { margin-bottom: 1.25em; }
.literalblock, .listingblock { margin-bottom: 1.25em; }
-.literalblock > .content > pre, .listingblock > .content > pre { background: none; color: inherit; font-family: Consolas, "Liberation Mono", Courier, monospace; border-width: 1px 0; border-style: dotted; border-color: #bfbfbf; -webkit-border-radius: 4px; border-radius: 4px; padding: 0.75em 0.75em 0.5em 0.75em; white-space: pre; overflow-x: auto; line-height: 1.6; }
+.literalblock > .content > pre, .listingblock > .content > pre { background: none; color: inherit; font-family: Consolas, "Liberation Mono", Courier, monospace; border-width: 1px 0; border-style: dotted; border-color: #bfbfbf; -webkit-border-radius: 4px; border-radius: 4px; padding: 0.75em 0.75em 0.5em 0.75em; word-wrap: break-word; line-height: 1.6; }
+.literalblock > .content > pre.nowrap, .listingblock > .content > pre.nowrap { overflow-x: auto; white-space: pre; }
.literalblock > .content > pre > code, .literalblock > .content > pre > tt, .listingblock > .content > pre > code, .listingblock > .content > pre > tt { color: inherit; font-family: Consolas, "Liberation Mono", Courier, monospace; padding: 0; background: none; font-weight: normal; }
@media only screen { .literalblock > .content > pre, .listingblock > .content > pre { font-size: 0.8em; } }
@media only screen and (min-width: 48em) { .literalblock > .content > pre, .listingblock > .content > pre { font-size: 0.9em; } }
diff --git a/lib/asciidoctor/backends/html5.rb b/lib/asciidoctor/backends/html5.rb
index 2e8085dc..99099c48 100644
--- a/lib/asciidoctor/backends/html5.rb
+++ b/lib/asciidoctor/backends/html5.rb
@@ -72,7 +72,7 @@ if DEFAULT_STYLESHEET_KEYS.include?(attr 'stylesheet')
</style><%
end
elsif attr? :stylesheet
- if attr? 'linkcss' %>
+ if @safe >= SafeMode::SECURE || (attr? 'linkcss') %>
<link rel="stylesheet" href="<%= normalize_web_path((attr :stylesheet), (attr :stylesdir, '')) %>"><%
else %>
<style>
@@ -418,24 +418,25 @@ class BlockListingTemplate < BaseTemplate
<div class="content monospaced"><%
if attr? 'style', 'source', false
language = (language = (attr 'language')) ? %(\#{language} language-\#{language}) : nil
+ nowrap = !(@document.attr? 'prewrap') || (option? 'nowrap')
case attr 'source-highlighter'
when 'coderay'
- pre_class = ' class="CodeRay"'
+ pre_class = nowrap ? ' class="CodeRay nowrap"' : ' class="CodeRay"'
code_class = language ? %( class="\#{language}") : nil
when 'highlightjs', 'highlight.js'
- pre_class = ' class="highlight"'
+ pre_class = nowrap ? ' class="highlight nowrap"' : ' class="highlight"'
code_class = language ? %( class="\#{language}") : nil
when 'prettify'
- pre_class = %( class="prettyprint\#{(attr? 'linenums') ? ' linenums' : nil})
+ pre_class = %( class="prettyprint\#{nowrap ? ' nowrap' : nil}\#{(attr? 'linenums') ? ' linenums' : nil})
pre_class = language ? %(\#{pre_class} \#{language}") : %(\#{pre_class}")
code_class = nil
else
- pre_class = ' class="highlight"'
+ pre_class = nowrap ? ' class="highlight nowrap"' : ' class="highlight"'
code_class = language ? %( class="\#{language}") : nil
end %>
<pre<%= pre_class %>><code<%= code_class %>><%= template.preserve_endlines(content, self) %></code></pre><%
else %>
-<pre><%= template.preserve_endlines(content, self) %></pre><%
+<pre<%= !(@document.attr? 'prewrap') || (option? 'nowrap') ? ' class="nowrap"' : nil %>><%= template.preserve_endlines(content, self) %></pre><%
end %>
</div>
</div>
@@ -449,7 +450,7 @@ class BlockLiteralTemplate < BaseTemplate
<%#encoding:UTF-8%><div#{id} class="literalblock#{role_class}">
#{title_div}
<div class="content monospaced">
-<pre><%= template.preserve_endlines(content, self) %></pre>
+<pre<%= !(@document.attr? 'prewrap') || (option? 'nowrap') ? ' class="nowrap"' : nil %>><%= template.preserve_endlines(content, self) %></pre>
</div>
</div>
EOS
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index 10439587..e20af522 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -145,7 +145,7 @@ class Document < AbstractBlock
@attributes['notitle'] = '' unless @options[:header_footer]
@attributes['toc-placement'] = 'auto'
@attributes['stylesheet'] = ''
- @attributes['linkcss'] = ''
+ @attributes['prewrap'] = ''
# language strings
# TODO load these based on language settings
@@ -207,7 +207,7 @@ class Document < AbstractBlock
end
if @safe >= SafeMode::SERVER
- # restrict document from setting linkcss, copycss, source-highlighter and backend
+ # restrict document from setting copycss, source-highlighter and backend
@attribute_overrides['copycss'] ||= nil
@attribute_overrides['source-highlighter'] ||= nil
@attribute_overrides['backend'] ||= DEFAULT_BACKEND
@@ -217,7 +217,7 @@ class Document < AbstractBlock
end
@attribute_overrides['docdir'] = ''
if @safe >= SafeMode::SECURE
- # assign linkcss (preventing css embedding) unless disabled from the commandline
+ # assign linkcss (preventing css embedding) unless explicitly disabled from the commandline or API
unless @attribute_overrides.fetch('linkcss', '').nil? || @attribute_overrides.has_key?('linkcss!')
@attribute_overrides['linkcss'] = ''
end
@@ -247,6 +247,12 @@ class Document < AbstractBlock
verdict
}
+ # special case like this can be removed once
+ # we move to a data table for attribute storage
+ #if @attributes['linkcss'].nil?
+ # @attributes.delete('linkcss')
+ #end
+
@attributes['backend'] ||= DEFAULT_BACKEND
@attributes['doctype'] ||= DEFAULT_DOCTYPE
update_backend_attributes