Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add screen and print styles

  • Loading branch information...
commit 60b8a707276b0dfbeceb40fdff34f42ed1c4648a 1 parent 1eb8812
@mislav authored
Showing with 382 additions and 0 deletions.
  1. +46 −0 Guardfile
  2. +336 −0 rfc.scss
View
46 Guardfile
@@ -0,0 +1,46 @@
+require 'guard/guard'
+require 'fileutils'
+
+class ::Guard::Sass < ::Guard::Guard
+ def initialize(watchers = [], options = {})
+ super
+ require 'sass' unless defined? ::Sass
+ end
+
+ def run_on_change(paths)
+ paths.reject { |p| File.basename(p).index('_') == 0 }.each do |file|
+ render_file(file)
+ end
+ end
+
+ def run_all
+ all_files = Dir.glob('**/*.*')
+ paths = ::Guard::Watcher.match_files(self, all_files)
+ run_on_change(paths)
+ end
+
+ def render_file(file)
+ source = File.read(file)
+ type = file.match(/\w+$/)[0].to_sym
+ outfile = file.sub(/\.\w+$/, '.css')
+ content = ::Sass::Engine.new(source, @options.merge(:syntax => type)).render
+
+ File.open(outfile, 'w') { |f| f << content }
+ puts "Rendered #{outfile}"
+ rescue ::Sass::SyntaxError
+ warn "Error processing file: #{$!}"
+ end
+end
+
+guard 'sass', :style => :compressed do
+ watch(/^.+\.s[ca]ss$/)
+end
+
+# guard 'livereload', :apply_js_live => false, :grace_period => 0 do
+# ext = %w[js css png gif html md markdown xml]
+
+# watch(%r{.+\.(#{ext.join('|')})$}) do |match|
+# file = match[0]
+# file unless file =~ /^_(?:site|tmp)\//
+# end
+# end
View
336 rfc.scss
@@ -0,0 +1,336 @@
+$body-type: "Helvetica", sans-serif;
+$heading-type: "Hoefler Text", serif;
+$margin-type: "Hoefler Text", serif;
+$pre-type: "Menlo", "Courier New", monospace;
+
+html {
+ margin: 0;
+ font: 10pt/1.26 $body-type;
+}
+
+body {
+ max-width: 50em;
+ margin: 0 auto 3em;
+}
+
+@media print {
+ body { max-width: auto; margin: 0 }
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-family: $heading-type;
+ margin: 2em 0 0.5em 0;
+ page-break-after: avoid;
+}
+h1 {
+ padding: 2em 0 2em 0;
+ margin: 0;
+ font-size: 2.4em;
+ font-weight: 900;
+}
+h2 {
+ font-size: 1.4em;
+ text-transform: uppercase;
+ font-weight: bold;
+}
+h3 {
+ font-size: 1.4em;
+ font-weight: bold;
+}
+h4 {
+ font-size: 1.3em;
+ font-weight: normal;
+ color: #444;
+}
+h5 {
+ font-size: 1.2em;
+ font-weight: normal;
+ color: #444;
+}
+
+q::before { content: "\201C"; }
+q::after { content: "\201D"; }
+
+p { margin: 0 }
+p + p { margin-top: .6em }
+
+p.rfc {
+ margin: 3em 0 1em;
+ color: #555;
+ font-style: italic;
+ + h1 { padding-top: 0 }
+}
+
+pre { margin: 1em 1.3em; font: 90% $pre-type; }
+
+@media print {
+ a { text-decoration: none; color: black }
+}
+
+@media screen, handheld {
+ html { margin: 1em; font-size: 14px; }
+ h1 { margin-bottom: 0.5em }
+ div.frontcover, div.halftitlepage, div.titlepage, div.imprint,
+ div.dedication, div.foreword, div.toc, div.index { display: none }
+}
+
+ol, ul, dl {
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+ul.empty { list-style: none }
+ol.alpha { list-style: upper-latin }
+dl {
+ dt { font-weight: bold }
+ dd + dt { margin-top: .6em }
+ dd { margin-top: .2em; margin-left: 1.5em; }
+}
+li + li { margin-top: .3em }
+
+.titlepage .authors {
+ margin-top: 4em;
+ text-align: right;
+ p { font-weight: bold }
+ li { list-style: none; margin: .5em 0 0 0 }
+ a[href^=mailto] { display: block }
+}
+
+/* cross-references */
+
+a.pageref::after { content: " on page " target-counter(attr(href), page); }
+a.chapref::before { content: " Chapter " target-counter(attr(href), chapter) ", "; }
+a.figref { content: " Figure " target-counter(attr(href), figure); }
+a.tableref { content: " Table " target-counter(attr(href), figure); }
+
+/* figures */
+
+figure, div.figure {
+ margin: 1em 0;
+ counter-increment: figure;
+ page-break-inside: avoid;
+
+ figcaption, .caption {
+ &::before {
+ // content: "Figure " counter(figure) ": ";
+ content: "Figure: ";
+ font-weight: bold;
+ }
+ }
+}
+
+@page {
+ margin: 27mm 16mm 27mm 16mm;
+ size: 7in 9.25in;
+
+ @footnotes {
+ border-top: thin solid black;
+ padding-top: 0.3em;
+ margin-top: 0.6em;
+ margin-left: 30%;
+ }
+}
+
+/* define default page and names pages: cover, blank, frontmatter */
+
+@page :left {
+ @top-left {
+ font: 11pt $margin-type;
+ content: string(short-title);
+ vertical-align: bottom;
+ padding-bottom: 2em;
+ }
+
+ @bottom-left {
+ font: 11pt $margin-type;
+ content: counter(page);
+ padding-top: 2em;
+ vertical-align: top;
+ }
+}
+
+@page :right {
+ @top-right {
+ font: 11pt $margin-type;
+ content: string(header, first);
+ vertical-align: bottom;
+ padding-bottom: 2em;
+ }
+
+ @bottom-right {
+ font: 11pt $margin-type;
+ content: counter(page);
+ text-align: right;
+ vertical-align: top;
+ padding-top: 2em;
+ }
+}
+
+@page frontmatter :left {
+ @top-left {
+ font: 11pt $margin-type;
+ content: string(title);
+ vertical-align: bottom;
+ padding-bottom: 2em;
+ }
+
+ @bottom-left {
+ font: 11pt $margin-type;
+ content: counter(page, lower-roman);
+ padding-top: 2em;
+ vertical-align: top;
+ }
+}
+
+@page cover { margin: 0; }
+
+@page frontmatter :right {
+ @top-right {
+ font: 11pt $margin-type;
+ content: string(header, first);
+ vertical-align: bottom;
+ padding-bottom: 2em;
+ }
+
+ @bottom-right {
+ font: 11pt $margin-type;
+ content: counter(page, lower-roman);
+ text-align: right;
+ vertical-align: top;
+ padding-top: 2em;
+ }
+}
+
+@page blank :left {
+ @top-left { content: normal }
+ @bottom-left { content: normal }
+}
+
+@page blank :right {
+ @top-right { content: normal }
+ @bottom-right { content: normal }
+}
+
+/* footnotes */
+
+.footnote {
+ display: none; /* default rule */
+
+ display: prince-footnote; /* prince-specific rules */
+ position: footnote;
+ footnote-style-position: inside;
+
+ counter-increment: footnote;
+ margin-left: 1.4em;
+ font-size: 90%;
+ line-height: 1.4;
+}
+
+.footnote::footnote-call {
+ vertical-align: super;
+ font-size: 80%;
+}
+
+.footnote::footnote-marker {
+ vertical-align: super;
+ color: green;
+ padding-right: 0.4em;
+}
+
+
+/*
+ A book consists of different types of sections. We propose to use
+ DIV elements with these class names:
+
+ frontcover
+ halftitlepage: contains the title of the book
+ titlepage: contains the title of the book, name of author(s) and publisher
+ imprint: left page with copyright, publisher, library printing information
+ dedication: right page with short dedication
+ foreword: written by someone other than the author(s)
+ toc: table of contents
+ preface: preface, including acknowledgements
+ chapter: each chapter is given its own DIV element
+ references: contains list of references
+ appendix: each appendix is given its own
+ bibliography
+ glossary
+ index
+ colophon: describes how the book was produced
+ backcover
+
+ A book will use several of the types listed above, but few books
+ will use all of them.
+*/
+
+/* which section uses which named page */
+
+.halftitlepage, .titlepage, .imprint, .dedication { page: blank }
+.foreword, .toc, .preface { page: frontmatter }
+
+/* page breaks */
+
+.frontcover, .halftitlepage, .titlepage { page-break-before: right }
+.imprint { page-break-before: always }
+article > section, div.article > div.section, .dedication, .foreword, .toc, .preface,
+.chapter, .reference, .appendix, .bibliography, .glossary, .index, .colophon {
+ page-break-before: always;
+}
+.backcover { page-break-before: left }
+
+section, div.section {
+ h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
+}
+
+/* TOC */
+
+ul.toc, ul.toc ul {
+ list-style-type: none;
+ margin: 0; padding: 0;
+}
+ul.toc ul {
+ margin-left: 1em;
+ font-weight: normal;
+}
+ul.toc > li {
+ font-weight: bold;
+ margin-bottom: 0.5em;
+}
+ul.toc a::after {
+ content: leader('.') target-counter(attr(href), page);
+ font-style: normal;
+}
+ul.toc > li.frontmatter a::after {
+ content: leader('.') target-counter(attr(href), page, lower-roman);
+ font-style: normal;
+}
+ul.toc > li.endmatter a::after {
+ content: leader('.') target-counter(attr(href), page);
+ font-style: normal;
+}
+ul.toc > li.chapter::before {
+ content: "Chapter " counter(toc-chapter, decimal);
+ display: block;
+ margin: 1em 0 0.1em -2.5cm;
+ font-weight: normal;
+ counter-increment: toc-chapter;
+ page-break-after: avoid;
+}
+
+/* TODO: chapter numbers */
+
+// article, .article {
+// section, div.section {
+// counter-reset: chapter;
+// h2, h3, h4, h5, h6 {
+// &::before {
+// content: counters(chapter, ".") ". ";
+// counter-increment: chapter;
+// }
+// }
+// }
+// }
+
+h1 { string-set: header content(); }
+section > h2, div.section > h2 {
+ string-set: header "Chapter " counter(chapter) ": " content();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.