Skip to content

Commit 3bba809

Browse files
authored
Merge pull request #131 from alphagov/improve-code-font-sizing
Improve code font sizing
2 parents 8d75660 + f89598c commit 3bba809

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

example/source/code.html.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Code examples
3+
---
4+
5+
# Code examples
6+
7+
A paragraph with a `code` element within it.
8+
9+
<a href="#"><code>code element within a link</code></a>
10+
11+
An example of a code block with a long line length
12+
13+
```ruby
14+
RSpec.describe ContentItem do
15+
subject { described_class.new(base_path) }
16+
let(:base_path) { "/search/news-and-communications" }
17+
let(:finder_content_item) { news_and_communications }
18+
let(:news_and_communications) {
19+
JSON.parse(File.read(Rails.root.join("features", "fixtures", "news_and_communications.json")))
20+
}
21+
22+
RSpec.describe "as_hash" do
23+
it "returns a content item as a hash" do
24+
expect(subject.as_hash).to eql(finder_content_item)
25+
end
26+
end
27+
end
28+
```
29+
30+
An example of a code block with a short length
31+
32+
```ruby
33+
RSpec.describe ContentItem do
34+
end
35+
```

example/source/index.html.md.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ If you want slightly more control, you can always use <strong>HTML</strong>.
1919
For more detail and troubleshooting, take a look at the `README.md` file in the root of this project.
2020

2121
<%= warning_text "Look out! A warning!" %>
22-
23-
<a href="#"><code>code element within a link</code></a>

lib/assets/stylesheets/modules/_technical-documentation.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@
111111
border-left: govuk-spacing(2) solid govuk-colour("mid-grey");
112112
}
113113

114+
// http://code.iamkate.com/html-and-css/fixing-browsers-broken-monospace-font-handling/
115+
pre,
116+
code {
117+
// Restores the normal text size in Mozilla Firefox, Google Chrome, and Safari; this unusual style rule should also be used anywhere where you would otherwise set the font-family property to ‘monospace’.
118+
font-family: monospace, monospace;
119+
// Restores the normal text size in Internet Explorer and Opera.
120+
font-size: 1em;
121+
}
122+
114123
pre {
115124
background: $code-00;
116125
padding: 15px;

0 commit comments

Comments
 (0)