diff options
author | tamarr <tamarr@users.noreply.github.com> | 2018-11-19 18:59:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-19 18:59:52 +0200 |
commit | 29e0ed13f596c6bcd5a2f7d0046c5c81717b56de (patch) | |
tree | ba3cd8d651da14ec2307d3b60ce79c829854d05f /guides/rails_guides | |
parent | 218e50ce59c3abfa5ffdfac253cdeb2f74602da0 (diff) | |
download | rails-29e0ed13f596c6bcd5a2f7d0046c5c81717b56de.tar.gz rails-29e0ed13f596c6bcd5a2f7d0046c5c81717b56de.tar.bz2 rails-29e0ed13f596c6bcd5a2f7d0046c5c81717b56de.zip |
allow right to left styling of docs (#3)
* adding rtl css main file and logic to use
Diffstat (limited to 'guides/rails_guides')
-rw-r--r-- | guides/rails_guides/generator.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index c83538ad48..5eee15b2ec 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -17,13 +17,14 @@ module RailsGuides class Generator GUIDES_RE = /\.(?:erb|md)\z/ - def initialize(edge:, version:, all:, only:, kindle:, language:) + def initialize(edge:, version:, all:, only:, kindle:, language:, rtl: false) @edge = edge @version = version @all = all @only = only @kindle = kindle @language = language + @rtl = rtl if @kindle check_for_kindlegen @@ -116,6 +117,10 @@ module RailsGuides def copy_assets FileUtils.cp_r(Dir.glob("#{@guides_dir}/assets/*"), @output_dir) + if (@rtl) + FileUtils.rm(Dir.glob("#{@output_dir}/stylesheets/main.css")) + FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css") + end end def output_file_for(guide) @@ -198,7 +203,7 @@ module RailsGuides def check_fragment_identifiers(html, anchors) html.scan(/<a\s+href="#([^"]+)/).flatten.each do |fragment_identifier| next if fragment_identifier == "mainCol" # in layout, jumps to some DIV - unless anchors.member?(fragment_identifier) + unless anchors.member?(CGI.unescape(fragment_identifier)) guess = anchors.min { |a, b| Levenshtein.distance(fragment_identifier, a) <=> Levenshtein.distance(fragment_identifier, b) } |