Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow juxtaposed visual test #1168

Merged
merged 8 commits into from
Jul 9, 2019
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
3 changes: 2 additions & 1 deletion spec/visual/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def as_boolean(value)
@raw = Rouge.highlight(@sample, 'plaintext', @formatter)
@highlighted = Rouge.highlight(@sample, @lexer, @formatter)

erb :lexer
template = params[:juxtaposed] ? :lexer_juxtaposed : :lexer
erb template
end


Expand Down
12 changes: 5 additions & 7 deletions spec/visual/templates/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
white-space: pre-wrap;
}
a { text-decoration: none }

header {
color: <%= @comment_color %>;
border-bottom: 1px dotted
}
#page-header, #page-footer {
padding: 15px;
text-align: center;
color: <%= @comment_color %>
}
#page-header {
border-bottom: 1px dotted
}
#page-header h1 {
margin: 0.25em;
Expand All @@ -32,10 +31,9 @@
.section-header {
margin-bottom: 20px;
padding-bottom: 8px;
color: <%= @comment_color %>;
border-bottom: 1px dotted
}
#page-footer {
color: <%= @comment_color %>;
border-top: 1px dotted
}
.rouge-line-table { border-collapse: collapse }
Expand Down
5 changes: 3 additions & 2 deletions spec/visual/templates/lexer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
}

.legend {
float: right;
padding: 15px;
padding-left: 0;
float: right;
width: 250px;
}
</style>

<header id="page-header">
<h1><%= @lexer.class.tag %> lexer visual test</h1>
</header>

<main>
<header class="section-header"><h2>Highlighted</h2></header>
<%= @highlighted %>

<header class="section-header"><h2>Raw</h2></header>
<pre><%= @raw %></pre>
<%= @raw %>
</main>

<aside class="legend">
Expand Down
45 changes: 45 additions & 0 deletions spec/visual/templates/lexer_juxtaposed.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<style type="text/css">
ashmaroli marked this conversation as resolved.
Show resolved Hide resolved
main {
display: inline-block;
margin-right: -215px;
padding: 8px 215px 0 0;
width: 100%;
}
.codeviewer {
float: left;
padding: 8px 12px;
width: 49.5%;
}
.legend {
float: right;
padding: 16px 14px 8px 0;
width: 215px;
}
.legend .codehilite { font-size: 13px }
</style>

<header id="page-header">
<h1><%= @lexer.class.tag %> lexer visual test</h1>
</header>

<main>
<section>
<div class="codeviewer">
<header class="section-header"><h2>Raw</h2></header>
<%= @raw %>
</div>
<div class="codeviewer">
<header class="section-header"><h2>Highlighted</h2></header>
<%= @highlighted %>
</div>
</section>
</main>

<aside class="legend">
<header class="section-header"><h2>Legend</h2></header>
<pre class="codehilite">
<% Rouge::Token.each_token do |token|
%><span class="<%= token.shortname %>"><%= token.qualname %></span>
<% end %>
</pre>
</aside>