Created
October 29, 2015 05:20
-
-
Save muojp/4c4790f01d92072fa982 to your computer and use it in GitHub Desktop.
Re:VIEW 1.6.0 -> 1.7.0 diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.rubocop.yml b/.rubocop.yml | |
index 137ead8..f944ff7 100644 | |
--- a/.rubocop.yml | |
+++ b/.rubocop.yml | |
@@ -1 +1,43 @@ | |
-inherit_from: rubocop-todo.yml | |
+AllCops: | |
+ Exclude: | |
+ - lib/lineinput.rb | |
+ - lib/uuid.rb | |
+ | |
+inherit_from: .rubocop_todo.yml | |
+ | |
+Lint/BlockAlignment: | |
+ Enabled: true | |
+ | |
+Lint/EndAlignment: | |
+ Enabled: AlignWith | |
+ | |
+Performance/ReverseEach: | |
+ Enabled: true | |
+ | |
+# Unnecessary spacing detected. | |
+Style/ExtraSpacing: | |
+ Enabled: true | |
+ | |
+# Use tr instead of gsub. | |
+Performance/StringReplacement: | |
+ Enabled: false | |
+ | |
+# Use alias_method instead of alias. | |
+Style/Alias: | |
+ Enabled: true | |
+ | |
+# Do not introduce global variables. | |
+Style/GlobalVars: | |
+ Enabled: true | |
+ | |
+# Use self-assignment shorthand +=. | |
+Style/SelfAssignment: | |
+ Enabled: true | |
+ | |
+# When defining the == operator, name its argument other. | |
+Style/OpMethod: | |
+ Enabled: true | |
+ | |
+# Use snake_case for variable names. | |
+Style/VariableName: | |
+ Enabled: true | |
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml | |
new file mode 100644 | |
index 0000000..4e7e365 | |
--- /dev/null | |
+++ b/.rubocop_todo.yml | |
@@ -0,0 +1,605 @@ | |
+# This configuration was generated by `rubocop --auto-gen-config` | |
+# on 2015-06-29 21:55:30 +0900 using RuboCop version 0.32.1. | |
+# The point is for the user to remove these configuration records | |
+# one by one as the offenses are removed from the code base. | |
+# Note that changes in the inspected code, or installation of new | |
+# versions of RuboCop, may require this file to be generated again. | |
+ | |
+# Offense count: 2 | |
+Lint/AmbiguousOperator: | |
+ Enabled: false | |
+ | |
+# Offense count: 36 | |
+# Configuration parameters: AllowSafeAssignment. | |
+Lint/AssignmentInCondition: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+Lint/HandleExceptions: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+Lint/LiteralInCondition: | |
+ Enabled: false | |
+ | |
+# Offense count: 10 | |
+Lint/NestedMethodDefinition: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+Lint/NonLocalExitFromIterator: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+Lint/ParenthesesAsGroupedExpression: | |
+ Enabled: false | |
+ | |
+# Offense count: 6 | |
+Lint/UnderscorePrefixedVariableName: | |
+ Enabled: false | |
+ | |
+# Offense count: 84 | |
+# Cop supports --auto-correct. | |
+Lint/UnusedBlockArgument: | |
+ Enabled: false | |
+ | |
+# Offense count: 214 | |
+# Cop supports --auto-correct. | |
+Lint/UnusedMethodArgument: | |
+ Enabled: false | |
+ | |
+# Offense count: 13 | |
+Lint/UselessAssignment: | |
+ Enabled: false | |
+ | |
+# Offense count: 184 | |
+Metrics/AbcSize: | |
+ Max: 298 | |
+ | |
+# Offense count: 9 | |
+Metrics/BlockNesting: | |
+ Max: 4 | |
+ | |
+# Offense count: 35 | |
+# Configuration parameters: CountComments. | |
+Metrics/ClassLength: | |
+ Max: 992 | |
+ | |
+# Offense count: 54 | |
+Metrics/CyclomaticComplexity: | |
+ Max: 65 | |
+ | |
+# Offense count: 815 | |
+# Configuration parameters: AllowURI, URISchemes. | |
+Metrics/LineLength: | |
+ Max: 1189 | |
+ | |
+# Offense count: 296 | |
+# Configuration parameters: CountComments. | |
+Metrics/MethodLength: | |
+ Max: 431 | |
+ | |
+# Offense count: 1 | |
+# Configuration parameters: CountComments. | |
+Metrics/ModuleLength: | |
+ Max: 134 | |
+ | |
+# Offense count: 2 | |
+# Configuration parameters: CountKeywordArgs. | |
+Metrics/ParameterLists: | |
+ Max: 8 | |
+ | |
+# Offense count: 49 | |
+Metrics/PerceivedComplexity: | |
+ Max: 69 | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/AccessModifierIndentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+Style/AccessorMethodName: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. | |
+Style/AlignHash: | |
+ Enabled: false | |
+ | |
+# Offense count: 15 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/AlignParameters: | |
+ Enabled: false | |
+ | |
+# Offense count: 30 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/AndOr: | |
+ Enabled: false | |
+ | |
+# Offense count: 23 | |
+Style/AsciiComments: | |
+ Enabled: false | |
+ | |
+# Offense count: 617 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/BarePercentLiterals: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/BlockComments: | |
+ Enabled: false | |
+ | |
+# Offense count: 109 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | |
+Style/BlockDelimiters: | |
+ Enabled: false | |
+ | |
+# Offense count: 69 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/BracesAroundHashParameters: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+Style/CaseEquality: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep. | |
+Style/CaseIndentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+Style/ClassAndModuleCamelCase: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/ClassAndModuleChildren: | |
+ Enabled: false | |
+ | |
+# Offense count: 8 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/ClassCheck: | |
+ Enabled: false | |
+ | |
+# Offense count: 28 | |
+# Cop supports --auto-correct. | |
+Style/ClassMethods: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/ColonMethodCall: | |
+ Enabled: false | |
+ | |
+# Offense count: 7 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: Keywords. | |
+Style/CommentAnnotation: | |
+ Enabled: false | |
+ | |
+# Offense count: 9 | |
+# Cop supports --auto-correct. | |
+Style/CommentIndentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+Style/ConstantName: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+Style/DeprecatedHashMethods: | |
+ Enabled: false | |
+ | |
+# Offense count: 105 | |
+Style/Documentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/DotPosition: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+Style/EachWithObject: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/EmptyElse: | |
+ Enabled: false | |
+ | |
+# Offense count: 5 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: AllowAdjacentOneLineDefs. | |
+Style/EmptyLineBetweenDefs: | |
+ Enabled: false | |
+ | |
+# Offense count: 43 | |
+# Cop supports --auto-correct. | |
+Style/EmptyLines: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+# Cop supports --auto-correct. | |
+Style/EmptyLinesAroundAccessModifier: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/EmptyLinesAroundBlockBody: | |
+ Enabled: false | |
+ | |
+# Offense count: 53 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/EmptyLinesAroundClassBody: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+Style/EmptyLinesAroundMethodBody: | |
+ Enabled: false | |
+ | |
+# Offense count: 44 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/EmptyLinesAroundModuleBody: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+Style/EmptyLiteral: | |
+ Enabled: false | |
+ | |
+# Offense count: 12 | |
+# Configuration parameters: Exclude. | |
+Style/FileName: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/FirstParameterIndentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/For: | |
+ Enabled: false | |
+ | |
+# Offense count: 22 | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/FormatString: | |
+ Enabled: false | |
+ | |
+# Offense count: 31 | |
+# Configuration parameters: MinBodyLength. | |
+Style/GuardClause: | |
+ Enabled: false | |
+ | |
+# Offense count: 52 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: SupportedStyles, UseHashRocketsWithSymbolValues. | |
+Style/HashSyntax: | |
+ EnforcedStyle: hash_rockets | |
+ | |
+# Offense count: 55 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: MaxLineLength. | |
+Style/IfUnlessModifier: | |
+ Enabled: false | |
+ | |
+# Offense count: 6 | |
+# Cop supports --auto-correct. | |
+Style/IndentArray: | |
+ Enabled: false | |
+ | |
+# Offense count: 24 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/IndentHash: | |
+ Enabled: false | |
+ | |
+# Offense count: 39 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/IndentationConsistency: | |
+ Enabled: false | |
+ | |
+# Offense count: 61 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: Width. | |
+Style/IndentationWidth: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+Style/InfiniteLoop: | |
+ Enabled: false | |
+ | |
+# Offense count: 18 | |
+# Cop supports --auto-correct. | |
+Style/LeadingCommentSpace: | |
+ Enabled: false | |
+ | |
+# Offense count: 7 | |
+# Cop supports --auto-correct. | |
+Style/LineEndConcatenation: | |
+ Enabled: false | |
+ | |
+# Offense count: 105 | |
+# Cop supports --auto-correct. | |
+Style/MethodCallParentheses: | |
+ Enabled: false | |
+ | |
+# Offense count: 11 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/MethodDefParentheses: | |
+ Enabled: false | |
+ | |
+# Offense count: 38 | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/MethodName: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+Style/MultilineBlockChain: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/MultilineIfThen: | |
+ Enabled: false | |
+ | |
+# Offense count: 35 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/MultilineOperationIndentation: | |
+ Enabled: false | |
+ | |
+# Offense count: 8 | |
+# Cop supports --auto-correct. | |
+Style/NegatedIf: | |
+ Enabled: false | |
+ | |
+# Offense count: 8 | |
+# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. | |
+Style/Next: | |
+ Enabled: false | |
+ | |
+# Offense count: 5 | |
+# Cop supports --auto-correct. | |
+Style/Not: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/NumericLiterals: | |
+ MinDigits: 6 | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: AllowSafeAssignment. | |
+Style/ParenthesesAroundCondition: | |
+ Enabled: false | |
+ | |
+# Offense count: 516 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: PreferredDelimiters. | |
+Style/PercentLiteralDelimiters: | |
+ Enabled: false | |
+ | |
+# Offense count: 160 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/PercentQLiterals: | |
+ Enabled: false | |
+ | |
+# Offense count: 37 | |
+# Cop supports --auto-correct. | |
+Style/PerlBackrefs: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Configuration parameters: NamePrefix, NamePrefixBlacklist. | |
+Style/PredicateName: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+Style/RedundantBegin: | |
+ Enabled: false | |
+ | |
+# Offense count: 14 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: AllowMultipleReturnValues. | |
+Style/RedundantReturn: | |
+ Enabled: false | |
+ | |
+# Offense count: 16 | |
+# Cop supports --auto-correct. | |
+Style/RedundantSelf: | |
+ Enabled: false | |
+ | |
+# Offense count: 35 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. | |
+Style/RegexpLiteral: | |
+ Enabled: false | |
+ | |
+# Offense count: 8 | |
+# Cop supports --auto-correct. | |
+Style/SelfAssignment: | |
+ Enabled: true | |
+ | |
+# Offense count: 6 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: AllowAsExpressionSeparator. | |
+Style/Semicolon: | |
+ Enabled: false | |
+ | |
+# Offense count: 42 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/SignalException: | |
+ Enabled: false | |
+ | |
+# Offense count: 11 | |
+# Configuration parameters: Methods. | |
+Style/SingleLineBlockParams: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: AllowIfMethodIsEmpty. | |
+Style/SingleLineMethods: | |
+ Enabled: false | |
+ | |
+# Offense count: 143 | |
+# Cop supports --auto-correct. | |
+Style/SpaceAfterComma: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+Style/SpaceAfterNot: | |
+ Enabled: false | |
+ | |
+# Offense count: 8 | |
+# Cop supports --auto-correct. | |
+Style/SpaceAfterSemicolon: | |
+ Enabled: false | |
+ | |
+# Offense count: 46 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/SpaceAroundEqualsInParameterDefault: | |
+ Enabled: false | |
+ | |
+# Offense count: 204 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: MultiSpaceAllowedForOperators. | |
+Style/SpaceAroundOperators: | |
+ Enabled: false | |
+ | |
+# Offense count: 84 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/SpaceBeforeBlockBraces: | |
+ Enabled: false | |
+ | |
+# Offense count: 2 | |
+# Cop supports --auto-correct. | |
+Style/SpaceBeforeComma: | |
+ Enabled: false | |
+ | |
+# Offense count: 272 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. | |
+Style/SpaceInsideBlockBraces: | |
+ Enabled: false | |
+ | |
+# Offense count: 151 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. | |
+Style/SpaceInsideHashLiteralBraces: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/SpaceInsideParens: | |
+ Enabled: false | |
+ | |
+# Offense count: 1 | |
+# Cop supports --auto-correct. | |
+Style/SpaceInsideRangeLiteral: | |
+ Enabled: false | |
+ | |
+# Offense count: 16 | |
+# Cop supports --auto-correct. | |
+Style/SpecialGlobalVars: | |
+ Enabled: false | |
+ | |
+# Offense count: 2762 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/StringLiterals: | |
+ Enabled: false | |
+ | |
+# Offense count: 450 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/StringLiteralsInInterpolation: | |
+ Enabled: false | |
+ | |
+# Offense count: 12 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: IgnoredMethods. | |
+Style/SymbolProc: | |
+ Enabled: false | |
+ | |
+# Offense count: 348 | |
+# Cop supports --auto-correct. | |
+Style/Tab: | |
+ Enabled: false | |
+ | |
+# Offense count: 9 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyle, SupportedStyles. | |
+Style/TrailingBlankLines: | |
+ Enabled: false | |
+ | |
+# Offense count: 32 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. | |
+Style/TrailingComma: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+# Cop supports --auto-correct. | |
+Style/TrailingWhitespace: | |
+ Enabled: false | |
+ | |
+# Offense count: 4 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. | |
+Style/TrivialAccessors: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+Style/UnlessElse: | |
+ Enabled: false | |
+ | |
+# Offense count: 228 | |
+# Cop supports --auto-correct. | |
+Style/UnneededPercentQ: | |
+ Enabled: false | |
+ | |
+# Offense count: 3 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: MaxLineLength. | |
+Style/WhileUntilModifier: | |
+ Enabled: false | |
+ | |
+# Offense count: 19 | |
+# Cop supports --auto-correct. | |
+# Configuration parameters: WordRegex. | |
+Style/WordArray: | |
+ MinSize: 7 | |
diff --git a/.travis.yml b/.travis.yml | |
index 30a0f32..b87175f 100644 | |
--- a/.travis.yml | |
+++ b/.travis.yml | |
@@ -1,9 +1,18 @@ | |
+language: ruby | |
+sudo: false | |
+ | |
rvm: | |
- 1.9.3 | |
- 2.0.0 | |
- 2.1.* | |
- 2.2.* | |
+ - ruby-head | |
branches: | |
only: | |
- master | |
+ | |
+script: | |
+ - bundle exec rake test | |
+ - bundle exec rubocop | |
+ | |
diff --git a/ChangeLog b/ChangeLog | |
index 8dc850d..33f141c 100644 | |
--- a/ChangeLog | |
+++ b/ChangeLog | |
@@ -1,3 +1,7 @@ | |
+Thu Oct 29 13:58:22 2015 KADO Masanori <[email protected]> | |
+ | |
+ * Release 1.7.0 | |
+ | |
Mon Jun 29 18:16:06 2015 KADO Masanori <[email protected]> | |
* Release 1.6.0 | |
diff --git a/Dockerfile b/Dockerfile | |
new file mode 100644 | |
index 0000000..69743c1 | |
--- /dev/null | |
+++ b/Dockerfile | |
@@ -0,0 +1,22 @@ | |
+# This file is a sample Dockerfile to build Re:VIEW documents. | |
+# | |
+# Build: | |
+# $ docker build -t review . | |
+# | |
+# Usage: | |
+# $ cd path/to/review/project | |
+# $ docker run -it --rm -v `pwd`:/work review rake pdf | |
+# | |
+# cf. https://github.com/vvakame/docker-review/blob/master/Dockerfile | |
+ | |
+FROM debian:sid | |
+MAINTAINER takahashim | |
+ | |
+RUN apt-get update \ | |
+ && apt-get install -y --no-install-recommends git-core ruby locales zip \ | |
+ && apt-get install -y --no-install-recommends texlive-lang-cjk texlive-lang-japanese texlive-fonts-recommended texlive-latex-extra ghostscript \ | |
+ && rm -rf /var/lib/apt/lists/* | |
+RUN gem install review rake bundler --no-rdoc --no-ri | |
+ | |
+VOLUME ["/work"] | |
+WORKDIR /work | |
diff --git a/README.rdoc b/README.rdoc | |
index d5453d4..58f8b6d 100644 | |
--- a/README.rdoc | |
+++ b/README.rdoc | |
@@ -78,4 +78,4 @@ LGPL. See COPYING file. | |
== Copyright | |
-Copyright (c) 2006-2014 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado. | |
+Copyright (c) 2006-2015 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado. | |
diff --git a/Rakefile b/Rakefile | |
index 5200110..e15b9ce 100644 | |
--- a/Rakefile | |
+++ b/Rakefile | |
@@ -12,7 +12,7 @@ require 'rake/clean' | |
task :default => [:test] | |
Rake::TestTask.new("test") do |t| | |
- t.libs << "test" | |
+ t.libs << "test" | |
t.test_files = Dir.glob("test/**/test_*.rb") | |
t.verbose = true | |
end | |
diff --git a/bin/review-check b/bin/review-check | |
index b8abe81..956a340 100755 | |
--- a/bin/review-check | |
+++ b/bin/review-check | |
@@ -31,12 +31,7 @@ rescue Errno::EPIPE | |
end | |
def main | |
- $KCODE = 'UTF-8' unless defined?(Encoding) | |
@config = ReVIEW::Configure.values | |
- @config.merge!({ | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8" | |
- }) | |
@book = ReVIEW::Book::Base.load | |
@book.config = @config | |
@@ -44,12 +39,6 @@ def main | |
files = ARGV unless ARGV.empty? | |
opts = OptionParser.new | |
opts.version = ReVIEW::VERSION | |
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| | |
- @config["inencoding"] = enc | |
- } | |
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| | |
- @config["outencoding"] = enc | |
- } | |
opts.on('-a', '--all-chapters', 'Check all chapters.') { | |
files = @book.chapters.map {|ent| ent.path } | |
} | |
@@ -95,11 +84,11 @@ def check_text(files) | |
each_paragraph(f) do |para, lineno| | |
s = para.join('') | |
if m = re.match(s) | |
- next if m[0] == $ReVIEW_utils_word_ok | |
+ next if m[0] == @review_utils_word_ok | |
next if neg and neg =~ s | |
str, offset = find_line(para, re) | |
out = sprintf("%s:%d: %s\n", path, lineno + offset, str) | |
- print convert_outencoding(out, @config["outencoding"]) | |
+ print out | |
end | |
end | |
} | |
@@ -109,14 +98,14 @@ end | |
def find_line(lines, re) | |
# single line? | |
lines.each_with_index do |line, idx| | |
- return line.gsub(re, '<<<\&>>>'), idx if re =~ line | |
+ return line.gsub(re, '<<<\&>>>'), idx if re =~ line | |
end | |
# multiple lines? | |
i = 0 | |
while i < lines.size - 1 | |
str = lines[i] + lines[i+1] | |
- return str.gsub(re, '<<<\&>>>'), i if re =~ str | |
+ return str.gsub(re, '<<<\&>>>'), i if re =~ str | |
i += 1 | |
end | |
@@ -127,7 +116,7 @@ def words_re(rc) | |
words = [] | |
nega = [] | |
File.foreach(rc) do |line| | |
- next if line[0,1] == '#' | |
+ next if line[0,1] == '#' | |
if / !/ =~ line | |
line, n = *line.split(/!/, 2) | |
nega.push n.strip | |
@@ -139,13 +128,11 @@ def words_re(rc) | |
end | |
def each_paragraph(f) | |
- $ReVIEW_utils_word_ok = nil | |
+ @review_utils_word_ok = nil | |
while line = f.gets | |
- line = convert_inencoding(line, @config["inencoding"]) | |
- | |
case line | |
when /\A\#@ok\((.*)\)/ | |
- $ReVIEW_utils_word_ok = $1 | |
+ @review_utils_word_ok = $1 | |
when /\A\#@/ | |
; | |
when %r[\A//caption\{(.*?)//\}] | |
@@ -168,7 +155,7 @@ def each_paragraph(f) | |
buf.push line.strip | |
end | |
yield buf, lineno | |
- $ReVIEW_utils_word_ok = nil | |
+ @review_utils_word_ok = nil | |
end | |
end | |
end | |
diff --git a/bin/review-compile b/bin/review-compile | |
index 06664c4..bdc9d6d 100755 | |
--- a/bin/review-compile | |
+++ b/bin/review-compile | |
@@ -34,8 +34,6 @@ rescue Errno::EPIPE | |
end | |
def _main | |
- $KCODE = 'UTF-8' unless defined?(Encoding) | |
- | |
mode = :files | |
basedir = nil | |
if /\Areview2/ =~ File.basename($0) | |
@@ -48,16 +46,14 @@ def _main | |
config = ReVIEW::Configure.values | |
config.merge!({ | |
- "secnolevel" => 2, # for IDGXML and HTML | |
- "tableopt" => nil, # for IDGXML | |
- "nolf" => nil, # for IDGXML | |
- "chapref" => nil, # for IDGXML | |
+ "secnolevel" => 2, # for IDGXML and HTML | |
+ "tableopt" => nil, # for IDGXML | |
+ "nolf" => nil, # for IDGXML | |
+ "chapref" => nil, # for IDGXML | |
"structuredxml" => nil, # for IDGXML | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => [], # for HTML | |
- "mathml" => nil, # for HTML | |
- "language" => "ja", # for HTML | |
+ "stylesheet" => [], # for HTML | |
+ "mathml" => nil, # for HTML | |
+ "language" => "ja", # for HTML | |
"deprecated-blocklines" => nil, | |
"footnotetext" => false, | |
"htmlext" => "html", | |
@@ -71,8 +67,6 @@ def _main | |
require 'yaml' | |
config = config.merge(YAML.load_file(yaml)) | |
end | |
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| config["inencoding"] = enc } | |
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| config["outencoding"] = enc } | |
opts.on('-c', '--check', 'Check manuscript') { check_only = true } | |
opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i } | |
opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i } | |
@@ -173,12 +167,12 @@ def _main | |
compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only)) | |
book.chapters.each do |chap| | |
str = compiler.compile(chap) | |
- write "#{chap.name}#{compiler.strategy.extname}", str unless check_only | |
+ write "#{chap.name}#{compiler.strategy.extname}", str unless check_only | |
end | |
# PART | |
book.parts_in_file.each do |part| | |
str = compiler.compile(part) | |
- write "#{part.name}#{compiler.strategy.extname}", str unless check_only | |
+ write "#{part.name}#{compiler.strategy.extname}", str unless check_only | |
end | |
else | |
raise "must not happen: #{mode}" | |
diff --git a/bin/review-epubmaker-legacy b/bin/review-epubmaker-legacy | |
index 8cdc855..5b4f5b7 100755 | |
--- a/bin/review-epubmaker-legacy | |
+++ b/bin/review-epubmaker-legacy | |
@@ -28,7 +28,7 @@ require 'review/i18n' | |
require 'review/htmlutils' | |
include ReVIEW::HTMLUtils | |
-$essential_files = ['top', 'toc', 'colophon'] | |
+@essential_files = ['top', 'toc', 'colophon'] | |
def main | |
opts = OptionParser.new | |
opts.version = ReVIEW::VERSION | |
@@ -57,7 +57,7 @@ def main | |
yamlfile = ARGV[0] | |
values = ReVIEW::Configure.values.merge(YAML.load_file(yamlfile)) | |
bookname = values["bookname"] | |
- $essential_files <<= bookname | |
+ @essential_files <<= bookname | |
tmp = values["debug"].nil? ? Dir.mktmpdir : "." | |
@bookdir = "#{tmp}/#{bookname}-epub" | |
@epubversion = values["epubversion"] || 2 | |
@@ -774,8 +774,8 @@ end | |
def output_chaps_by_file(l, values) | |
file_id = File.basename(l.chomp.strip,".*") | |
- if (idx = $essential_files.index(file_id)) | |
- if idx == $essential_files.size - 1 | |
+ if (idx = @essential_files.index(file_id)) | |
+ if idx == @essential_files.size - 1 | |
STDERR.puts "#{file_id} is book name. Please rename #{l.chomp.strip}." | |
else | |
STDERR.puts "#{file_id} is special name. Please rename #{l.chomp.strip}." | |
@@ -800,8 +800,8 @@ def include_mathml?(filename) | |
} | |
return false | |
} | |
- rescue | |
- false | |
+rescue | |
+ false | |
end | |
def getFigId(filename) | |
diff --git a/bin/review-index b/bin/review-index | |
index 5c1099b..d959c9a 100755 | |
--- a/bin/review-index | |
+++ b/bin/review-index | |
@@ -32,25 +32,14 @@ rescue Errno::EPIPE | |
end | |
def _main | |
- $KCODE = 'UTF-8' unless defined?(Encoding) | |
- | |
printer_class = ReVIEW::TextTOCPrinter | |
source = nil | |
upper = ReVIEW::TOCPrinter.default_upper_level | |
- param = { | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8" | |
- } | |
+ param = {} | |
book = ReVIEW::Book::Base.load | |
opts = OptionParser.new | |
opts.version = ReVIEW::VERSION | |
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| | |
- param["inencoding"] = enc | |
- } | |
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| | |
- param["outencoding"] = enc | |
- } | |
opts.on('-a', '--all', 'print all chapters.') { | |
begin | |
source = book | |
@@ -71,7 +60,7 @@ def _main | |
} | |
opts.on('-l', '--level N', 'list upto N level (1..4, default=4)') {|n| | |
upper = Integer(n) | |
- unless (0..4).include?(upper) # 0 is hidden option | |
+ unless (0..4).include?(upper) # 0 is hidden option | |
$stderr.puts "-l/--level option accepts only 1..4" | |
exit 1 | |
end | |
diff --git a/bin/review-preproc b/bin/review-preproc | |
index 4f9a299..ee0941d 100755 | |
--- a/bin/review-preproc | |
+++ b/bin/review-preproc | |
@@ -35,25 +35,12 @@ rescue Errno::EPIPE | |
end | |
def main | |
- $KCODE = 'UTF-8' unless defined?(Encoding) | |
- | |
- param = { | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- } | |
+ param = {} | |
mode = :output | |
opts = OptionParser.new | |
opts.version = ReVIEW::VERSION | |
opts.banner = "Usage: #{File.basename($0)} [-c|-d|-s|--replace] [<file>...]" | |
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and | |
-SJIS)') {|enc| | |
- param["inencoding"] = enc | |
- } | |
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC | |
-, JIS, and SJIS)') {|enc| | |
- param["outencoding"] = enc | |
- } | |
opts.on('-c', '--check', 'Check if preprocess is needed.') { | |
mode = :check | |
} | |
diff --git a/bin/review-validate b/bin/review-validate | |
index 2975a2e..6bbf322 100755 | |
--- a/bin/review-validate | |
+++ b/bin/review-validate | |
@@ -15,7 +15,7 @@ colcount = 0 | |
ln = 0 | |
ARGF.each {|line| | |
- ln = ln + 1 | |
+ ln += 1 | |
if line =~ /\A\/\/([a-z]+).+\{/ | |
# block | |
_block = $1 | |
diff --git a/bin/review-vol b/bin/review-vol | |
index e6d6885..3866e41 100755 | |
--- a/bin/review-vol | |
+++ b/bin/review-vol | |
@@ -21,13 +21,7 @@ require 'optparse' | |
include ReVIEW::TextUtils | |
def main | |
- $KCODE = 'UTF-8' unless defined?(Encoding) | |
- | |
@config = ReVIEW::Configure.values | |
- @config.merge!({ | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8" | |
- }) | |
part_sensitive = false | |
basedir = nil | |
@@ -40,12 +34,6 @@ def main | |
opts.on('-P', '--part-sensitive', 'Prints volume of each parts.') { | |
part_sensitive = true | |
} | |
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| | |
- @config["inencoding"] = enc | |
- } | |
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| | |
- @config["outencoding"] = enc | |
- } | |
opts.on('--directory=DIR', 'Compile all chapters in DIR.') {|path| | |
basedir = path | |
} | |
@@ -95,7 +83,7 @@ end | |
def print_chapter_volume(chap) | |
vol = chap.volume | |
- title = convert_outencoding(chap.title, @config["outencoding"]) | |
+ title = chap.title | |
printf "%s %3dKB %6dC %5dL %3dP %s %-s\n", | |
chapnumstr(chap.number), vol.kbytes, vol.chars, vol.lines, vol.page, | |
"#{chap.name} ".ljust(25, '.'), title | |
diff --git a/doc/NEWS.ja.md b/doc/NEWS.ja.md | |
index 47a06ba..41e47cc 100644 | |
--- a/doc/NEWS.ja.md | |
+++ b/doc/NEWS.ja.md | |
@@ -1,3 +1,25 @@ | |
+# Version 1.7.0の主な変更点 | |
+ | |
+## 全般 | |
+* Rubocopの設定の追加とそれに伴うリファクタリングを実施しました | |
+* 内部の文字コードをUTF-8に統一しました ([#399]) | |
+* Dockerfileを追加しました | |
+ | |
+## バグ修正 | |
+* コードハイライト無効時に、htmlbuilderでlistnumおよびemlistnumにおいて行番号が表示されないバグを修正しました ([#449]) | |
+ | |
+## ビルダーとメーカー | |
+ | |
+### epubmaker | |
+* 綴じ方向を設定する``direction``パラメータをサポートしました ([#435]) | |
+ | |
+## コードコントリビュータ | |
+* [@snoozer05](https://github.com/snoozer05) | |
+ | |
+[#399]: https://github.com/kmuto/review/pull/399 | |
+[#435]: https://github.com/kmuto/review/pull/435 | |
+[#449]: https://github.com/kmuto/review/issues/449 | |
+ | |
# Version 1.6.0の主な変更点 | |
## 全般 | |
diff --git a/doc/NEWS.md b/doc/NEWS.md | |
index 3068dd7..ec219a8 100644 | |
--- a/doc/NEWS.md | |
+++ b/doc/NEWS.md | |
@@ -1,3 +1,25 @@ | |
+# Version 1.7.0 | |
+ | |
+## In general | |
+* Set up Rubocop settings and refactor code with the settings | |
+* Change the internal encoding to UTF-8 altogether ([#399]) | |
+* Add a Dockerfile | |
+ | |
+## Bug Fix | |
+* Fix htmlbuilder to display line numbers with listnum/emlistnum under a syntax highlighting environment ([#449]) | |
+ | |
+## Builders and Makers | |
+ | |
+### epubmaker | |
+* Support ``direction`` parameter to set binding direction ([#435]) | |
+ | |
+## Code contributors | |
+* [@snoozer05](https://github.com/snoozer05) | |
+ | |
+[#399]: https://github.com/kmuto/review/pull/399 | |
+[#435]: https://github.com/kmuto/review/pull/435 | |
+[#449]: https://github.com/kmuto/review/issues/449 | |
+ | |
# Version 1.6.0 | |
## In general | |
diff --git a/doc/quickstart.ja.md b/doc/quickstart.ja.md | |
index d0a6ec4..e110b99 100644 | |
--- a/doc/quickstart.ja.md | |
+++ b/doc/quickstart.ja.md | |
@@ -161,7 +161,7 @@ sample.re を HTML に変換すると、次のようになります。 | |
</html> | |
``` | |
-Re:VIEW フォーマットについての詳細は、 [format.rdoc](https://github.com/kmuto/review/blob/master/doc/format.rdoc) を参照してください。 | |
+Re:VIEW フォーマットについての詳細は、 [format.ja.md](https://github.com/kmuto/review/blob/master/doc/format.ja.md) を参照してください。 | |
review-compile を含め、ほとんどのコマンドは `--help` オプションを付けるとオプションについてのヘルプが表示されます。`review-compile` には多数のオプションがあるので確認してください。 | |
diff --git a/doc/quickstart.md b/doc/quickstart.md | |
index bc27edf..10b341a 100644 | |
--- a/doc/quickstart.md | |
+++ b/doc/quickstart.md | |
@@ -191,7 +191,7 @@ You can get HTML file as follows: | |
</html> | |
``` | |
-For more information about Re:VIEW format, see [format.rdoc](https://github.com/kmuto/review/blob/master/doc/format.rdoc). | |
+For more information about Re:VIEW format, see [format.md](https://github.com/kmuto/review/blob/master/doc/format.md). | |
review-compile and other commands in Re:VIEW has `--help` option to output help. `review-compile` has many options, so you may see them. | |
diff --git a/lib/epubmaker/content.rb b/lib/epubmaker/content.rb | |
index c7cb792..c74820e 100644 | |
--- a/lib/epubmaker/content.rb | |
+++ b/lib/epubmaker/content.rb | |
@@ -60,12 +60,12 @@ module EPUBMaker | |
complement | |
end | |
- def ==(obj) | |
- if self.class != obj.class | |
+ def ==(other) | |
+ if self.class != other.class | |
return false | |
end | |
[self.id, self.file, self.media, self.title, self.level, self.notoc, self.chaptype, self.properties] == | |
- [obj.id, obj.file, obj.media, obj.title, obj.level, obj.notoc, obj.chaptype, obj.properties] | |
+ [other.id, other.file, other.media, other.title, other.level, other.notoc, other.chaptype, other.properties] | |
end | |
private | |
diff --git a/lib/epubmaker/epubcommon.rb b/lib/epubmaker/epubcommon.rb | |
index 5936f64..f45165e 100644 | |
--- a/lib/epubmaker/epubcommon.rb | |
+++ b/lib/epubmaker/epubcommon.rb | |
@@ -28,6 +28,10 @@ module EPUBMaker | |
"application/epub+zip" | |
end | |
+ def opf_path | |
+ "OEBPS/#{@producer.params["bookname"]}.opf" | |
+ end | |
+ | |
def opf_coverimage | |
s = "" | |
if @producer.params["coverimage"] | |
@@ -112,66 +116,53 @@ EOT | |
# Return container content. | |
def container | |
- s = <<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"> | |
- <rootfiles> | |
- <rootfile full-path="OEBPS/#{@producer.params["bookname"]}.opf" media-type="application/oebps-package+xml" /> | |
- </rootfiles> | |
-</container> | |
-EOT | |
- s | |
+ @opf_path = opf_path | |
+ tmplfile = File.expand_path('./xml/container.xml.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
# Return cover content. | |
def cover(type=nil) | |
- bodyext = type.nil? ? "" : " epub:type=\"#{type}\"" | |
+ @body_ext = type.nil? ? "" : " epub:type=\"#{type}\"" | |
- s = common_header | |
- s << <<EOT | |
- <title>#{CGI.escapeHTML(@producer.params["title"])}</title> | |
-</head> | |
-<body#{bodyext}> | |
-EOT | |
- if @producer.params["coverimage"].nil? | |
- s << <<EOT | |
-<h1 class="cover-title">#{CGI.escapeHTML(@producer.params["title"])}</h1> | |
-EOT | |
- else | |
- file = nil | |
- @producer.contents.each do |item| | |
- if item.media =~ /\Aimage/ && item.file =~ /#{@producer.params["coverimage"]}\Z/ # / | |
- file = item.file | |
- break | |
- end | |
+ if @producer.params["coverimage"] | |
+ file = @producer.coverimage | |
+ if !file | |
+ raise "coverimage #{@producer.params["coverimage"]} not found. Abort." | |
end | |
- raise "coverimage #{@producer.params["coverimage"]} not found. Abort." if file.nil? | |
- s << <<EOT | |
+ @body = <<-EOT | |
<div id="cover-image" class="cover-image"> | |
<img src="#{file}" alt="#{CGI.escapeHTML(@producer.params["title"])}" class="max"/> | |
</div> | |
-EOT | |
+ EOT | |
+ else | |
+ @body = <<-EOT | |
+<h1 class="cover-title">#{CGI.escapeHTML(@producer.params["title"])}</h1> | |
+ EOT | |
end | |
- s << <<EOT | |
-</body> | |
-</html> | |
-EOT | |
- s | |
+ @title = @producer.params['title'] | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
# Return title (copying) content. | |
def titlepage | |
- s = common_header | |
- s << <<EOT | |
- <title>#{CGI.escapeHTML(@producer.params["title"])}</title> | |
-</head> | |
-<body> | |
- <h1 class="tp-title">#{CGI.escapeHTML(@producer.params["title"])}</h1> | |
-EOT | |
+ @title = @producer.params["title"] | |
+ @body = <<EOT | |
+ <h1 class="tp-title">#{CGI.escapeHTML(@title)}</h1> | |
+EOT | |
if @producer.params["aut"] | |
- s << <<EOT | |
+ @body << <<EOT | |
<p> | |
<br /> | |
<br /> | |
@@ -182,7 +173,7 @@ EOT | |
publisher = @producer.params["pbl"] || @producer.params["prt"] # XXX Backward Compatiblity | |
if publisher | |
- s << <<EOT | |
+ @body << <<EOT | |
<p> | |
<br /> | |
<br /> | |
@@ -193,67 +184,66 @@ EOT | |
EOT | |
end | |
- s << <<EOT | |
-</body> | |
-</html> | |
-EOT | |
- | |
- s | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
# Return colophon content. | |
def colophon | |
- s = common_header | |
- s << <<EOT | |
- <title>#{@producer.res.v("colophontitle")}</title> | |
-</head> | |
-<body> | |
+ @title = @producer.res.v("colophontitle") | |
+ @body = <<EOT | |
<div class="colophon"> | |
EOT | |
if @producer.params["subtitle"].nil? | |
- s << <<EOT | |
+ @body << <<EOT | |
<p class="title">#{CGI.escapeHTML(@producer.params["title"])}</p> | |
EOT | |
else | |
- s << <<EOT | |
+ @body << <<EOT | |
<p class="title">#{CGI.escapeHTML(@producer.params["title"])}<br /><span class="subtitle">#{CGI.escapeHTML(@producer.params["subtitle"])}</span></p> | |
EOT | |
end | |
if @producer.params["date"] || @producer.params["history"] | |
- s << %Q[ <div class="pubhistory">\n] | |
+ @body << %Q[ <div class="pubhistory">\n] | |
if @producer.params["history"] | |
@producer.params["history"].each_with_index do |items, edit| | |
items.each_with_index do |item, rev| | |
editstr = (edit == 0) ? ReVIEW::I18n.t("first_edition") : ReVIEW::I18n.t("nth_edition","#{edit+1}") | |
revstr = ReVIEW::I18n.t("nth_impression", "#{rev+1}") | |
if item =~ /\A\d+\-\d+\-\d+\Z/ | |
- s << %Q[ <p>#{ReVIEW::I18n.t("published_by1", [date_to_s(item), editstr+revstr])}</p>\n] | |
+ @body << %Q[ <p>#{ReVIEW::I18n.t("published_by1", [date_to_s(item), editstr+revstr])}</p>\n] | |
else | |
# custom date with string | |
item.match(/\A(\d+\-\d+\-\d+)[\s ](.+)/) do |m| | |
- s << %Q[ <p>#{ReVIEW::I18n.t("published_by3", [date_to_s(m[1]), m[2]])}</p>\n] | |
+ @body << %Q[ <p>#{ReVIEW::I18n.t("published_by3", [date_to_s(m[1]), m[2]])}</p>\n] | |
end | |
end | |
end | |
end | |
else | |
- s << %Q[ <p>#{ReVIEW::I18n.t("published_by2", date_to_s(@producer.params["date"]))}</p>\n] | |
+ @body << %Q[ <p>#{ReVIEW::I18n.t("published_by2", date_to_s(@producer.params["date"]))}</p>\n] | |
end | |
- s << %Q[ </div>\n] | |
+ @body << %Q[ </div>\n] | |
end | |
- s << %Q[ <table class="colophon">\n] | |
- s << %Q[ <tr><th>#{@producer.res.v("aut")}</th><td>#{CGI.escapeHTML(@producer.params["aut"].join(", "))}</td></tr>\n] unless @producer.params["aut"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("csl")}</th><td>#{CGI.escapeHTML(@producer.params["csl"].join(", "))}</td></tr>\n] unless @producer.params["csl"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("trl")}</th><td>#{CGI.escapeHTML(@producer.params["trl"].join(", "))}</td></tr>\n] unless @producer.params["trl"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("dsr")}</th><td>#{CGI.escapeHTML(@producer.params["dsr"].join(", "))}</td></tr>\n] unless @producer.params["dsr"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("ill")}</th><td>#{CGI.escapeHTML(@producer.params["ill"].join(", "))}</td></tr>\n] unless @producer.params["ill"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("edt")}</th><td>#{CGI.escapeHTML(@producer.params["edt"].join(", "))}</td></tr>\n] unless @producer.params["edt"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("pbl")}</th><td>#{CGI.escapeHTML(@producer.params["pbl"].join(", "))}</td></tr>\n] unless @producer.params["pbl"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("prt")}</th><td>#{CGI.escapeHTML(@producer.params["prt"].join(", "))}</td></tr>\n] unless @producer.params["prt"].nil? | |
- s << %Q[ <tr><th>#{@producer.res.v("pht")}</th><td>#{CGI.escapeHTML(@producer.params["pht"].join(", "))}</td></tr>\n] unless @producer.params["pht"].nil? | |
+ @body << %Q[ <table class="colophon">\n] | |
+ @body << %w[aut csl trl dsr ill edt pbl prt pht].map{ |role| | |
+ if @producer.params[role] | |
+ %Q[ <tr><th>#{@producer.res.v(role)}</th><td>#{CGI.escapeHTML(@producer.params[role].join(", "))}</td></tr>\n] | |
+ else | |
+ "" | |
+ end | |
+ }.join("") | |
+ | |
if @producer.params["isbn"].to_s =~ /\A\d{10}\Z/ || @producer.params["isbn"].to_s =~ /\A\d{13}\Z/ | |
isbn = nil | |
str = @producer.params["isbn"].to_s | |
@@ -262,21 +252,23 @@ EOT | |
else | |
isbn = "#{str[0..2]}-#{str[3..3]}-#{str[4..8]}-#{str[9..11]}-#{str[12..12]}" | |
end | |
- s << %Q[ <tr><th>ISBN</th><td>#{isbn}</td></tr>\n] | |
+ @body << %Q[ <tr><th>ISBN</th><td>#{isbn}</td></tr>\n] | |
end | |
- s << <<EOT | |
- </table> | |
-EOT | |
+ @body << %Q[ </table>\n] | |
if [email protected]["rights"].nil? && @producer.params["rights"].size > 0 | |
- s << %Q[ <p class="copyright">#{@producer.params["rights"].join("<br />")}</p>] | |
+ @body << %Q[ <p class="copyright">#{@producer.params["rights"].join("<br />")}</p>] | |
end | |
+ @body << %Q[ </div>\n] | |
- s << <<EOT | |
- </div> | |
-</body> | |
-</html> | |
-EOT | |
- s | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
def date_to_s(date) | |
@@ -287,25 +279,24 @@ EOT | |
# Return own toc content. | |
def mytoc | |
- s = common_header | |
- s << <<EOT | |
- <title>#{@producer.res.v("toctitle")}</title> | |
-</head> | |
-<body> | |
- <h1 class="toc-title">#{@producer.res.v("toctitle")}</h1> | |
-EOT | |
+ @title = @producer.res.v("toctitle") | |
+ @body = %Q[ <h1 class="toc-title">#{@producer.res.v("toctitle")}</h1>\n] | |
if @producer.params["epubmaker"]["flattoc"].nil? | |
- s << hierarchy_ncx("ul") | |
+ @body << hierarchy_ncx("ul") | |
else | |
- s << flat_ncx("ul", @producer.params["epubmaker"]["flattocindent"]) | |
+ @body << flat_ncx("ul", @producer.params["epubmaker"]["flattocindent"]) | |
end | |
- s << <<EOT | |
-</body> | |
-</html> | |
-EOT | |
- s | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
def hierarchy_ncx(type) | |
@@ -394,7 +385,7 @@ EOT | |
File.open("#{tmpdir}/META-INF/container.xml", "w") {|f| @producer.container(f) } | |
FileUtils.mkdir_p("#{tmpdir}/OEBPS") | |
- File.open("#{tmpdir}/OEBPS/#{@producer.params["bookname"]}.opf", "w") {|f| @producer.opf(f) } | |
+ File.open(File.join(tmpdir, opf_path), "w") {|f| @producer.opf(f) } | |
if File.exist?("#{basedir}/#{@producer.params["cover"]}") | |
FileUtils.cp("#{basedir}/#{@producer.params["cover"]}", "#{tmpdir}/OEBPS") | |
@@ -417,21 +408,13 @@ EOT | |
end | |
def legacy_cover_and_title_file(loadfile, writefile) | |
- s = common_header | |
- s << <<EOT | |
- <title>#{@producer.params["booktitle"]}</title> | |
-</head> | |
-<body> | |
-EOT | |
+ @title = @producer.params["booktitle"] | |
+ s = "" | |
File.open(loadfile) do |f| | |
f.each_line do |l| | |
s << l | |
end | |
end | |
- s << <<EOT | |
-</body> | |
-</html> | |
-EOT | |
File.open(writefile, "w") do |f| | |
f.puts s | |
diff --git a/lib/epubmaker/epubv2.rb b/lib/epubmaker/epubv2.rb | |
index df3bc8f..4ee603a 100644 | |
--- a/lib/epubmaker/epubv2.rb | |
+++ b/lib/epubmaker/epubv2.rb | |
@@ -23,24 +23,14 @@ module EPUBMaker | |
# Return opf file content. | |
def opf | |
- s = <<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId"> | |
- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> | |
-EOT | |
- | |
- s << opf_metainfo | |
- s << opf_coverimage | |
- | |
- s << %Q[ </metadata>\n] | |
- | |
- s << opf_manifest | |
- s << opf_tocx | |
- s << opf_guide | |
- | |
- s << %Q[</package>\n] | |
- | |
- s | |
+ @opf_metainfo = opf_metainfo | |
+ @opf_coverimage = opf_coverimage | |
+ @opf_manifest = opf_manifest | |
+ @opf_toc = opf_tocx | |
+ | |
+ tmplfile = File.expand_path('./opf/epubv2.opf.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ return tmpl.result(binding) | |
end | |
def opf_metainfo | |
@@ -121,39 +111,15 @@ EOT | |
s | |
end | |
- def opf_guide | |
- s = "" | |
- s << %Q[ <guide>\n] | |
- s << %Q[ <reference type="cover" title="#{@producer.res.v("covertitle")}" href="#{@producer.params["cover"]}"/>\n] | |
- s << %Q[ <reference type="title-page" title="#{@producer.res.v("titlepagetitle")}" href="titlepage.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["titlepage"].nil? | |
- s << %Q[ <reference type="toc" title="#{@producer.res.v("toctitle")}" href="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["mytoc"].nil? | |
- s << %Q[ <reference type="colophon" title="#{@producer.res.v("colophontitle")}" href="colophon.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["colophon"].nil? | |
- s << %Q[ </guide>\n] | |
- s | |
- end | |
- | |
# Return ncx content. +indentarray+ has prefix marks for each level. | |
def ncx(indentarray) | |
- s = <<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> | |
- <head> | |
- <meta name="dtb:depth" content="1"/> | |
- <meta name="dtb:totalPageCount" content="0"/> | |
- <meta name="dtb:maxPageNumber" content="0"/> | |
-EOT | |
- s << ncx_isbn | |
+ @ncx_isbn = ncx_isbn | |
+ @ncx_doctitle = ncx_doctitle | |
+ @ncx_navmap = ncx_navmap(indentarray) | |
- s << <<EOT | |
- </head> | |
-EOT | |
- s << ncx_doctitle | |
- s << ncx_navmap(indentarray) | |
- | |
- s << <<EOT | |
-</ncx> | |
-EOT | |
- s | |
+ tmplfile = File.expand_path('./ncx/epubv2.ncx.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ return tmpl.result(binding) | |
end | |
# Produce EPUB file +epubfile+. | |
@@ -169,24 +135,5 @@ EOT | |
export_zip(tmpdir, epubfile) | |
end | |
- private | |
- | |
- # Return common XHTML headder | |
- def common_header | |
- s =<<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@producer.params["language"]}"> | |
-<head> | |
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> | |
- <meta http-equiv="Content-Style-Type" content="text/css"/> | |
- <meta name="generator" content="Re:VIEW"/> | |
-EOT | |
- | |
- @producer.params["stylesheet"].each do |file| | |
- s << %Q[ <link rel="stylesheet" type="text/css" href="#{file}"/>\n] | |
- end | |
- s | |
- end | |
end | |
end | |
diff --git a/lib/epubmaker/epubv3.rb b/lib/epubmaker/epubv3.rb | |
index 8455f17..a0d3acf 100644 | |
--- a/lib/epubmaker/epubv3.rb | |
+++ b/lib/epubmaker/epubv3.rb | |
@@ -22,23 +22,13 @@ module EPUBMaker | |
# Return opf file content. | |
def opf | |
- s = <<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="#{@producer.params["language"]}"> | |
- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> | |
-EOT | |
- | |
- s << opf_metainfo | |
- | |
- s << %Q[ </metadata>\n] | |
- | |
- s << opf_manifest | |
- s << opf_tocx | |
- s << opf_guide # same as ePUB2 | |
+ @opf_metainfo = opf_metainfo | |
+ @opf_manifest = opf_manifest | |
+ @opf_toc = opf_tocx | |
- s << %Q[</package>\n] | |
- | |
- s | |
+ tmplfile = File.expand_path('./opf/epubv3.opf.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ return tmpl.result(binding) | |
end | |
def opf_metainfo | |
@@ -155,7 +145,11 @@ EOT | |
end | |
s = "" | |
- s << %Q[ <spine>\n] | |
+ if @producer.params["direction"] | |
+ s << %Q[ <spine page-progression-direction="#{@producer.params["direction"]}">\n] | |
+ else | |
+ s << %Q[ <spine>\n] | |
+ end | |
s << %Q[ <itemref idref="#{@producer.params["bookname"]}" linear="#{cover_linear}"/>\n] | |
s << %Q[ <itemref idref="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}" />\n] if @producer.params["toc"] | |
@@ -168,38 +162,25 @@ EOT | |
s | |
end | |
- def opf_guide | |
- s = "" | |
- s << %Q[ <guide>\n] | |
- s << %Q[ <reference type="cover" title="#{@producer.res.v("covertitle")}" href="#{@producer.params["cover"]}"/>\n] | |
- s << %Q[ <reference type="title-page" title="#{@producer.res.v("titlepagetitle")}" href="titlepage.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["titlepage"].nil? | |
- s << %Q[ <reference type="toc" title="#{@producer.res.v("toctitle")}" href="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}"/>\n] | |
- s << %Q[ <reference type="colophon" title="#{@producer.res.v("colophontitle")}" href="colophon.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["colophon"].nil? | |
- s << %Q[ </guide>\n] | |
- s | |
- end | |
- | |
def ncx(indentarray) | |
- s = common_header | |
- s << <<EOT | |
- <title>#{@producer.res.v("toctitle")}</title> | |
-</head> | |
-<body> | |
- <nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc"> | |
- <h1 class="toc-title">#{@producer.res.v("toctitle")}</h1> | |
-EOT | |
- | |
if @producer.params["epubmaker"]["flattoc"].nil? | |
- s << hierarchy_ncx("ol") | |
+ ncx_main = hierarchy_ncx("ol") | |
else | |
- s << flat_ncx("ol", @producer.params["epubmaker"]["flattocindent"]) | |
+ ncx_main = flat_ncx("ol", @producer.params["epubmaker"]["flattocindent"]) | |
end | |
- s << <<EOT | |
- </nav> | |
-</body> | |
-</html> | |
+ | |
+ @body = <<EOT | |
+ <nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc"> | |
+ <h1 class="toc-title">#{@producer.res.v("toctitle")}</h1> | |
+#{ncx_main} </nav> | |
EOT | |
- s | |
+ | |
+ @title = @producer.res.v("toctitle") | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ return tmpl.result(binding) | |
end | |
# Produce EPUB file +epubfile+. | |
@@ -237,20 +218,5 @@ EOT | |
s | |
end | |
- def common_header | |
- s =<<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-<!DOCTYPE html> | |
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@producer.params["language"]}"> | |
-<head> | |
- <meta charset="UTF-8" /> | |
- <meta name="generator" content="Re:VIEW" /> | |
-EOT | |
- | |
- @producer.params["stylesheet"].each do |file| | |
- s << %Q[ <link rel="stylesheet" type="text/css" href="#{file}"/>\n] | |
- end | |
- s | |
- end | |
end | |
end | |
diff --git a/lib/epubmaker/producer.rb b/lib/epubmaker/producer.rb | |
index 51c9631..073f717 100644 | |
--- a/lib/epubmaker/producer.rb | |
+++ b/lib/epubmaker/producer.rb | |
@@ -54,6 +54,18 @@ module EPUBMaker | |
end | |
end | |
+ def coverimage | |
+ if !params["coverimage"] | |
+ return nil | |
+ end | |
+ @contents.each do |item| | |
+ if item.media =~ /\Aimage/ && item.file =~ /#{params["coverimage"]}\Z/ # / | |
+ return item.file | |
+ end | |
+ end | |
+ return nil | |
+ end | |
+ | |
# Update parameters by merging from new parameter hash +params+. | |
def merge_params(params) | |
@params = @params.merge(params) | |
diff --git a/lib/review/book/base.rb b/lib/review/book/base.rb | |
index 5af0a7c..6ff2cb5 100644 | |
--- a/lib/review/book/base.rb | |
+++ b/lib/review/book/base.rb | |
@@ -84,6 +84,14 @@ module ReVIEW | |
end | |
end | |
+ def htmlversion | |
+ if config["htmlversion"].blank? | |
+ nil | |
+ else | |
+ config["htmlversion"].to_i | |
+ end | |
+ end | |
+ | |
def parts | |
@parts ||= read_parts() | |
end | |
@@ -111,7 +119,7 @@ module ReVIEW | |
end | |
def each_chapter_r(&block) | |
- chapters.reverse.each(&block) | |
+ chapters.reverse_each(&block) | |
end | |
def chapter_index | |
@@ -217,12 +225,12 @@ module ReVIEW | |
end | |
def read_PART | |
- return @read_PART if @read_PART | |
+ return @read_part if @read_part | |
if catalog | |
- @read_PART = catalog.parts | |
+ @read_part = catalog.parts | |
else | |
- @read_PART = File.read("#{@basedir}/#{config["part_file"]}") | |
+ @read_part = File.read("#{@basedir}/#{config["part_file"]}") | |
end | |
end | |
diff --git a/lib/review/book/compilable.rb b/lib/review/book/compilable.rb | |
index 6c71bff..cc566f1 100644 | |
--- a/lib/review/book/compilable.rb | |
+++ b/lib/review/book/compilable.rb | |
@@ -44,7 +44,6 @@ module ReVIEW | |
@title = '' | |
open {|f| | |
f.each_line {|l| | |
- l = convert_inencoding(l, book.config["inencoding"]) | |
if l =~ /\A=+/ | |
@title = l.sub(/\A=+(\[.+?\])?(\{.+?\})?/, '').strip | |
break | |
@@ -74,8 +73,7 @@ module ReVIEW | |
attr_writer :content | |
def content | |
- @content = convert_inencoding(File.read(path()), | |
- book.config["inencoding"]) | |
+ @content = File.read(path()) | |
rescue | |
@content | |
end | |
diff --git a/lib/review/book/index.rb b/lib/review/book/index.rb | |
index d4c1bec..e41253a 100644 | |
--- a/lib/review/book/index.rb | |
+++ b/lib/review/book/index.rb | |
@@ -58,7 +58,7 @@ module ReVIEW | |
@index.fetch(id) | |
rescue | |
if @index.keys.map{|i| i.split(/\|/).last }.flatten. # unfold all ids | |
- reduce(Hash.new(0)){|h, i| h[i] += 1; h}. # number of occurrences | |
+ reduce(Hash.new(0)){|h, i| h[i] += 1; h}. # number of occurrences | |
select{|k, v| k == id && v > 1 }.present? # detect duplicated | |
raise KeyError, "key '#{id}' is ambiguous for #{self.class}" | |
end | |
@@ -172,7 +172,7 @@ module ReVIEW | |
attr_reader :id | |
attr_reader :number | |
attr_reader :caption | |
- attr_writer :index # internal use only | |
+ attr_writer :index # internal use only | |
def bound? | |
path | |
@@ -245,12 +245,12 @@ module ReVIEW | |
end | |
def title(id) | |
- sprintf(@locale["#{@index.item_type}_caption_format".intern], | |
+ sprintf(@locale["#{@index.item_type}_caption_format".to_sym], | |
@index.title(id)) | |
end | |
def number(id) | |
- sprintf(@locale["#{@index.item_type}_number_format".intern], | |
+ sprintf(@locale["#{@index.item_type}_number_format".to_sym], | |
@index.number(id)) | |
end | |
diff --git a/lib/review/builder.rb b/lib/review/builder.rb | |
index 5483562..332fc5c 100644 | |
--- a/lib/review/builder.rb | |
+++ b/lib/review/builder.rb | |
@@ -63,15 +63,11 @@ module ReVIEW | |
alias_method :raw_result, :result | |
def print(*s) | |
- @output.print(*s.map{|i| | |
- convert_outencoding(i, @book.config["outencoding"]) | |
- }) | |
+ @output.print(*s) | |
end | |
def puts(*s) | |
- @output.puts *s.map{|i| | |
- convert_outencoding(i, @book.config["outencoding"]) | |
- } | |
+ @output.puts(*s) | |
end | |
def target_name | |
@@ -380,7 +376,7 @@ module ReVIEW | |
line = self.unescape(lines.join("\n")) | |
cmds = { | |
:graphviz => "echo '#{line}' | dot -T#{image_ext} -o#{file_path}", | |
- :gnuplot => "echo 'set terminal " + | |
+ :gnuplot => "echo 'set terminal " + | |
"#{(image_ext == "eps") ? "postscript eps" : image_ext}\n" + | |
" set output \"#{file_path}\"\n#{line}' | gnuplot", | |
:blockdiag => "echo '#{line}' "+ | |
@@ -400,13 +396,12 @@ module ReVIEW | |
end | |
def inline_include(file_name) | |
- compile_inline convert_inencoding(File.open(file_name).read, | |
- @book.config["inencoding"]) | |
+ compile_inline File.open(file_name).read | |
end | |
def include(file_name) | |
File.foreach(file_name) do |line| | |
- paragraph([convert_inencoding(line, @book.config["inencoding"])]) | |
+ paragraph([line]) | |
end | |
end | |
@@ -443,4 +438,4 @@ module ReVIEW | |
end | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/compiler.rb b/lib/review/compiler.rb | |
index b944207..5c7f033 100644 | |
--- a/lib/review/compiler.rb | |
+++ b/lib/review/compiler.rb | |
@@ -362,7 +362,7 @@ module ReVIEW | |
elsif level < current_level # down | |
level_diff = current_level - level | |
level = current_level | |
- (1..(level_diff - 1)).to_a.reverse.each do |i| | |
+ (1..(level_diff - 1)).to_a.reverse_each do |i| | |
@strategy.ul_begin {i} | |
@strategy.ul_item_begin [] | |
end | |
@@ -371,7 +371,7 @@ module ReVIEW | |
elsif level > current_level # up | |
level_diff = level - current_level | |
level = current_level | |
- (1..level_diff).to_a.reverse.each do |i| | |
+ (1..level_diff).to_a.reverse_each do |i| | |
@strategy.ul_item_end | |
@strategy.ul_end {level + i} | |
end | |
@@ -381,7 +381,7 @@ module ReVIEW | |
end | |
end | |
- (1..level).to_a.reverse.each do |i| | |
+ (1..level).to_a.reverse_each do |i| | |
@strategy.ul_item_end | |
@strategy.ul_end {i} | |
end | |
@@ -424,7 +424,7 @@ module ReVIEW | |
def read_command(f) | |
line = f.gets | |
- name = line.slice(/[a-z]+/).intern | |
+ name = line.slice(/[a-z]+/).to_sym | |
args = parse_args(line.sub(%r<\A//[a-z]+>, '').rstrip.chomp('{'), name) | |
lines = block_open?(line) ? read_block(f) : nil | |
return name, args, lines | |
@@ -446,7 +446,7 @@ module ReVIEW | |
error "unexpected EOF (block begins at: #{head})" | |
return buf | |
end | |
- f.gets # discard terminator | |
+ f.gets # discard terminator | |
buf | |
end | |
@@ -524,7 +524,7 @@ module ReVIEW | |
rescue => err | |
error err.message | |
end | |
- public :text # called from strategy | |
+ public :text # called from strategy | |
def compile_inline(str) | |
op, arg = /\A@<(\w+)>\{(.*?)\}\z/.match(str).captures | |
@@ -550,4 +550,4 @@ module ReVIEW | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/configure.rb b/lib/review/configure.rb | |
index b42b0c3..a6955f8 100644 | |
--- a/lib/review/configure.rb | |
+++ b/lib/review/configure.rb | |
@@ -1,6 +1,9 @@ | |
# -*- coding: utf-8 -*- | |
module ReVIEW | |
class Configure < Hash | |
+ | |
+ attr_accessor :maker | |
+ | |
def self.values | |
Configure[ | |
# These parameters can be overridden by YAML file. | |
@@ -36,17 +39,26 @@ module ReVIEW | |
"language" => 'ja', # XXX default language should be JA?? | |
"chapter_file" => 'CHAPS', | |
- "part_file" => 'PART', | |
- "reject_file" => 'REJECT', | |
- "predef_file" => 'PREDEF', | |
+ "part_file" => 'PART', | |
+ "reject_file" => 'REJECT', | |
+ "predef_file" => 'PREDEF', | |
"postdef_file" => 'POSTDEF', | |
- "page_metric" => ReVIEW::Book::PageMetric.a5, | |
- "ext" => '.re', | |
- "image_dir" => 'images', | |
- "image_types" => %w( .ai .psd .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif .svg ), | |
- "bib_file" => "bib.re", | |
+ "page_metric" => ReVIEW::Book::PageMetric.a5, | |
+ "ext" => '.re', | |
+ "image_dir" => 'images', | |
+ "image_types" => %w( .ai .psd .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif .svg ), | |
+ "bib_file" => "bib.re", | |
"colophon_order" => %w(aut csl trl dsr ill cov edt pbl contact prt), | |
] | |
end | |
+ | |
+ def [](key) | |
+ if self.key?(key) | |
+ return self.fetch(key) | |
+ end | |
+ if @maker && self.key?(@maker) | |
+ return self.fetch(@maker).fetch(key, nil) | |
+ end | |
+ end | |
end | |
end | |
diff --git a/lib/review/epubbuilder.rb b/lib/review/epubbuilder.rb | |
index 2f2d5bf..0609ffa 100644 | |
--- a/lib/review/epubbuilder.rb | |
+++ b/lib/review/epubbuilder.rb | |
@@ -15,4 +15,4 @@ module ReVIEW | |
class EPUBBuilder < HTMLBuilder | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/epubmaker.rb b/lib/review/epubmaker.rb | |
index 12541e0..a6e65a1 100644 | |
--- a/lib/review/epubmaker.rb | |
+++ b/lib/review/epubmaker.rb | |
@@ -11,6 +11,7 @@ require 'review' | |
require 'rexml/document' | |
require 'rexml/streamlistener' | |
require 'epubmaker' | |
+require 'review/htmltoc' | |
module ReVIEW | |
class EPUBMaker | |
@@ -19,7 +20,7 @@ module ReVIEW | |
def initialize | |
@producer = nil | |
- @tochtmltxt = "toc-html.txt" | |
+ @htmltoc = nil | |
@buildlogtxt = "build-log.txt" | |
end | |
@@ -51,6 +52,7 @@ module ReVIEW | |
call_hook("hook_beforeprocess", basetmpdir) | |
+ @htmltoc = ReVIEW::HTMLToc.new(basetmpdir) | |
## copy all files into basetmpdir | |
copy_stylesheet(basetmpdir) | |
@@ -200,7 +202,7 @@ module ReVIEW | |
build_part(part, basetmpdir, htmlfile) | |
title = ReVIEW::I18n.t("part", part.number) | |
title += ReVIEW::I18n.t("chapter_postfix") + part.name.strip if part.name.strip.present? | |
- write_tochtmltxt(basetmpdir, "0\t#{htmlfile}\t#{title}\tchaptype=part") | |
+ @htmltoc.add_item(0, htmlfile, title, {:chaptype => "part"}) | |
write_buildlogtxt(basetmpdir, htmlfile, "") | |
end | |
end | |
@@ -215,21 +217,23 @@ module ReVIEW | |
def build_part(part, basetmpdir, htmlfile) | |
log("Create #{htmlfile} from a template.") | |
File.open("#{basetmpdir}/#{htmlfile}", "w") do |f| | |
- f.puts header(CGI.escapeHTML(@params["booktitle"])) | |
- f.puts <<EOT | |
-<div class="part"> | |
-<h1 class="part-number">#{ReVIEW::I18n.t("part", part.number)}</h1> | |
-EOT | |
+ @body = "" | |
+ @body << "<div class=\"part\">\n" | |
+ @body << "<h1 class=\"part-number\">#{ReVIEW::I18n.t("part", part.number)}</h1>\n" | |
if part.name.strip.present? | |
- f.puts <<EOT | |
-<h2 class="part-title">#{part.name.strip}</h2> | |
-EOT | |
+ @body << "<h2 class=\"part-title\">#{part.name.strip}</h2>\n" | |
end | |
+ @body << "</div>\n" | |
- f.puts <<EOT | |
-</div> | |
-EOT | |
- f.puts footer | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ f.write tmpl.result(binding) | |
end | |
end | |
@@ -320,51 +324,27 @@ EOT | |
headlines.each do |headline| | |
headline["level"] = 0 if ispart.present? && headline["level"] == 1 | |
if first.nil? | |
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}##{headline["id"]}\t#{headline["title"]}\tchaptype=#{chaptype}") | |
+ @htmltoc.add_item(headline["level"], filename+"#"+headline["id"], headline["title"], {:chaptype => chaptype}) | |
else | |
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}\t#{headline["title"]}\tforce_include=true,chaptype=#{chaptype}#{prop_str}") | |
+ @htmltoc.add_item(headline["level"], filename, headline["title"], {:force_include => true, :chaptype => chaptype+prop_str}) | |
first = nil | |
end | |
end | |
end | |
def push_contents(basetmpdir) | |
- File.open("#{basetmpdir}/#{@tochtmltxt}") do |f| | |
- f.each_line do |l| | |
- force_include = nil | |
- customid = nil | |
- chaptype = nil | |
- properties = nil | |
- level, file, title, custom = l.chomp.split("\t") | |
- if custom.present? | |
- # custom setting | |
- vars = custom.split(/,\s*/) | |
- vars.each do |var| | |
- k, v = var.split("=") | |
- case k | |
- when "id" | |
- customid = v | |
- when "force_include" | |
- force_include = true | |
- when "chaptype" | |
- chaptype = v | |
- when "properties" | |
- properties = v | |
- end | |
- end | |
- end | |
- next if level.to_i > @params["toclevel"] && force_include.nil? | |
- log("Push #{file} to ePUB contents.") | |
+ @htmltoc.each_item do |level, file, title, args| | |
+ next if level.to_i > @params["toclevel"] && args[:force_include].nil? | |
+ log("Push #{file} to ePUB contents.") | |
- hash = {"file" => file, "level" => level.to_i, "title" => title, "chaptype" => chaptype} | |
- if customid.present? | |
- hash["id"] = customid | |
- end | |
- if properties.present? | |
- hash["properties"] = properties.split(" ") | |
- end | |
- @producer.contents.push(Content.new(hash)) | |
+ hash = {"file" => file, "level" => level.to_i, "title" => title, "chaptype" => args[:chaptype]} | |
+ if args[:id].present? | |
+ hash["id"] = args[:id] | |
+ end | |
+ if args[:properties].present? | |
+ hash["properties"] = args[:properties].split(" ") | |
end | |
+ @producer.contents.push(Content.new(hash)) | |
end | |
end | |
@@ -386,55 +366,54 @@ EOT | |
else | |
FileUtils.cp(@params["titlefile"], "#{basetmpdir}/titlepage.#{@params["htmlext"]}") | |
end | |
- write_tochtmltxt(basetmpdir, "1\ttitlepage.#{@params["htmlext"]}\t#{@producer.res.v("titlepagetitle")}\tchaptype=pre") | |
+ @htmltoc.add_item(1, "titlepage.#{@params['htmlext']}", @producer.res.v("titlepagetitle"), {:chaptype => "pre"}) | |
end | |
if @params["originaltitlefile"].present? && File.exist?(@params["originaltitlefile"]) | |
FileUtils.cp(@params["originaltitlefile"], "#{basetmpdir}/#{File.basename(@params["originaltitlefile"])}") | |
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["originaltitlefile"])}\t#{@producer.res.v("originaltitle")}\tchaptype=pre") | |
+ @htmltoc.add_item(1, File.basename(@params["originaltitlefile"]), @producer.res.v("originaltitle"), {:chaptype => "pre"}) | |
end | |
if @params["creditfile"].present? && File.exist?(@params["creditfile"]) | |
FileUtils.cp(@params["creditfile"], "#{basetmpdir}/#{File.basename(@params["creditfile"])}") | |
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["creditfile"])}\t#{@producer.res.v("credittitle")}\tchaptype=pre") | |
+ @htmltoc.add_item(1, File.basename(@params["creditfile"]), @producer.res.v("credittitle"), {:chaptype => "pre"}) | |
end | |
end | |
def build_titlepage(basetmpdir, htmlfile) | |
File.open("#{basetmpdir}/#{htmlfile}", "w") do |f| | |
- f.puts header(CGI.escapeHTML(@params["booktitle"])) | |
- f.puts <<EOT | |
-<div class="titlepage"> | |
-<h1 class="tp-title">#{CGI.escapeHTML(@params["booktitle"])}</h1> | |
-EOT | |
- | |
+ @body = "" | |
+ @body << "<div class=\"titlepage\">" | |
+ @body << "<h1 class=\"tp-title\">#{CGI.escapeHTML(@params["booktitle"])}</h1>" | |
if @params["aut"] | |
- f.puts <<EOT | |
-<h2 class="tp-author">#{@params["aut"].join(", ")}</h2> | |
-EOT | |
+ @body << "<h2 class=\"tp-author\">#{@params["aut"].join(", ")}</h2>" | |
end | |
if @params["prt"] | |
- f.puts <<EOT | |
-<h3 class="tp-publisher">#{@params["prt"].join(", ")}</h3> | |
-EOT | |
+ @body << "<h3 class=\"tp-publisher\">#{@params["prt"].join(", ")}</h3>" | |
end | |
+ @body << "</div>" | |
- f.puts <<EOT | |
-</div> | |
-EOT | |
- f.puts footer | |
+ @language = @producer.params['language'] | |
+ @stylesheets = @producer.params["stylesheet"] | |
+ if @producer.params["htmlversion"].to_i == 5 | |
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ else | |
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR) | |
+ end | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ f.write tmpl.result(binding) | |
end | |
end | |
def copy_backmatter(basetmpdir) | |
if @params["profile"] | |
FileUtils.cp(@params["profile"], "#{basetmpdir}/#{File.basename(@params["profile"])}") | |
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["profile"])}\t#{@producer.res.v("profiletitle")}\tchaptype=post") | |
+ @htmltoc.add_item(1, File.basename(@params["profile"]), @producer.res.v("profiletitle"), {:chaptype => "post"}) | |
end | |
if @params["advfile"] | |
FileUtils.cp(@params["advfile"], "#{basetmpdir}/#{File.basename(@params["advfile"])}") | |
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["advfile"])}\t#{@producer.res.v("advtitle")}\tchaptype=post") | |
+ @htmltoc.add_item(1, File.basename(@params["advfile"]), @producer.res.v("advtitle"), {:chaptype => "post"}) | |
end | |
if @params["colophon"] | |
@@ -443,18 +422,12 @@ EOT | |
else | |
File.open("#{basetmpdir}/colophon.#{@params["htmlext"]}", "w") {|f| @producer.colophon(f) } | |
end | |
- write_tochtmltxt(basetmpdir, "1\tcolophon.#{@params["htmlext"]}\t#{@producer.res.v("colophontitle")}\tchaptype=post") | |
+ @htmltoc.add_item(1, "colophon.#{@params["htmlext"]}", @producer.res.v("colophontitle"), {:chaptype => "post"}) | |
end | |
if @params["backcover"] | |
FileUtils.cp(@params["backcover"], "#{basetmpdir}/#{File.basename(@params["backcover"])}") | |
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["backcover"])}\t#{@producer.res.v("backcovertitle")}\tchaptype=post") | |
- end | |
- end | |
- | |
- def write_tochtmltxt(basetmpdir, s) | |
- File.open("#{basetmpdir}/#{@tochtmltxt}", "a") do |f| | |
- f.puts s | |
+ @htmltoc.add_item(1, File.basename(@params["backcover"]), @producer.res.v("backcovertitle"), {:chaptype => "post"}) | |
end | |
end | |
@@ -464,49 +437,6 @@ EOT | |
end | |
end | |
- def header(title) | |
- # titleはすでにエスケープ済みと想定 | |
- s = <<EOT | |
-<?xml version="1.0" encoding="UTF-8"?> | |
-EOT | |
- if @params["htmlversion"] == 5 | |
- s << <<EOT | |
-<!DOCTYPE html> | |
-<html xml:lang='ja' xmlns:ops='http://www.idpf.org/2007/ops' xmlns='http://www.w3.org/1999/xhtml'> | |
-<head> | |
- <meta charset="UTF-8" /> | |
-EOT | |
- else | |
- s << <<EOT | |
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
-<html xml:lang='ja' xmlns:ops='http://www.idpf.org/2007/ops' xmlns='http://www.w3.org/1999/xhtml'> | |
-<head> | |
- <meta http-equiv='Content-Type' content='text/html;charset=UTF-8' /> | |
- <meta http-equiv='Content-Style-Type' content='text/css' /> | |
-EOT | |
- end | |
- if @params["stylesheet"].size > 0 | |
- @params["stylesheet"].each do |sfile| | |
- s << <<EOT | |
- <link rel='stylesheet' type='text/css' href='#{sfile}' /> | |
-EOT | |
- end | |
- end | |
- s << <<EOT | |
- <meta content='Re:VIEW' name='generator'/> | |
- <title>#{title}</title> | |
-</head> | |
-<body> | |
-EOT | |
- end | |
- | |
- def footer | |
- <<EOT | |
-</body> | |
-</html> | |
-EOT | |
- end | |
- | |
class ReVIEWHeaderListener | |
include REXML::StreamListener | |
def initialize(headlines) | |
diff --git a/lib/review/ewbbuilder.rb b/lib/review/ewbbuilder.rb | |
index 3861961..fd65e10 100644 | |
--- a/lib/review/ewbbuilder.rb | |
+++ b/lib/review/ewbbuilder.rb | |
@@ -62,7 +62,7 @@ module ReVIEW | |
lines.each do |line| | |
if noescape | |
puts detab(line) | |
- elsif /\AC:.*?>(.+)/ =~ line # DOS prompt hack | |
+ elsif /\AC:.*?>(.+)/ =~ line # DOS prompt hack | |
prompt, cmd = *line.split('>', 2) | |
puts "#{escape(prompt)}>//command{#{escape(cmd)}}//}" | |
else | |
@@ -198,7 +198,7 @@ module ReVIEW | |
# FIXME | |
end | |
- Z_SPACE = "\241\241" # zen-kaku space in EUC-JP | |
+ Z_SPACE = "\241\241" # zen-kaku space in EUC-JP | |
def paragraph(lines) | |
if @noindent | |
@@ -263,10 +263,10 @@ module ReVIEW | |
if abbr | |
add_index(word) + "//g{#{word}//}" + | |
add_index(abbr) + "(#{abbr}, " + | |
- add_index(eng) + "#{eng})" | |
+ add_index(eng) + "#{eng})" | |
elsif eng | |
add_index(word) + "//g{#{word}//}" + | |
- add_index(eng) + "(#{eng})" | |
+ add_index(eng) + "(#{eng})" | |
else | |
add_index(word) + "//g{#{word}//}" | |
end | |
diff --git a/lib/review/exception.rb b/lib/review/exception.rb | |
index 8940325..3669442 100644 | |
--- a/lib/review/exception.rb | |
+++ b/lib/review/exception.rb | |
@@ -17,5 +17,5 @@ module ReVIEW | |
class CompileError < ApplicationError; end | |
class SyntaxError < CompileError; end | |
class FileNotFound < ApplicationError; end | |
- class KeyError < CompileError; end | |
+ class KeyError < CompileError; end | |
end | |
diff --git a/lib/review/htmlbuilder.rb b/lib/review/htmlbuilder.rb | |
index b8e11d0..2a1c89d 100644 | |
--- a/lib/review/htmlbuilder.rb | |
+++ b/lib/review/htmlbuilder.rb | |
@@ -70,7 +70,7 @@ module ReVIEW | |
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0 | |
warn "user's layout is prohibited in safe mode. ignored." | |
else | |
- title = convert_outencoding(strip_html(compile_inline(@chapter.title)), @book.config["outencoding"]) | |
+ title = strip_html(compile_inline(@chapter.title)) | |
toc = "" | |
toc_level = 0 | |
@@ -101,44 +101,21 @@ module ReVIEW | |
end | |
# default XHTML header/footer | |
- header = <<EOT | |
-<?xml version="1.0" encoding="#{@book.config["outencoding"] || "UTF-8"}"?> | |
-EOT | |
- if @book.config["htmlversion"].to_i == 5 | |
- header += <<EOT | |
-<!DOCTYPE html> | |
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:#{xmlns_ops_prefix}="http://www.idpf.org/2007/ops" xml:lang="#{@book.config["language"]}"> | |
-<head> | |
- <meta charset="#{@book.config["outencoding"] || "UTF-8"}" /> | |
-EOT | |
+ @error_messages = error_messages | |
+ @warning_messages = warning_messages | |
+ @title = strip_html(compile_inline(@chapter.title)) | |
+ @body = @output.string | |
+ @language = @book.config['language'] | |
+ @stylesheets = @book.config["stylesheet"] | |
+ | |
+ if @book.htmlversion == 5 | |
+ htmlfilename = "layout-html5.html.erb" | |
else | |
- header += <<EOT | |
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@book.config["language"]}"> | |
-<head> | |
- <meta http-equiv="Content-Type" content="text/html;charset=#{@book.config["outencoding"] || "UTF-8"}" /> | |
- <meta http-equiv="Content-Style-Type" content="text/css" /> | |
-EOT | |
- end | |
- | |
- unless @book.config["stylesheet"].nil? | |
- @book.config["stylesheet"].each do |style| | |
- header += <<EOT | |
- <link rel="stylesheet" type="text/css" href="#{style}" /> | |
-EOT | |
- end | |
+ htmlfilename = "layout-xhtml1.html.erb" | |
end | |
- header += <<EOT | |
- <meta name="generator" content="Re:VIEW" /> | |
- <title>#{convert_outencoding(strip_html(compile_inline(@chapter.title)), @book.config["outencoding"])}</title> | |
-</head> | |
-<body> | |
-EOT | |
- footer = <<EOT | |
-</body> | |
-</html> | |
-EOT | |
- header + messages() + convert_outencoding(@output.string, @book.config["outencoding"]) + footer | |
+ tmplfile = File.expand_path('./html/'+htmlfilename, ReVIEW::Template::TEMPLATE_DIR) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ tmpl.result(binding) | |
end | |
def xmlns_ops_prefix | |
@@ -177,7 +154,7 @@ EOT | |
"<ul>\n" + | |
@errors.map {|file, line, msg| | |
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n" | |
- }.join('') + | |
+ }.join('') + | |
"</ul>\n" | |
end | |
@@ -373,7 +350,7 @@ EOT | |
def ol_begin | |
if @ol_num | |
- puts "<ol start=\"#{@ol_num}\">" ## it's OK in HTML5, but not OK in XHTML1.1 | |
+ puts "<ol start=\"#{@ol_num}\">" ## it's OK in HTML5, but not OK in XHTML1.1 | |
@ol_num = nil | |
else | |
puts '<ol>' | |
@@ -490,10 +467,18 @@ EOT | |
end | |
def listnum_body(lines, lang) | |
- body = lines.inject(''){|i, j| i + detab(j) + "\n"} | |
- lexer = lang | |
- puts highlight(:body => body, :lexer => lexer, :format => 'html', | |
- :options => {:linenos => 'inline', :nowrap => false}) | |
+ if highlight? | |
+ body = lines.inject(''){|i, j| i + detab(j) + "\n"} | |
+ lexer = lang | |
+ puts highlight(:body => body, :lexer => lexer, :format => 'html', | |
+ :options => {:linenos => 'inline', :nowrap => false}) | |
+ else | |
+ print '<pre class="list">' | |
+ lines.each_with_index do |line, i| | |
+ puts detab((i+1).to_s.rjust(2) + ": " + line) | |
+ end | |
+ puts '</pre>' | |
+ end | |
end | |
def emlist(lines, caption = nil, lang = nil) | |
@@ -514,10 +499,20 @@ EOT | |
if caption.present? | |
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) | |
end | |
- body = lines.inject(''){|i, j| i + detab(j) + "\n"} | |
- lexer = lang | |
- puts highlight(:body => body, :lexer => lexer, :format => 'html', | |
- :options => {:linenos => 'inline', :nowrap => false}) | |
+ | |
+ if highlight? | |
+ body = lines.inject(''){|i, j| i + detab(j) + "\n"} | |
+ lexer = lang | |
+ puts highlight(:body => body, :lexer => lexer, :format => 'html', | |
+ :options => {:linenos => 'inline', :nowrap => false}) | |
+ else | |
+ print '<pre class="emlist">' | |
+ lines.each_with_index do |line, i| | |
+ puts detab((i+1).to_s.rjust(2) + ": " + line) | |
+ end | |
+ puts '</pre>' | |
+ end | |
+ | |
puts '</div>' | |
end | |
@@ -830,7 +825,7 @@ QUOTE | |
end | |
def compile_ruby(base, ruby) | |
- if @book.config["htmlversion"].to_i == 5 | |
+ if @book.htmlversion == 5 | |
%Q[<ruby>#{escape_html(base)}<rp>#{I18n.t("ruby_prefix")}</rp><rt>#{escape_html(ruby)}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>] | |
else | |
%Q[<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>] | |
@@ -863,7 +858,7 @@ QUOTE | |
end | |
def inline_tti(str) | |
- if @book.config["htmlversion"].to_i == 5 | |
+ if @book.htmlversion == 5 | |
%Q(<code class="tt"><i>#{escape_html(str)}</i></code>) | |
else | |
%Q(<tt><i>#{escape_html(str)}</i></tt>) | |
@@ -871,7 +866,7 @@ QUOTE | |
end | |
def inline_ttb(str) | |
- if @book.config["htmlversion"].to_i == 5 | |
+ if @book.htmlversion == 5 | |
%Q(<code class="tt"><b>#{escape_html(str)}</b></code>) | |
else | |
%Q(<tt><b>#{escape_html(str)}</b></tt>) | |
@@ -883,7 +878,7 @@ QUOTE | |
end | |
def inline_code(str) | |
- if @book.config["htmlversion"].to_i == 5 | |
+ if @book.htmlversion == 5 | |
%Q(<code class="inline-code tt">#{escape_html(str)}</code>) | |
else | |
%Q(<tt class="inline-code">#{escape_html(str)}</tt>) | |
@@ -939,7 +934,7 @@ QUOTE | |
end | |
def inline_bib(id) | |
- %Q(<a href="#{@book.bib_file.gsub(/re\Z/, "html")}#bib-#{normalize_id(id)}">[#{@chapter.bibpaper(id).number}]</a>) | |
+ %Q(<a href="#{@book.bib_file.gsub(/\.re\Z/, ".#{@book.config['htmlext']}")}#bib-#{normalize_id(id)}">[#{@chapter.bibpaper(id).number}]</a>) | |
end | |
def inline_hd_chap(chap, id) | |
@@ -1079,7 +1074,7 @@ QUOTE | |
end | |
def inline_tt(str) | |
- if @book.config["htmlversion"].to_i == 5 | |
+ if @book.htmlversion == 5 | |
%Q(<code class="tt">#{escape_html(str)}</code>) | |
else | |
%Q(<tt>#{escape_html(str)}</tt>) | |
@@ -1159,4 +1154,4 @@ QUOTE | |
end | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/htmltoc.rb b/lib/review/htmltoc.rb | |
new file mode 100644 | |
index 0000000..7defa87 | |
--- /dev/null | |
+++ b/lib/review/htmltoc.rb | |
@@ -0,0 +1,45 @@ | |
+require 'review' | |
+module ReVIEW | |
+ class HTMLToc | |
+ def initialize(basedir) | |
+ @tochtmltxt = "toc-html.txt" | |
+ @basedir = basedir | |
+ end | |
+ | |
+ def add_item(level, filename, title, args) | |
+ args_str = encode_args(args) | |
+ line = [level, filename, title, args_str].join("\t") | |
+ File.open(tocfilename, "a") do |f| | |
+ f.write "#{line}\n" | |
+ end | |
+ end | |
+ | |
+ def each_item | |
+ File.open(tocfilename) do |f| | |
+ f.each_line do |line| | |
+ level, file, title, args_str = line.chomp.split("\t") | |
+ args = decode_args(args_str) | |
+ yield level, file, title, args | |
+ end | |
+ end | |
+ end | |
+ | |
+ def tocfilename | |
+ File.join(@basedir, @tochtmltxt) | |
+ end | |
+ | |
+ def decode_args(args_str) | |
+ args = Hash.new | |
+ args_str.split(/,\s*/).each do |pair| | |
+ key, val = pair.split("=") | |
+ args[key.to_sym] = val | |
+ end | |
+ args | |
+ end | |
+ | |
+ def encode_args(args) | |
+ args.map{|k,v| "#{k}=#{v}"}.join(",") | |
+ end | |
+ end | |
+end | |
+ | |
diff --git a/lib/review/htmlutils.rb b/lib/review/htmlutils.rb | |
index 031e24a..1ddccdb 100644 | |
--- a/lib/review/htmlutils.rb | |
+++ b/lib/review/htmlutils.rb | |
@@ -40,7 +40,7 @@ module ReVIEW | |
str.gsub('-', '-') | |
end | |
- def highlight_pygments? | |
+ def highlight? | |
@book.config["pygments"].present? || | |
@book.config["highlight"] && @book.config["highlight"]["html"] == "pygments" | |
end | |
@@ -58,7 +58,7 @@ module ReVIEW | |
if ops[:options] && ops[:options].kind_of?(Hash) | |
options.merge!(ops[:options]) | |
end | |
- return body if !highlight_pygments? | |
+ return body if !highlight? | |
begin | |
require 'pygments' | |
@@ -87,4 +87,4 @@ module ReVIEW | |
end | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/i18n.rb b/lib/review/i18n.rb | |
index e8344ef..a398827 100644 | |
--- a/lib/review/i18n.rb | |
+++ b/lib/review/i18n.rb | |
@@ -38,7 +38,7 @@ module ReVIEW | |
end | |
class << self | |
- alias v t ## for EPUBMaker backward compatibility | |
+ alias_method :v, :t ## for EPUBMaker backward compatibility | |
end | |
def self.update(user_i18n, locale = nil) | |
@@ -65,7 +65,11 @@ module ReVIEW | |
locale = user_i18n["locale"] | |
if locale | |
user_i18n.delete("locale") | |
- @store[locale].merge!(user_i18n) | |
+ if @store[locale] | |
+ @store[locale].merge!(user_i18n) | |
+ else | |
+ @store[locale] = user_i18n | |
+ end | |
else | |
user_i18n.each do |key, values| | |
raise KeyError, "Invalid locale file: #{path}" unless values.kind_of? Hash | |
diff --git a/lib/review/i18n.yml b/lib/review/i18n.yml | |
index 8de4d0d..17b89cd 100644 | |
--- a/lib/review/i18n.yml | |
+++ b/lib/review/i18n.yml | |
@@ -116,7 +116,7 @@ en: | |
profiletitle: "Profile" | |
backcovertitle: "Back Cover" | |
-zh_TW: | |
+zh-TW: | |
image: 圖 | |
table: 表 | |
list: List | |
diff --git a/lib/review/idgxmlbuilder.rb b/lib/review/idgxmlbuilder.rb | |
index 8c07bb1..31e2105 100644 | |
--- a/lib/review/idgxmlbuilder.rb | |
+++ b/lib/review/idgxmlbuilder.rb | |
@@ -541,7 +541,7 @@ module ReVIEW | |
totallength = 0 | |
cellwidth.size.times do |n| | |
cellwidth[n] = cellwidth[n].to_f / 0.351 # mm -> pt | |
- totallength = totallength + cellwidth[n] | |
+ totallength += cellwidth[n] | |
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth | |
end | |
if cellwidth.size < col | |
@@ -1084,7 +1084,7 @@ module ReVIEW | |
lines.each do |l| | |
print l.gsub("<", "<").gsub(">", ">").gsub(""", "\"").gsub("&", "&") | |
print "\n" unless lines.length == no | |
- no = no + 1 | |
+ no += 1 | |
end | |
end | |
@@ -1095,8 +1095,7 @@ module ReVIEW | |
def inline_chapref(id) | |
chs = ["", "「", "」"] | |
unless @book.config["chapref"].nil? | |
- _chs = convert_inencoding(@book.config["chapref"], | |
- @book.config["inencoding"]).split(",") | |
+ _chs = @book.config["chapref"].split(",") | |
if _chs.size != 3 | |
error "--chapsplitter must have exactly 3 parameters with comma." | |
else | |
@@ -1195,4 +1194,4 @@ module ReVIEW | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/inaobuilder.rb b/lib/review/inaobuilder.rb | |
index 3ef68d0..06d5d8b 100644 | |
--- a/lib/review/inaobuilder.rb | |
+++ b/lib/review/inaobuilder.rb | |
@@ -352,4 +352,4 @@ module ReVIEW | |
end | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb | |
index 0818692..4e021f6 100644 | |
--- a/lib/review/latexbuilder.rb | |
+++ b/lib/review/latexbuilder.rb | |
@@ -505,7 +505,7 @@ module ReVIEW | |
def th(s) | |
## use shortstack for @<br> | |
- if /\\\\/i =~ s | |
+ if /\\\\/i =~ s | |
macro('reviewth', macro('shortstack[l]', s)) | |
else | |
macro('reviewth', s) | |
@@ -514,7 +514,7 @@ module ReVIEW | |
def td(s) | |
## use shortstack for @<br> | |
- if /\\\\/ =~ s | |
+ if /\\\\/ =~ s | |
macro('shortstack[l]', s) | |
else | |
s | |
diff --git a/lib/review/latexutils.rb b/lib/review/latexutils.rb | |
index 1df738b..532b373 100644 | |
--- a/lib/review/latexutils.rb | |
+++ b/lib/review/latexutils.rb | |
@@ -17,18 +17,18 @@ module ReVIEW | |
module LaTeXUtils | |
METACHARS = { | |
- '#' => '\#', | |
- "$" => '\textdollar{}', | |
+ '#' => '\#', | |
+ "$" => '\textdollar{}', | |
'%' => '\%', | |
'&' => '\&', | |
'{' => '\{', | |
'}' => '\}', | |
- '_' => '\textunderscore{}', | |
+ '_' => '\textunderscore{}', | |
'^' => '\textasciicircum{}', | |
'~' => '\textasciitilde{}', | |
'|' => '\textbar{}', | |
- '<' => '\textless{}', | |
- '>' => '\textgreater{}', | |
+ '<' => '\textless{}', | |
+ '>' => '\textgreater{}', | |
"\\" => '\reviewbackslash{}', | |
"-" => '{-}', | |
@@ -70,7 +70,7 @@ module ReVIEW | |
alias_method :escape, :escape_latex | |
def unescape_latex(str) | |
- metachars_invert_re = Regexp.new(METACHARS_INVERT.keys.collect{|key| Regexp.escape(key)}.join('|')) | |
+ metachars_invert_re = Regexp.new(METACHARS_INVERT.keys.collect{|key| Regexp.escape(key)}.join('|')) | |
str.gsub(metachars_invert_re) {|s| | |
METACHARS_INVERT[s] or raise "unknown trans char: #{s}" | |
} | |
diff --git a/lib/review/markdownbuilder.rb b/lib/review/markdownbuilder.rb | |
index 445510a..b777bac 100644 | |
--- a/lib/review/markdownbuilder.rb | |
+++ b/lib/review/markdownbuilder.rb | |
@@ -51,9 +51,9 @@ module ReVIEW | |
def list_header(id, caption, lang) | |
if get_chap.nil? | |
- puts %Q[リスト#{@chapter.list(id).number} #{compile_inline(caption)}] | |
+ print %Q[リスト#{@chapter.list(id).number} #{compile_inline(caption)}\n\n] | |
else | |
- puts %Q[リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}] | |
+ print %Q[リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}\n\n] | |
end | |
lang ||= "" | |
puts "```#{lang}" | |
@@ -103,6 +103,7 @@ module ReVIEW | |
blank | |
if caption | |
puts caption | |
+ print "\n" | |
end | |
lang ||= "" | |
puts "```#{lang}" | |
@@ -274,4 +275,4 @@ module ReVIEW | |
end | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/pdfmaker.rb b/lib/review/pdfmaker.rb | |
index 7a3bb5c..6b15374 100644 | |
--- a/lib/review/pdfmaker.rb | |
+++ b/lib/review/pdfmaker.rb | |
@@ -22,6 +22,8 @@ module ReVIEW | |
include FileUtils | |
include ReVIEW::LaTeXUtils | |
+ attr_accessor :config, :basedir | |
+ | |
def initialize | |
@basedir = Dir.pwd | |
end | |
@@ -39,13 +41,16 @@ module ReVIEW | |
$stderr.puts "#{File.basename($0, '.*')}: warning: #{msg}" | |
end | |
- def check_book(config) | |
- pdf_file = config["bookname"]+".pdf" | |
- File.unlink(pdf_file) if File.exist?(pdf_file) | |
+ def pdf_filepath | |
+ File.join(@basedir, @config["bookname"]+".pdf") | |
+ end | |
+ | |
+ def remove_old_file | |
+ FileUtils.rm_f(pdf_filepath) | |
end | |
- def build_path(config) | |
- "./#{config["bookname"]}-pdf" | |
+ def build_path | |
+ "./#{@config["bookname"]}-pdf" | |
end | |
def check_compile_status(ignore_errors) | |
@@ -89,31 +94,30 @@ module ReVIEW | |
end | |
def execute(*args) | |
- config = ReVIEW::Configure.values | |
+ @config = ReVIEW::Configure.values | |
cmd_config, yamlfile = parse_opts(args) | |
- config.merge!(YAML.load_file(yamlfile)) | |
+ @config.merge!(YAML.load_file(yamlfile)) | |
# YAML configs will be overridden by command line options. | |
- config.merge!(cmd_config) | |
- I18n.setup(config["language"]) | |
- generate_pdf(config, yamlfile) | |
+ @config.merge!(cmd_config) | |
+ I18n.setup(@config["language"]) | |
+ generate_pdf(yamlfile) | |
end | |
- def generate_pdf(config, yamlfile) | |
- check_book(config) | |
- @path = build_path(config) | |
- bookname = config["bookname"] | |
+ def generate_pdf(yamlfile) | |
+ remove_old_file | |
+ @path = build_path() | |
Dir.mkdir(@path) | |
@chaps_fnames = Hash.new{|h, key| h[key] = ""} | |
@compile_errors = nil | |
book = ReVIEW::Book.load(@basedir) | |
- book.config = config | |
+ book.config = @config | |
book.parts.each do |part| | |
if part.name.present? | |
if part.file? | |
- output_chaps(part.name, config, yamlfile) | |
+ output_chaps(part.name, yamlfile) | |
@chaps_fnames["CHAPS"] << %Q|\\input{#{part.name}.tex}\n| | |
else | |
@chaps_fnames["CHAPS"] << %Q|\\part{#{part.name}}\n| | |
@@ -122,40 +126,39 @@ module ReVIEW | |
part.chapters.each do |chap| | |
filename = File.basename(chap.path, ".*") | |
- output_chaps(filename, config, yamlfile) | |
- @chaps_fnames["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF? | |
- @chaps_fnames["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS? | |
+ output_chaps(filename, yamlfile) | |
+ @chaps_fnames["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF? | |
+ @chaps_fnames["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS? | |
@chaps_fnames["APPENDIX"] << "\\input{#{filename}.tex}\n" if chap.on_APPENDIX? | |
@chaps_fnames["POSTDEF"] << "\\input{#{filename}.tex}\n" if chap.on_POSTDEF? | |
end | |
end | |
- check_compile_status(config["ignore-errors"]) | |
+ check_compile_status(@config["ignore-errors"]) | |
- config["pre_str"] = @chaps_fnames["PREDEF"] | |
- config["chap_str"] = @chaps_fnames["CHAPS"] | |
- config["appendix_str"] = @chaps_fnames["APPENDIX"] | |
- config["post_str"] = @chaps_fnames["POSTDEF"] | |
+ @config["pre_str"] = @chaps_fnames["PREDEF"] | |
+ @config["chap_str"] = @chaps_fnames["CHAPS"] | |
+ @config["appendix_str"] = @chaps_fnames["APPENDIX"] | |
+ @config["post_str"] = @chaps_fnames["POSTDEF"] | |
- config["usepackage"] = "" | |
- if config["texstyle"] | |
- config["usepackage"] = "\\usepackage{#{config['texstyle']}}" | |
+ @config["usepackage"] = "" | |
+ if @config["texstyle"] | |
+ @config["usepackage"] = "\\usepackage{#{@config['texstyle']}}" | |
end | |
- copy_images("./images", "#{@path}/images") | |
- copyStyToDir(Dir.pwd + "/sty", @path) | |
- copyStyToDir(Dir.pwd + "/sty", @path, "fd") | |
- copyStyToDir(Dir.pwd + "/sty", @path, "cls") | |
+ copy_images("./images", File.join(@path, "images")) | |
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path) | |
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path, "fd") | |
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path, "cls") | |
copyStyToDir(Dir.pwd, @path, "tex") | |
- Dir.chdir(@path) { | |
- template = get_template(config) | |
+ Dir.chdir(@path) do | |
+ template = get_template | |
File.open("./book.tex", "wb"){|f| f.write(template)} | |
- call_hook("hook_beforetexcompile", config) | |
+ call_hook("hook_beforetexcompile") | |
## do compile | |
- enc = config["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ } | |
kanji = 'utf8' | |
texcommand = "platex" | |
texoptions = "-kanji=#{kanji}" | |
@@ -165,36 +168,32 @@ module ReVIEW | |
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0 | |
warn "command configuration is prohibited in safe mode. ignored." | |
else | |
- texcommand = config["texcommand"] if config["texcommand"] | |
- dvicommand = config["dvicommand"] if config["dvicommand"] | |
- dvioptions = config["dvioptions"] if config["dvioptions"] | |
- if enc | |
- kanji = enc.split(/\=/).last.gsub(/-/, '').downcase | |
- texoptions = "-kanji=#{kanji}" | |
- end | |
- texoptions = config["texoptions"] if config["texoptions"] | |
+ texcommand = @config["texcommand"] if @config["texcommand"] | |
+ dvicommand = @config["dvicommand"] if @config["dvicommand"] | |
+ dvioptions = @config["dvioptions"] if @config["dvioptions"] | |
+ texoptions = @config["texoptions"] if @config["texoptions"] | |
end | |
3.times do | |
system_or_raise("#{texcommand} #{texoptions} book.tex") | |
end | |
- call_hook("hook_aftertexcompile", config) | |
+ call_hook("hook_aftertexcompile") | |
- if File.exist?("book.dvi") | |
+ if File.exist?("book.dvi") | |
system_or_raise("#{dvicommand} #{dvioptions} book.dvi") | |
end | |
- } | |
- call_hook("hook_afterdvipdf", config) | |
- | |
- FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf") | |
+ end | |
+ call_hook("hook_afterdvipdf") | |
+ | |
+ FileUtils.cp(File.join(@path, "book.pdf"), pdf_filepath) | |
- unless config["debug"] | |
+ unless @config["debug"] | |
remove_entry_secure @path | |
end | |
end | |
- def output_chaps(filename, config, yamlfile) | |
+ def output_chaps(filename, yamlfile) | |
$stderr.puts "compiling #{filename}.tex" | |
- cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename}.re > #{@path}/#{filename}.tex" | |
+ cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=latex --level=#{@config["secnolevel"]} --toclevel=#{@config["toclevel"]} #{@config["params"]} #{filename}.re > #{@path}/#{filename}.tex" | |
if system cmd | |
# OK | |
else | |
@@ -203,6 +202,8 @@ module ReVIEW | |
end | |
end | |
+ # PDFMaker#copy_images should copy image files _AND_ execute extractbb (or ebb). | |
+ # | |
def copy_images(from, to) | |
if File.exist?(from) | |
Dir.mkdir(to) | |
@@ -237,57 +238,57 @@ module ReVIEW | |
end | |
end | |
- def make_colophon_role(role, config) | |
- if config[role].present? | |
- return "#{ReVIEW::I18n.t(role)} & #{escape_latex(join_with_separator(config[role], ReVIEW::I18n.t("names_splitter")))} \\\\\n" | |
+ def make_colophon_role(role) | |
+ if @config[role].present? | |
+ return "#{ReVIEW::I18n.t(role)} & #{escape_latex(join_with_separator(@config[role], ReVIEW::I18n.t("names_splitter")))} \\\\\n" | |
else | |
"" | |
end | |
end | |
- def make_colophon(config) | |
+ def make_colophon | |
colophon = "" | |
- config["colophon_order"].each do |role| | |
- colophon += make_colophon_role(role, config) | |
+ @config["colophon_order"].each do |role| | |
+ colophon += make_colophon_role(role) | |
end | |
colophon | |
end | |
- def make_authors(config) | |
+ def make_authors | |
authors = "" | |
- if config["aut"].present? | |
- author_names = join_with_separator(config["aut"], ReVIEW::I18n.t("names_splitter")) | |
+ if @config["aut"].present? | |
+ author_names = join_with_separator(@config["aut"], ReVIEW::I18n.t("names_splitter")) | |
authors = ReVIEW::I18n.t("author_with_label", author_names) | |
end | |
- if config["csl"].present? | |
- csl_names = join_with_separator(config["csl"], ReVIEW::I18n.t("names_splitter")) | |
+ if @config["csl"].present? | |
+ csl_names = join_with_separator(@config["csl"], ReVIEW::I18n.t("names_splitter")) | |
authors += " \\\\\n"+ ReVIEW::I18n.t("supervisor_with_label", csl_names) | |
end | |
- if config["trl"].present? | |
- trl_names = join_with_separator(config["trl"], ReVIEW::I18n.t("names_splitter")) | |
+ if @config["trl"].present? | |
+ trl_names = join_with_separator(@config["trl"], ReVIEW::I18n.t("names_splitter")) | |
authors += " \\\\\n"+ ReVIEW::I18n.t("translator_with_label", trl_names) | |
end | |
authors | |
end | |
- def get_template(config) | |
- dclass = config["texdocumentclass"] || [] | |
- documentclass = dclass[0] || "jsbook" | |
- documentclassoption = dclass[1] || "oneside" | |
+ def get_template | |
+ dclass = @config["texdocumentclass"] || [] | |
+ documentclass = dclass[0] || "jsbook" | |
+ documentclassoption = dclass[1] || "oneside" | |
- okuduke = make_colophon(config) | |
- authors = make_authors(config) | |
+ okuduke = make_colophon | |
+ authors = make_authors | |
- custom_titlepage = make_custom_page(config["cover"]) || make_custom_page(config["coverfile"]) | |
- custom_originaltitlepage = make_custom_page(config["originaltitlefile"]) | |
- custom_creditpage = make_custom_page(config["creditfile"]) | |
+ custom_titlepage = make_custom_page(@config["cover"]) || make_custom_page(@config["coverfile"]) | |
+ custom_originaltitlepage = make_custom_page(@config["originaltitlefile"]) | |
+ custom_creditpage = make_custom_page(@config["creditfile"]) | |
- custom_profilepage = make_custom_page(config["profile"]) | |
- custom_advfilepage = make_custom_page(config["advfile"]) | |
- if config["colophon"] && config["colophon"].kind_of?(String) | |
- custom_colophonpage = make_custom_page(config["colophon"]) | |
+ custom_profilepage = make_custom_page(@config["profile"]) | |
+ custom_advfilepage = make_custom_page(@config["advfile"]) | |
+ if @config["colophon"] && @config["colophon"].kind_of?(String) | |
+ custom_colophonpage = make_custom_page(@config["colophon"]) | |
end | |
- custom_backcoverpage = make_custom_page(config["backcover"]) | |
+ custom_backcoverpage = make_custom_page(@config["backcover"]) | |
template = File.expand_path('layout.tex.erb', File.dirname(__FILE__)) | |
layout_file = File.join(@basedir, "layouts", "layout.tex.erb") | |
@@ -296,30 +297,29 @@ module ReVIEW | |
end | |
erb = ERB.new(File.open(template).read) | |
- values = config # must be 'values' for legacy files | |
+ values = @config # must be 'values' for legacy files | |
erb.result(binding) | |
end | |
def copyStyToDir(dirname, copybase, extname = "sty") | |
unless File.directory?(dirname) | |
- $stderr.puts "No such directory - #{dirname}" | |
+ warn "No such directory - #{dirname}" | |
return | |
end | |
- Dir.open(dirname) {|dir| | |
- dir.each {|fname| | |
- next if fname =~ /^\./ | |
- if fname =~ /\.(#{extname})$/i | |
- Dir.mkdir(copybase) unless File.exist?(copybase) | |
- FileUtils.cp "#{dirname}/#{fname}", copybase | |
+ Dir.open(dirname) do |dir| | |
+ dir.each do |fname| | |
+ if File.extname(fname).downcase == "."+extname | |
+ FileUtils.mkdir_p(copybase) | |
+ FileUtils.cp File.join(dirname, fname), copybase | |
end | |
- } | |
- } | |
+ end | |
+ end | |
end | |
- def call_hook(hookname, config) | |
- if config["pdfmaker"].instance_of?(Hash) && config["pdfmaker"][hookname] | |
- hook = File.absolute_path(config["pdfmaker"][hookname], @basedir) | |
+ def call_hook(hookname) | |
+ if @config["pdfmaker"].instance_of?(Hash) && @config["pdfmaker"][hookname] | |
+ hook = File.absolute_path(@config["pdfmaker"][hookname], @basedir) | |
if ENV["REVIEW_SAFE_MODE"].to_i & 1 > 0 | |
warn "hook configuration is prohibited in safe mode. ignored." | |
else | |
diff --git a/lib/review/preprocessor.rb b/lib/review/preprocessor.rb | |
index 8880841..02e79b5 100644 | |
--- a/lib/review/preprocessor.rb | |
+++ b/lib/review/preprocessor.rb | |
@@ -24,24 +24,10 @@ module ReVIEW | |
end | |
def warn(msg) | |
- if @config["outencoding"] =~ /^EUC$/ | |
- msg = NKF.nkf("-W -e", msg) | |
- elsif @config["outencoding"] =~ /^SJIS$/ | |
- msg = NKF.nkf("-W -s", msg) | |
- elsif @config["outencoding"] =~ /^JIS$/ | |
- msg = NKF.nkf("-W -j", msg) | |
- end | |
$stderr.puts "#{location()}: warning: #{msg}" | |
end | |
def error(msg) | |
- if @config["outencoding"] =~ /^EUC$/ | |
- msg = NKF.nkf("-W -e", msg) | |
- elsif @config["outencoding"] =~ /^SJIS$/ | |
- msg = NKF.nkf("-W -s", msg) | |
- elsif @config["outencoding"] =~ /^JIS$/ | |
- msg = NKF.nkf("-W -j", msg) | |
- end | |
@errutils_err = true | |
raise ApplicationError, "#{location()}: #{msg}" | |
end | |
@@ -148,7 +134,7 @@ module ReVIEW | |
path = expand(direc.arg) | |
ent = @repository.fetch_file(path) | |
ent = evaluate(path, ent) if direc['eval'] | |
- replace_block f, line, ent, false # FIXME: turn off lineno: tmp | |
+ replace_block(f, line, ent, false) # FIXME: turn off lineno: tmp | |
when /\A\#@map(?:range)?/ | |
direc = parse_directive(line, 2, 'unindent') | |
@@ -156,7 +142,7 @@ module ReVIEW | |
ent = @repository.fetch_range(path, direc.args[1]) or | |
error "unknown range: #{path}: #{direc.args[1]}" | |
ent = (direc['unindent'] ? unindent(ent, direc['unindent']) : ent) | |
- replace_block f, line, ent, false # FIXME: turn off lineno: tmp | |
+ replace_block(f, line, ent, false) # FIXME: turn off lineno: tmp | |
when /\A\#@end/ | |
error 'unbaranced #@end' | |
@@ -167,7 +153,7 @@ module ReVIEW | |
warn "unkown directive: #{line.strip}" unless known_directive?(op) | |
@f.print line | |
- when /\A\s*\z/ # empty line | |
+ when /\A\s*\z/ # empty line | |
@f.puts | |
else | |
@f.print line | |
@@ -183,34 +169,11 @@ module ReVIEW | |
KNOWN_DIRECTIVES.index(op) | |
end | |
- def convert_outencoding(*s) | |
- ine = "" | |
- if @config["inencoding"] =~ /^EUC$/i | |
- ine = "-E," | |
- elsif @config["inencoding"] =~ /^SJIS$/i | |
- ine = "-S," | |
- elsif @config["inencoding"] =~ /^JIS$/i | |
- ine = "-J," | |
- elsif @config["inencoding"] =~ /^UTF\-8$/i | |
- ine = "-W," | |
- end | |
- | |
- if @config["outencoding"] =~ /^EUC$/i | |
- NKF.nkf("#{ine} -m0x -e", *s) | |
- elsif @config["outencoding"] =~ /^SJIS$/i | |
- NKF.nkf("#{ine} -m0x -s", *s) | |
- elsif @config["outencoding"] =~ /^JIS$/i | |
- NKF.nkf("#{ine} -m0x -j", *s) | |
- else | |
- NKF.nkf("#{ine} -m0x -w", *s) | |
- end | |
- end | |
- | |
def replace_block(f, directive_line, newlines, with_lineno) | |
@f.print directive_line | |
newlines.each do |line| | |
print_number line.number if with_lineno | |
- @f.print convert_outencoding(line.string) | |
+ @f.print line.string | |
end | |
skip_list f | |
end | |
@@ -243,8 +206,8 @@ module ReVIEW | |
class Directive | |
def initialize(op, args, opts) | |
@op = op | |
- @args = args | |
- @opts = opts | |
+ @args = args | |
+ @opts = opts | |
end | |
attr_reader :op | |
@@ -297,12 +260,12 @@ module ReVIEW | |
def optarg_value(spec) | |
case spec | |
- when 'true' then true # [name=true] | |
- when 'false' then false # [name=false] | |
- when 'nil' then nil # [name=nil] | |
- when nil then true # [name] | |
- when /^\d+$/ then $&.to_i # [name=8] | |
- else # [name=val] | |
+ when 'true' then true # [name=true] | |
+ when 'false' then false # [name=false] | |
+ when 'nil' then nil # [name=nil] | |
+ when nil then true # [name] | |
+ when /^\d+$/ then $&.to_i # [name=8] | |
+ else # [name=val] | |
spec | |
end | |
end | |
@@ -465,7 +428,7 @@ module ReVIEW | |
repo = {'file' => whole} | |
curr = {'WHOLE' => whole} | |
lineno = 1 | |
- yacchack = false # remove ';'-only lines. | |
+ yacchack = false # remove ';'-only lines. | |
opened = [['(not opened)', '(not opened)']] * 3 | |
f.each do |line| | |
@@ -510,7 +473,7 @@ module ReVIEW | |
when /(?:\A\#@|\#@@)yacchack/ | |
yacchack = true | |
- when /\A\#@-/ # does not increment line number. | |
+ when /\A\#@-/ # does not increment line number. | |
line = canonical($') | |
curr.each_value do |list| | |
list.push Line.new(nil, line) | |
diff --git a/lib/review/template.rb b/lib/review/template.rb | |
new file mode 100644 | |
index 0000000..8236cc3 | |
--- /dev/null | |
+++ b/lib/review/template.rb | |
@@ -0,0 +1,21 @@ | |
+require 'erb' | |
+module ReVIEW | |
+ class Template | |
+ TEMPLATE_DIR = File.join(File.dirname(__FILE__), "../../templates") | |
+ | |
+ def self.load(filename, mode = 1) | |
+ self.new(filename, mode) | |
+ end | |
+ | |
+ def initialize(filename = nil, mode = nil) | |
+ if filename | |
+ content = File.read(filename) | |
+ @erb = ERB.new(content, nil, mode) | |
+ end | |
+ end | |
+ | |
+ def result(bind_data = nil) | |
+ @erb.result(bind_data) | |
+ end | |
+ end | |
+end | |
diff --git a/lib/review/textbuilder.rb b/lib/review/textbuilder.rb | |
index 8e3a34c..b30a06d 100644 | |
--- a/lib/review/textbuilder.rb | |
+++ b/lib/review/textbuilder.rb | |
@@ -14,4 +14,4 @@ module ReVIEW | |
class TEXTBuilder < TOPBuilder | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/textutils.rb b/lib/review/textutils.rb | |
index 54f4bbb..056902b 100644 | |
--- a/lib/review/textutils.rb | |
+++ b/lib/review/textutils.rb | |
@@ -34,33 +34,5 @@ module ReVIEW | |
blocked_lines.map{|l| l.join("")} | |
end | |
- | |
- def convert_inencoding(str, enc) | |
- case enc | |
- when /^EUC$/i | |
- NKF.nkf("-E -w -m0x", str) | |
- when /^SJIS$/i | |
- NKF.nkf("-S -w -m0x", str) | |
- when /^JIS$/i | |
- NKF.nkf("-J -w -m0x", str) | |
- when /^UTF-8$/i | |
- NKF.nkf("-W -w -m0x", str) | |
- else | |
- NKF.nkf("-w -m0 -m0x", str) | |
- end | |
- end | |
- | |
- def convert_outencoding(str, enc) | |
- case enc | |
- when /^EUC$/i | |
- NKF.nkf("-W -e -m0x", str) | |
- when /^SJIS$/i | |
- NKF.nkf("-W -s -m0x", str) | |
- when /^JIS$/i | |
- NKF.nkf("-W -j -m0x", str) | |
- else | |
- str | |
- end | |
- end | |
end | |
end | |
diff --git a/lib/review/tocparser.rb b/lib/review/tocparser.rb | |
index d10c401..42b6d37 100644 | |
--- a/lib/review/tocparser.rb | |
+++ b/lib/review/tocparser.rb | |
@@ -323,11 +323,11 @@ module ReVIEW | |
end | |
end | |
- class Book::Base # reopen | |
+ class Book::Base # reopen | |
include TOCRoot | |
end | |
- class Book::ChapterSet # reopen | |
+ class Book::ChapterSet # reopen | |
include TOCRoot | |
end | |
@@ -335,7 +335,7 @@ module ReVIEW | |
include TOCRoot | |
end | |
- class Book::Chapter # reopen | |
+ class Book::Chapter # reopen | |
def toc | |
@toc ||= TOCParser.parse(self) | |
unless @toc.size == 1 | |
diff --git a/lib/review/tocprinter.rb b/lib/review/tocprinter.rb | |
index 345d4ab..b6c979c 100644 | |
--- a/lib/review/tocprinter.rb | |
+++ b/lib/review/tocprinter.rb | |
@@ -13,14 +13,13 @@ | |
require 'review/htmlutils' | |
require 'review/htmllayout' | |
-require 'nkf' | |
module ReVIEW | |
class TOCPrinter | |
def TOCPrinter.default_upper_level | |
- 99 # no one use 99 level nest | |
+ 99 # no one use 99 level nest | |
end | |
def initialize(print_upper, param) | |
@@ -31,28 +30,6 @@ module ReVIEW | |
def print?(level) | |
level <= @print_upper | |
end | |
- | |
- def nkffilter(line) | |
- inc = "" | |
- outc = "-w" | |
- if @config["inencoding"] =~ /^EUC$/ | |
- inc = "-E" | |
- elsif @config["inencoding"] =~ /^SJIS$/ | |
- inc = "-S" | |
- elsif @config["inencoding"] =~ /^JIS$/ | |
- inc = "-J" | |
- end | |
- | |
- if @config["outencoding"] =~ /^EUC$/ | |
- outc = "-e" | |
- elsif @config["outencoding"] =~ /^SJIS$/ | |
- outc = "-s" | |
- elsif @config["outencoding"] =~ /^JIS$/ | |
- outc = "-j" | |
- end | |
- | |
- NKF.nkf("#{inc} #{outc}", line) | |
- end | |
end | |
@@ -79,11 +56,11 @@ module ReVIEW | |
printf "%3s %3dKB %6dC %5dL %s (%s)\n", | |
chapnumstr(node.number), | |
vol.kbytes, vol.chars, vol.lines, | |
- nkffilter(node.label), node.chapter_id | |
+ node.label, node.chapter_id | |
else | |
printf "%17s %5dL %s\n", | |
'', node.estimated_lines, | |
- nkffilter(" #{' ' * (node.level - 1)}#{number} #{node.label}") | |
+ " #{' ' * (node.level - 1)}#{number} #{node.label}" | |
end | |
end | |
@@ -94,7 +71,7 @@ module ReVIEW | |
def volume_columns(level, volstr) | |
cols = ["", "", "", nil] | |
cols[level - 1] = volstr | |
- cols[0, 3] # does not display volume of level-4 section | |
+ cols[0, 3] # does not display volume of level-4 section | |
end | |
end | |
@@ -186,7 +163,7 @@ module ReVIEW | |
class IDGTOCPrinter < TOCPrinter | |
def print_book(book) | |
puts %Q(<?xml version="1.0" encoding="UTF-8"?>) | |
- puts nkffilter(%Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>)) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには? | |
+ puts %Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには? | |
puts %Q(<ul aid:pstyle='ul-partblock'>) | |
print_children book | |
puts %Q(</ul></doc>) | |
@@ -208,15 +185,15 @@ module ReVIEW | |
if node.chapter? | |
vol = node.volume | |
printf "<li aid:pstyle='ul-part'>%s</li>\n", | |
- nkffilter("#{chapnumstr(node.number)}#{node.label}") | |
+ "#{chapnumstr(node.number)}#{node.label}" | |
else | |
printf "<li>%-#{LABEL_LEN}s\n", | |
- nkffilter(" #{' ' * (node.level - 1)}#{seq} #{node.label}</li>") | |
+ " #{' ' * (node.level - 1)}#{seq} #{node.label}</li>" | |
end | |
end | |
def chapnumstr(n) | |
- n ? nkffilter(sprintf('第%d章 ', n)) : '' | |
+ n ? sprintf('第%d章 ', n) : '' | |
end | |
def volume_columns(level, volstr) | |
diff --git a/lib/review/topbuilder.rb b/lib/review/topbuilder.rb | |
index ab35d20..2d7f611 100644 | |
--- a/lib/review/topbuilder.rb | |
+++ b/lib/review/topbuilder.rb | |
@@ -741,8 +741,7 @@ module ReVIEW | |
def inline_chapref(id) | |
chs = ["", "「", "」"] | |
unless @book.config["chapref"].nil? | |
- _chs = convert_inencoding(@book.config["chapref"], | |
- @book.config["inencoding"]).split(",") | |
+ _chs = @book.config["chapref"].split(",") | |
if _chs.size != 3 | |
error "--chapsplitter must have exactly 3 parameters with comma." | |
else | |
@@ -787,4 +786,4 @@ module ReVIEW | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/unfold.rb b/lib/review/unfold.rb | |
index 2d79712..0c06fca 100644 | |
--- a/lib/review/unfold.rb | |
+++ b/lib/review/unfold.rb | |
@@ -47,7 +47,7 @@ module ReVIEW | |
private | |
- ZSPACE = "\241\241" # EUC-JP zen-kaku space | |
+ ZSPACE = "\241\241" # EUC-JP zen-kaku space | |
def do_unfold(input) | |
@blank_needed = false | |
@@ -135,4 +135,4 @@ module ReVIEW | |
end | |
-end # module ReVIEW | |
+end # module ReVIEW | |
diff --git a/lib/review/version.rb b/lib/review/version.rb | |
index a201ac1..fe94777 100644 | |
--- a/lib/review/version.rb | |
+++ b/lib/review/version.rb | |
@@ -1,3 +1,3 @@ | |
module ReVIEW | |
- VERSION = "1.6.0" | |
+ VERSION = "1.7.0" | |
end | |
diff --git a/review.gemspec b/review.gemspec | |
index d936b66..98a4515 100644 | |
--- a/review.gemspec | |
+++ b/review.gemspec | |
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem| | |
gem.summary = "Re:VIEW: a easy-to-use digital publishing system" | |
gem.description = "Re:VIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX." | |
gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version= | |
- gem.date = "2015-06-29" | |
+ gem.date = "2015-10-29" | |
gem.files = `git ls-files`.split("\n") | |
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | |
@@ -27,5 +27,6 @@ Gem::Specification.new do |gem| | |
gem.add_development_dependency("rake") | |
gem.add_development_dependency("test-unit") | |
gem.add_development_dependency("pygments.rb") | |
+ gem.add_development_dependency("rubocop") | |
end | |
diff --git a/rubocop-todo.yml b/rubocop-todo.yml | |
deleted file mode 100644 | |
index 133d9fe..0000000 | |
--- a/rubocop-todo.yml | |
+++ /dev/null | |
@@ -1,456 +0,0 @@ | |
-# This configuration was generated by `rubocop --auto-gen-config` | |
-# on 2014-03-27 13:46:06 +0900 using RuboCop version 0.19.1. | |
-# The point is for the user to remove these configuration records | |
-# one by one as the offenses are removed from the code base. | |
-# Note that changes in the inspected code, or installation of new | |
-# versions of RuboCop, may require this file to be generated again. | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-AccessModifierIndentation: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-AccessorMethodName: | |
- Enabled: false | |
- | |
-# Offense count: 29 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-AlignParameters: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-AmbiguousOperator: | |
- Enabled: false | |
- | |
-# Offense count: 30 | |
-# Cop supports --auto-correct. | |
-AndOr: | |
- Enabled: false | |
- | |
-# Offense count: 22 | |
-AsciiComments: | |
- Enabled: false | |
- | |
-# Offense count: 34 | |
-# Configuration parameters: AllowSafeAssignment. | |
-AssignmentInCondition: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-BlockAlignment: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-BlockComments: | |
- Enabled: false | |
- | |
-# Offense count: 10 | |
-BlockNesting: | |
- Max: 4 | |
- | |
-# Offense count: 114 | |
-# Cop supports --auto-correct. | |
-Blocks: | |
- Enabled: false | |
- | |
-# Offense count: 31 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-BracesAroundHashParameters: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-CaseEquality: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-ClassAndModuleCamelCase: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-ClassAndModuleChildren: | |
- Enabled: false | |
- | |
-# Offense count: 28 | |
-# Configuration parameters: CountComments. | |
-ClassLength: | |
- Max: 1003 | |
- | |
-# Offense count: 35 | |
-ClassMethods: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-ClassVars: | |
- Enabled: false | |
- | |
-# Offense count: 14 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: PreferredMethods. | |
-CollectionMethods: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-# Cop supports --auto-correct. | |
-ColonMethodCall: | |
- Enabled: false | |
- | |
-# Offense count: 11 | |
-# Configuration parameters: Keywords. | |
-CommentAnnotation: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-ConstantName: | |
- Enabled: false | |
- | |
-# Offense count: 52 | |
-CyclomaticComplexity: | |
- Max: 64 | |
- | |
-# Offense count: 98 | |
-Documentation: | |
- Enabled: false | |
- | |
-# Offense count: 5 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: AllowAdjacentOneLineDefs. | |
-EmptyLineBetweenDefs: | |
- Enabled: false | |
- | |
-# Offense count: 32 | |
-# Cop supports --auto-correct. | |
-EmptyLines: | |
- Enabled: false | |
- | |
-# Offense count: 3 | |
-EmptyLinesAroundAccessModifier: | |
- Enabled: false | |
- | |
-# Offense count: 101 | |
-# Cop supports --auto-correct. | |
-EmptyLinesAroundBody: | |
- Enabled: false | |
- | |
-# Offense count: 3 | |
-# Cop supports --auto-correct. | |
-EmptyLiteral: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-Eval: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-FavorUnlessOverNegatedIf: | |
- Enabled: false | |
- | |
-# Offense count: 11 | |
-# Configuration parameters: Exclude. | |
-FileName: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-For: | |
- Enabled: false | |
- | |
-# Offense count: 22 | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-FormatString: | |
- Enabled: false | |
- | |
-# Offense count: 13 | |
-# Configuration parameters: AllowedVariables. | |
-GlobalVars: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-# Cop supports --auto-correct. | |
-HashMethods: | |
- Enabled: false | |
- | |
-# Offense count: 42 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: SupportedStyles. | |
-HashSyntax: | |
- EnforcedStyle: hash_rockets | |
- | |
-# Offense count: 34 | |
-# Configuration parameters: MaxLineLength. | |
-IfUnlessModifier: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-IndentArray: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-IndentHash: | |
- Enabled: false | |
- | |
-# Offense count: 36 | |
-# Cop supports --auto-correct. | |
-IndentationConsistency: | |
- Enabled: false | |
- | |
-# Offense count: 59 | |
-# Cop supports --auto-correct. | |
-IndentationWidth: | |
- Enabled: false | |
- | |
-# Offense count: 19 | |
-# Cop supports --auto-correct. | |
-LeadingCommentSpace: | |
- Enabled: false | |
- | |
-# Offense count: 6 | |
-# Cop supports --auto-correct. | |
-LineEndConcatenation: | |
- Enabled: false | |
- | |
-# Offense count: 696 | |
-LineLength: | |
- Max: 739 | |
- | |
-# Offense count: 109 | |
-# Cop supports --auto-correct. | |
-MethodCallParentheses: | |
- Enabled: false | |
- | |
-# Offense count: 11 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-MethodDefParentheses: | |
- Enabled: false | |
- | |
-# Offense count: 226 | |
-# Configuration parameters: CountComments. | |
-MethodLength: | |
- Max: 426 | |
- | |
-# Offense count: 17 | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-MethodName: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-MultilineIfThen: | |
- Enabled: false | |
- | |
-# Offense count: 6 | |
-Not: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-NumericLiterals: | |
- MinDigits: 7 | |
- | |
-# Offense count: 1 | |
-OpMethod: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Configuration parameters: CountKeywordArgs. | |
-ParameterLists: | |
- Max: 6 | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: AllowSafeAssignment. | |
-ParenthesesAroundCondition: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-ParenthesesAsGroupedExpression: | |
- Enabled: false | |
- | |
-# Offense count: 473 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: PreferredDelimiters. | |
-PercentLiteralDelimiters: | |
- Enabled: false | |
- | |
-# Offense count: 36 | |
-# Cop supports --auto-correct. | |
-PerlBackrefs: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-# Configuration parameters: NamePrefixBlacklist. | |
-PredicateName: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-RedundantBegin: | |
- Enabled: false | |
- | |
-# Offense count: 15 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: AllowMultipleReturnValues. | |
-RedundantReturn: | |
- Enabled: false | |
- | |
-# Offense count: 8 | |
-# Cop supports --auto-correct. | |
-RedundantSelf: | |
- Enabled: false | |
- | |
-# Offense count: 18 | |
-# Configuration parameters: MaxSlashes. | |
-RegexpLiteral: | |
- Enabled: false | |
- | |
-# Offense count: 8 | |
-SelfAssignment: | |
- Enabled: false | |
- | |
-# Offense count: 5 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: AllowAsExpressionSeparator. | |
-Semicolon: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-ShadowingOuterLocalVariable: | |
- Enabled: false | |
- | |
-# Offense count: 40 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-SignalException: | |
- Enabled: false | |
- | |
-# Offense count: 5 | |
-# Configuration parameters: Methods. | |
-SingleLineBlockParams: | |
- Enabled: false | |
- | |
-# Offense count: 4 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: AllowIfMethodIsEmpty. | |
-SingleLineMethods: | |
- Enabled: false | |
- | |
-# Offense count: 230 | |
-# Cop supports --auto-correct. | |
-SpaceAfterComma: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-SpaceAfterNot: | |
- Enabled: false | |
- | |
-# Offense count: 8 | |
-# Cop supports --auto-correct. | |
-SpaceAfterSemicolon: | |
- Enabled: false | |
- | |
-# Offense count: 36 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-SpaceAroundEqualsInParameterDefault: | |
- Enabled: false | |
- | |
-# Offense count: 152 | |
-# Cop supports --auto-correct. | |
-SpaceAroundOperators: | |
- Enabled: false | |
- | |
-# Offense count: 55 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-SpaceBeforeBlockBraces: | |
- Enabled: false | |
- | |
-# Offense count: 232 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. | |
-SpaceInsideBlockBraces: | |
- Enabled: false | |
- | |
-# Offense count: 75 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. | |
-SpaceInsideHashLiteralBraces: | |
- Enabled: false | |
- | |
-# Offense count: 2 | |
-# Cop supports --auto-correct. | |
-SpaceInsideParens: | |
- Enabled: false | |
- | |
-# Offense count: 13 | |
-# Cop supports --auto-correct. | |
-SpecialGlobalVars: | |
- Enabled: false | |
- | |
-# Offense count: 2407 | |
-# Cop supports --auto-correct. | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-StringLiterals: | |
- Enabled: false | |
- | |
-# Offense count: 348 | |
-Tab: | |
- Enabled: false | |
- | |
-# Offense count: 6 | |
-# Cop supports --auto-correct. | |
-TrailingBlankLines: | |
- Enabled: false | |
- | |
-# Offense count: 34 | |
-# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. | |
-TrailingComma: | |
- Enabled: false | |
- | |
-# Offense count: 8 | |
-# Configuration parameters: ExactNameMatch, AllowPredicates, Whitelist. | |
-TrivialAccessors: | |
- Enabled: false | |
- | |
-# Offense count: 3 | |
-UnlessElse: | |
- Enabled: false | |
- | |
-# Offense count: 18 | |
-UselessAssignment: | |
- Enabled: false | |
- | |
-# Offense count: 1 | |
-# Configuration parameters: EnforcedStyle, SupportedStyles. | |
-VariableName: | |
- Enabled: false | |
- | |
-# Offense count: 3 | |
-# Configuration parameters: MaxLineLength. | |
-WhileUntilModifier: | |
- Enabled: false | |
- | |
-# Offense count: 31 | |
-# Cop supports --auto-correct. | |
-WordArray: | |
- MinSize: 7 | |
- | |
-BarePercentLiterals: | |
- Enabled: false | |
- | |
-UnusedMethodArgument: | |
- Enabled: false | |
- | |
-PercentQLiterals: | |
- Enabled: false | |
- | |
-UnneededPercentQ: | |
- Enabled: false | |
- | |
diff --git a/templates/html/layout-html5.html.erb b/templates/html/layout-html5.html.erb | |
new file mode 100644 | |
index 0000000..3087688 | |
--- /dev/null | |
+++ b/templates/html/layout-html5.html.erb | |
@@ -0,0 +1,17 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<!DOCTYPE html> | |
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="<%= @language %>"> | |
+<head> | |
+ <meta charset="UTF-8" /> | |
+<% if @stylesheets.present? %> | |
+<% @stylesheets.each do |style| %> | |
+ <link rel="stylesheet" type="text/css" href="<%= style %>" /> | |
+<% end %> | |
+<% end%> | |
+ <meta name="generator" content="Re:VIEW" /> | |
+ <title><%= @title %></title> | |
+</head> | |
+<body<%= @body_ext %>> | |
+<%= @body %> | |
+</body> | |
+</html> | |
diff --git a/templates/html/layout-xhtml1.html.erb b/templates/html/layout-xhtml1.html.erb | |
new file mode 100644 | |
index 0000000..a88a8d1 | |
--- /dev/null | |
+++ b/templates/html/layout-xhtml1.html.erb | |
@@ -0,0 +1,20 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="<%= @language %>"> | |
+<head> | |
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> | |
+ <meta http-equiv="Content-Style-Type" content="text/css"/> | |
+<% if @stylesheets.present? %> | |
+<% @stylesheets.each do |style| %> | |
+ <link rel="stylesheet" type="text/css" href="<%= style %>" /> | |
+<% end %> | |
+<% end%> | |
+ <meta name="generator" content="Re:VIEW"/> | |
+ <title><%= @title %></title> | |
+</head> | |
+<body<%= @body_ext %>> | |
+<% if @error_messages %><%= @error_messages %><% end %> | |
+<% if @warning_messages %><%= @warning_messages %><% end %> | |
+<%= @body %> | |
+</body> | |
+</html> | |
diff --git a/templates/ncx/epubv2.ncx.erb b/templates/ncx/epubv2.ncx.erb | |
new file mode 100644 | |
index 0000000..4378a57 | |
--- /dev/null | |
+++ b/templates/ncx/epubv2.ncx.erb | |
@@ -0,0 +1,11 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> | |
+ <head> | |
+ <meta name="dtb:depth" content="1"/> | |
+ <meta name="dtb:totalPageCount" content="0"/> | |
+ <meta name="dtb:maxPageNumber" content="0"/> | |
+<%= @ncx_isbn %> | |
+ </head> | |
+<%= @ncx_doctitle %> | |
+<%= @ncx_navmap %> | |
+</ncx> | |
diff --git a/templates/opf/epubv2.opf.erb b/templates/opf/epubv2.opf.erb | |
new file mode 100644 | |
index 0000000..ae632a0 | |
--- /dev/null | |
+++ b/templates/opf/epubv2.opf.erb | |
@@ -0,0 +1,21 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId"> | |
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> | |
+<%= @opf_metainfo %> | |
+<%= @opf_coverimage %> | |
+ </metadata> | |
+<%= @opf_manifest %> | |
+<%= @opf_toc %> | |
+ <guide> | |
+ <reference type="cover" title="<%= @producer.res.v("covertitle") %>" href="<%= @producer.params["cover"] %>"/> | |
+<% if @producer.params["titlepage"].present? %> | |
+ <reference type="title-page" title="<%= @producer.res.v("titlepagetitle") %>" href="titlepage.<%= @producer.params["htmlext"] %>"/> | |
+<% end %> | |
+<% if @producer.params["mytoc"].present? %> | |
+ <reference type="toc" title="<%= @producer.res.v("toctitle") %>" href="<%= @producer.params["bookname"] %>-toc.<%= @producer.params["htmlext"] %>"/> | |
+<% end %> | |
+<% if @producer.params["colophon"].present? %> | |
+ <reference type="colophon" title="<%= @producer.res.v("colophontitle") %>" href="colophon.<%= @producer.params["htmlext"] %>"/> | |
+<% end %> | |
+ </guide> | |
+</package> | |
diff --git a/templates/opf/epubv3.opf.erb b/templates/opf/epubv3.opf.erb | |
new file mode 100644 | |
index 0000000..9313371 | |
--- /dev/null | |
+++ b/templates/opf/epubv3.opf.erb | |
@@ -0,0 +1,18 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="<%= @producer.params["language"] %>"> | |
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> | |
+<%= @opf_metainfo %> | |
+ </metadata> | |
+<%= @opf_manifest %> | |
+<%= @opf_toc %> | |
+ <guide> | |
+ <reference type="cover" title="<%= @producer.res.v("covertitle") %>" href="<%= @producer.params["cover"] %>"/> | |
+<% if @producer.params["titlepage"].present? %> | |
+ <reference type="title-page" title="<%= @producer.res.v("titlepagetitle") %>" href="titlepage.<%= @producer.params["htmlext"] %>"/> | |
+<% end %> | |
+ <reference type="toc" title="<%= @producer.res.v("toctitle") %>" href="<%= @producer.params["bookname"] %>-toc.<%= @producer.params["htmlext"] %>"/> | |
+<% if @producer.params["colophon"].present? %> | |
+ <reference type="colophon" title="<%= @producer.res.v("colophontitle") %>" href="colophon.<%= @producer.params["htmlext"] %>"/> | |
+<% end %> | |
+ </guide> | |
+</package> | |
diff --git a/templates/xml/container.xml.erb b/templates/xml/container.xml.erb | |
new file mode 100644 | |
index 0000000..47d49b8 | |
--- /dev/null | |
+++ b/templates/xml/container.xml.erb | |
@@ -0,0 +1,6 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"> | |
+ <rootfiles> | |
+ <rootfile full-path="<%= @opf_path %>" media-type="application/oebps-package+xml" /> | |
+ </rootfiles> | |
+</container> | |
diff --git a/test/assets/test.xml.erb b/test/assets/test.xml.erb | |
new file mode 100644 | |
index 0000000..cdb001c | |
--- /dev/null | |
+++ b/test/assets/test.xml.erb | |
@@ -0,0 +1,3 @@ | |
+<test> | |
+<name><%= @name %></name> | |
+</test> | |
diff --git a/test/test.re b/test/test.re | |
index 02de638..fd6951d 100644 | |
--- a/test/test.re | |
+++ b/test/test.re | |
@@ -1,7 +1,7 @@ | |
= 見出し | |
以下を実行 | |
//emlist{ | |
-./bin/review-compile --inencoding=UTF-8 --outencoding=UTF-8 --hdnumberingmode test.re --target=html | |
+./bin/review-compile --hdnumberingmode test.re --target=html | |
} | |
== 節1 | |
diff --git a/test/test_book.rb b/test/test_book.rb | |
index 1bf75f3..b3313a6 100644 | |
--- a/test/test_book.rb | |
+++ b/test/test_book.rb | |
@@ -158,14 +158,14 @@ class BookTest < Test::Unit::TestCase | |
def test_setParameter | |
book = Book::Base.new(File.dirname(__FILE__)) | |
book.param = :test | |
- assert_equal :test, book.param # old way | |
+ assert_equal :test, book.param # old way | |
assert_equal :test, book.config # new way | |
end | |
def test_setConfig | |
book = Book::Base.new(File.dirname(__FILE__)) | |
book.config = :test | |
- assert_equal :test, book.param # old way | |
+ assert_equal :test, book.param # old way | |
assert_equal :test, book.config # new way | |
end | |
@@ -391,7 +391,7 @@ EOC | |
end | |
mktmpbookdir 'catalog.yml' => "APPENDIX:\n - p01.re", | |
- 'p01.re' => '= appendix' do |dir, book, files| | |
+ 'p01.re' => '= appendix' do |dir, book, files| | |
assert_equal 'appendix', book.appendix.chapters.first.title | |
assert_equal 1, book.appendix.chapters.first.number | |
end | |
@@ -399,7 +399,7 @@ EOC | |
def test_postscripts | |
mktmpbookdir 'catalog.yml' => "POSTDEF:\n - b01.re", | |
- 'b01.re' => '= back' do |dir, book, files| | |
+ 'b01.re' => '= back' do |dir, book, files| | |
assert_kind_of Book::Part, book.postscripts | |
assert_equal 1, book.postscripts.chapters.size | |
assert_equal 'back', book.postscripts.chapters.first.title | |
diff --git a/test/test_book_chapter.rb b/test/test_book_chapter.rb | |
index b9d8453..09b47ca 100644 | |
--- a/test/test_book_chapter.rb | |
+++ b/test/test_book_chapter.rb | |
@@ -3,27 +3,6 @@ require 'book_test_helper' | |
class ChapterTest < Test::Unit::TestCase | |
include BookTestHelper | |
- def setup | |
- | |
- if "".respond_to?(:encode) | |
- @utf8_str = "あいうえお" | |
- @eucjp_str = "あいうえお".encode("EUC-JP") | |
- @sjis_str = "あいうえお".encode("Shift_JIS") | |
- @jis_str = "あいうえお".encode("ISO-2022-JP") | |
- else | |
- @utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお" | |
- @eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa" | |
- @sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8" | |
- @jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42" | |
- end | |
-=begin | |
- @utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお" | |
- @eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa" | |
- @sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8" | |
- @jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42" | |
-=end | |
- end | |
- | |
def test_initialize | |
ch = Book::Chapter.new(:book, :number, :name, '/foo/bar', :io) | |
assert_equal :book, ch.book | |
@@ -88,60 +67,6 @@ class ChapterTest < Test::Unit::TestCase | |
io = StringIO.new("=1\n=2\n") | |
ch = Book::Chapter.new(book, nil, nil, nil, io) | |
assert_equal '1', ch.title | |
- | |
- | |
- [ | |
- ['EUC', @eucjp_str], | |
- ['SJIS', @sjis_str], | |
-# ['JIS', @jis_str], | |
- ['XYZ', @eucjp_str], | |
- ].each do |enc, instr| | |
- io = StringIO.new("= #{instr}\n") | |
- ch = Book::Chapter.new(book, nil, nil, nil, io) | |
- book.config['inencoding'] = enc | |
- assert_equal @utf8_str, ch.title | |
- assert_equal @utf8_str, ch.instance_eval { @title } | |
- end | |
- end | |
- | |
- def test_content | |
- [ | |
- ['EUC', @eucjp_str], | |
- ['SJIS', @sjis_str], | |
- ['JIS', @jis_str], | |
- ['XYZ', @eucjp_str], | |
- ].each do |enc, instr| | |
- tf = Tempfile.new('chapter_test') | |
- book = Book::Base.new(nil) | |
- begin | |
- tf.print instr | |
- tf.close | |
- | |
- ch = Book::Chapter.new(book, nil, nil, tf.path) | |
- book.config['inencoding'] = enc | |
- assert_equal @utf8_str, ch.content | |
- assert_equal @utf8_str, ch.instance_eval { @content } | |
- ensure | |
- tf.close(true) | |
- end | |
- | |
- tf1 = Tempfile.new('chapter_test1') | |
- tf2 = Tempfile.new('chapter_test2') | |
- begin | |
- tf1.puts instr | |
- tf1.puts instr | |
- tf1.close | |
- tf2.puts instr | |
- tf1.close | |
- | |
- ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2) | |
- book.config['inencoding'] = enc | |
- assert_equal "#{@utf8_str}\n#{@utf8_str}\n", ch.content # XXX: OK? | |
- ensure | |
- tf1.close(true) | |
- tf2.close(true) | |
- end | |
- end | |
end | |
def test_lines | |
@@ -282,7 +207,6 @@ E | |
def test_column_index | |
book = Book::Base.new(nil) | |
- book.config["inencoding"] = "utf-8" | |
do_test_index(<<E, Book::ColumnIndex, :column_index, :column, :propagate => false) | |
= dummy1 | |
===[column]{abc} aaaa | |
diff --git a/test/test_book_part.rb b/test/test_book_part.rb | |
index d753730..10f3ae9 100644 | |
--- a/test/test_book_part.rb | |
+++ b/test/test_book_part.rb | |
@@ -33,7 +33,7 @@ class PartTest < Test::Unit::TestCase | |
assert_equal 0, part.volume.lines | |
chs = [] | |
- tfs = [] ## prevent from removing Tempfile | |
+ tfs = [] ## prevent from removing Tempfile | |
Tempfile.open('part_test') do |o| | |
o.print "12345" | |
chs << Book::Chapter.new(book, nil, nil, o.path) | |
diff --git a/test/test_builder.rb b/test/test_builder.rb | |
index 1a1bf25..13d29b8 100644 | |
--- a/test/test_builder.rb | |
+++ b/test/test_builder.rb | |
@@ -52,47 +52,6 @@ class BuidlerTest < Test::Unit::TestCase | |
assert_raises(NoMethodError) do # XXX: OK? | |
b.puts "" | |
end | |
- | |
- if "".respond_to?(:encode) | |
- utf8_str = "あいうえお" | |
- eucjp_str = "あいうえお".encode("EUC-JP") | |
- sjis_str = "あいうえお".encode("Shift_JIS") | |
- jis_str = "あいうえお".encode("ISO-2022-JP") | |
- else | |
- utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお" | |
- eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa" | |
- sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8" | |
- jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42" | |
- end | |
- | |
- [ | |
- ['EUC', eucjp_str], | |
- ['SJIS', sjis_str], | |
-# ['JIS', jis_str], | |
-# ['jis', jis_str], | |
-# ['jIs', jis_str], | |
- ['XYZ', utf8_str], | |
- ].each do |enc, expect| | |
- params = {"outencoding" => enc} | |
- | |
- [ | |
- [:print, utf8_str, expect], | |
- [:puts, utf8_str, "#{expect}\n"], | |
- [:print, "#{utf8_str}\n", "#{expect}\n"], | |
- [:puts, "#{utf8_str}\n", "#{expect}\n"], | |
- ].each do |m, instr, expstr| | |
- b = Builder.new | |
- chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil) | |
- b.bind(nil, chapter, nil) | |
- chapter.book.config = params | |
- b.__send__(m, instr) | |
- if "".respond_to?(:encode) | |
- assert_equal expstr.encode("UTF-8"), b.result | |
- else | |
- assert_equal expstr, b.result | |
- end | |
- end | |
- end | |
end | |
def test_not_implemented_methods | |
@@ -131,14 +90,6 @@ class BuidlerTest < Test::Unit::TestCase | |
assert_equal [:text, text], @b.compile_inline(text) | |
end | |
- def test_convert_outencoding | |
- book = ReVIEW::Book::Base.new(nil) | |
- book.config = {'outencoding' => "EUC"} | |
- b = Builder.new | |
- ret = b.convert_outencoding("a", book.config["outencoding"]) | |
- assert_equal "a", ret | |
- end | |
- | |
class XBuilder < Builder | |
def list_header(id, caption) | |
end | |
diff --git a/test/test_configure.rb b/test/test_configure.rb | |
new file mode 100644 | |
index 0000000..970f16d | |
--- /dev/null | |
+++ b/test/test_configure.rb | |
@@ -0,0 +1,50 @@ | |
+# encoding: utf-8 | |
+ | |
+require 'test_helper' | |
+require 'review/epubmaker' | |
+ | |
+class ConfigureTest < Test::Unit::TestCase | |
+ include ReVIEW | |
+ | |
+ def setup | |
+ @maker = ReVIEW::EPUBMaker.new | |
+ @config = ReVIEW::Configure.values | |
+ @config.merge!({ | |
+ "bookname" => "sample", | |
+ "title" => "Sample Book", | |
+ "version" => 2, | |
+ "urnid" => "http://example.jp/", | |
+ "date" => "2011-01-01", | |
+ "language" => "ja", | |
+ "epubmaker" => {"flattocindent" => true}, | |
+ }) | |
+ @output = StringIO.new | |
+ I18n.setup(@config["language"]) | |
+ end | |
+ | |
+ def test_configure_class | |
+ assert_equal ReVIEW::Configure, @config.class | |
+ end | |
+ | |
+ def test_configure_get | |
+ bookname = @config["bookname"] | |
+ assert_equal "sample", bookname | |
+ end | |
+ | |
+ def test_configure_get2 | |
+ assert_equal true, @config["epubmaker"]["flattocindent"] | |
+ end | |
+ | |
+ def test_configure_with_maker | |
+ @config.maker = "epubmaker" | |
+ assert_equal true, @config["flattocindent"] | |
+ assert_equal true, @config["epubmaker"]["flattocindent"] | |
+ end | |
+ | |
+ def test_configure_with_invalidmaker | |
+ @config.maker = "pdfmaker" | |
+ assert_equal nil, @config["flattocindent"] | |
+ assert_equal true, @config["epubmaker"]["flattocindent"] | |
+ end | |
+ | |
+end | |
diff --git a/test/test_htmlbuilder.rb b/test/test_htmlbuilder.rb | |
index 192d5f2..3545dc7 100644 | |
--- a/test/test_htmlbuilder.rb | |
+++ b/test/test_htmlbuilder.rb | |
@@ -14,10 +14,9 @@ class HTMLBuidlerTest < Test::Unit::TestCase | |
@builder = HTMLBuilder.new() | |
@config = ReVIEW::Configure.values | |
@config.merge!({ | |
- "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => nil, # for HTMLBuilder | |
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
+ "stylesheet" => nil, # for HTMLBuilder | |
+ "htmlext" => "html", | |
}) | |
@book = Book::Base.new(".") | |
@book.config = @config | |
@@ -521,6 +520,35 @@ class HTMLBuidlerTest < Test::Unit::TestCase | |
assert_equal "<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<pre class=\"list\">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n</pre>\n</div>\n", actual | |
end | |
+ def test_listnum | |
+ def @chapter.list(id) | |
+ Book::ListIndex::Item.new("samplelist",1) | |
+ end | |
+ | |
+ @book.config["highlight"] = false | |
+ actual = compile_block(<<-EOS) | |
+//listnum[samplelist][this is @<b>{test}<&>_][ruby]{ | |
+def foo(a1, a2=:test) | |
+ (1..3).times{|i| a.include?(:foo)} | |
+ return true | |
+end | |
+//} | |
+EOS | |
+ | |
+ expected =<<-EOS | |
+<div class="code"> | |
+<p class="caption">リスト1.1: this is <b>test</b><&>_</p> | |
+<pre class="list"> 1: def foo(a1, a2=:test) | |
+ 2: (1..3).times{|i| a.include?(:foo)} | |
+ 3: return true | |
+ 4: end | |
+</pre> | |
+</div> | |
+EOS | |
+ | |
+ assert_equal expected, actual | |
+ end | |
+ | |
def test_listnum_pygments_lang | |
def @chapter.list(id) | |
Book::ListIndex::Item.new("samplelist",1) | |
@@ -583,6 +611,19 @@ class HTMLBuidlerTest < Test::Unit::TestCase | |
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual | |
end | |
+ def test_emlistnum | |
+ @book.config["highlight"] = false | |
+ actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n") | |
+ expected =<<-EOS | |
+<div class="emlistnum-code"> | |
+<pre class="emlist"> 1: lineA | |
+ 2: lineB | |
+</pre> | |
+</div> | |
+EOS | |
+ assert_equal expected, actual | |
+ end | |
+ | |
def test_emlist_with_4tab | |
@config["tabwidth"] = 4 | |
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n") | |
@@ -626,6 +667,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase | |
assert_equal %Q|<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}") | |
end | |
+ def test_bib_htmlext | |
+ def @chapter.bibpaper(id) | |
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib") | |
+ end | |
+ | |
+ @config["htmlext"] = "xhtml" | |
+ assert_equal %Q|<a href="bib.xhtml#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}") | |
+ end | |
+ | |
def test_bibpaper | |
def @chapter.bibpaper(id) | |
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib") | |
diff --git a/test/test_htmltoc.rb b/test/test_htmltoc.rb | |
new file mode 100644 | |
index 0000000..a8b3a92 | |
--- /dev/null | |
+++ b/test/test_htmltoc.rb | |
@@ -0,0 +1,32 @@ | |
+# encoding: utf-8 | |
+ | |
+require 'test_helper' | |
+require 'review/htmltoc' | |
+ | |
+class HTMLTocTest < Test::Unit::TestCase | |
+ | |
+ def setup | |
+ end | |
+ | |
+ def teardown | |
+ end | |
+ | |
+ def test_tocfilename | |
+ toc = HTMLToc.new("/var/tmp") | |
+ assert_equal "/var/tmp/toc-html.txt", toc.tocfilename | |
+ end | |
+ | |
+ def test_encode_args | |
+ toc = HTMLToc.new("/var/tmp") | |
+ assert_equal "chaptype=pre", toc.encode_args({:chaptype => "pre"}) | |
+ assert_equal "force_include=true,chaptype=body,properties=foo", toc.encode_args({:force_include => true, :chaptype => "body", "properties"=>"foo"}) | |
+ end | |
+ | |
+ def test_decode_args | |
+ toc = HTMLToc.new("/var/tmp") | |
+ assert_equal({:chaptype => "pre"}, toc.decode_args("chaptype=pre")) | |
+ assert_equal({:force_include => "true", :chaptype => "body",:properties=>"foo"}, toc.decode_args("force_include=true,chaptype=body,properties=foo")) | |
+ end | |
+ | |
+end | |
+ | |
diff --git a/test/test_i18n.rb b/test/test_i18n.rb | |
index c42203c..08024dd 100644 | |
--- a/test/test_i18n.rb | |
+++ b/test/test_i18n.rb | |
@@ -10,7 +10,7 @@ require 'tmpdir' | |
class I18nTest < Test::Unit::TestCase | |
include ReVIEW | |
- if RUBY_VERSION !~ /^1.8/ ## to avoid Travis error :-( | |
+ if RUBY_VERSION !~ /^1.8/ ## to avoid Travis error :-( | |
def test_load_locale_yml | |
Dir.mktmpdir do |dir| | |
Dir.chdir(dir) do | |
@@ -137,10 +137,8 @@ class I18nTest < Test::Unit::TestCase | |
I18n.setup "en" | |
@builder = HTMLBuilder.new() | |
@config = { | |
- "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => nil, # for HTMLBuilder | |
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
+ "stylesheet" => nil, # for HTMLBuilder | |
"ext" => ".re" | |
} | |
@book = Book::Base.new(".") | |
diff --git a/test/test_idgxmlbuilder.rb b/test/test_idgxmlbuilder.rb | |
index 6b2718e..4830c22 100644 | |
--- a/test/test_idgxmlbuilder.rb | |
+++ b/test/test_idgxmlbuilder.rb | |
@@ -14,8 +14,6 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase | |
@config = ReVIEW::Configure.values | |
@config.merge!({ | |
"secnolevel" => 2, | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
"nolf" => true, | |
"tableopt" => "10" | |
}) | |
diff --git a/test/test_inaobuilder.rb b/test/test_inaobuilder.rb | |
index bb7ff48..c22f1f7 100644 | |
--- a/test/test_inaobuilder.rb | |
+++ b/test/test_inaobuilder.rb | |
@@ -9,10 +9,8 @@ class INAOBuidlerTest < Test::Unit::TestCase | |
def setup | |
@param = { | |
- "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => nil, # for HTMLBuilder | |
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
+ "stylesheet" => nil, # for HTMLBuilder | |
} | |
end | |
diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb | |
index f1ad017..c0158c7 100644 | |
--- a/test/test_latexbuilder.rb | |
+++ b/test/test_latexbuilder.rb | |
@@ -12,11 +12,9 @@ class LATEXBuidlerTest < Test::Unit::TestCase | |
@builder = LATEXBuilder.new() | |
@config = ReVIEW::Configure.values | |
@config.merge!( { | |
- "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder | |
+ "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder | |
"toclevel" => 2, | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => nil, # for EPUBBuilder | |
+ "stylesheet" => nil, # for EPUBBuilder | |
}) | |
@book = Book::Base.new(nil) | |
@book.config = @config | |
diff --git a/test/test_lineinput.rb b/test/test_lineinput.rb | |
index 219e3c1..8ef3406 100644 | |
--- a/test/test_lineinput.rb | |
+++ b/test/test_lineinput.rb | |
@@ -73,24 +73,6 @@ class LineInputTest < Test::Unit::TestCase | |
assert li.next? | |
end | |
- def test_skip_blank_lines | |
- if "".respond_to?(:encode) | |
- euc_jp_spc = " ".encode("EUC-JP") | |
- else | |
- euc_jp_spc = "\xa1\xa1" # EUC-JP 全角空白 | |
- end | |
- [ | |
- ["", 0, nil], | |
- ["\n \n \nabc", 3, 'abc'], | |
- ["\t", 1, nil], | |
- [euc_jp_spc, 0, euc_jp_spc], | |
- ].each do |text, n, rest| | |
- li = LineInput.new(StringIO.new(text)) | |
- assert_equal n, li.skip_blank_lines | |
- assert_equal rest, li.gets | |
- end | |
- end | |
- | |
def test_gets_if | |
io = StringIO.new | |
li = LineInput.new(io) | |
diff --git a/test/test_markdownbuilder.rb b/test/test_markdownbuilder.rb | |
index b34c7c8..d49ae02 100644 | |
--- a/test/test_markdownbuilder.rb | |
+++ b/test/test_markdownbuilder.rb | |
@@ -12,10 +12,8 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase | |
def setup | |
@builder = MARKDOWNBuilder.new() | |
@config = { | |
- "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
- "stylesheet" => nil, # for HTMLBuilder | |
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder | |
+ "stylesheet" => nil, # for HTMLBuilder | |
} | |
@book = Book::Base.new(nil) | |
@book.config = @config | |
@@ -74,6 +72,7 @@ BBB | |
assert_equal <<-EOS, actual | |
リスト1.1 caption | |
+ | |
``` | |
AAA | |
BBB | |
@@ -91,6 +90,7 @@ BBB | |
assert_equal <<-EOS, actual | |
リスト1.1 caption | |
+ | |
```ruby | |
AAA | |
BBB | |
@@ -109,6 +109,7 @@ BBB | |
assert_equal <<-EOS, actual | |
caption | |
+ | |
```ruby | |
AAA | |
BBB | |
diff --git a/test/test_pdfmaker.rb b/test/test_pdfmaker.rb | |
index 54caa96..fa5919f 100644 | |
--- a/test/test_pdfmaker.rb | |
+++ b/test/test_pdfmaker.rb | |
@@ -17,6 +17,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
"date" => "2011-01-01", | |
"language" => "ja", | |
}) | |
+ @maker.config = @config | |
@output = StringIO.new | |
I18n.setup(@config["language"]) | |
end | |
@@ -26,7 +27,8 @@ class PDFMakerTest < Test::Unit::TestCase | |
Dir.chdir(dir) do | |
pdf_file = File.join(dir, "sample.pdf") | |
FileUtils.touch(pdf_file) | |
- @maker.check_book(@config) | |
+ @maker.basedir = Dir.pwd | |
+ @maker.remove_old_file | |
assert !File.exist?(pdf_file) | |
end | |
end | |
@@ -35,13 +37,13 @@ class PDFMakerTest < Test::Unit::TestCase | |
def test_check_book_none | |
Dir.mktmpdir do |dir| | |
assert_nothing_raised do | |
- @maker.check_book(@config) | |
+ @maker.remove_old_file | |
end | |
end | |
end | |
def test_buildpath | |
- assert_equal(@maker.build_path(@config), "./sample-pdf") | |
+ assert_equal(@maker.build_path, "./sample-pdf") | |
end | |
def test_parse_opts_help | |
@@ -78,7 +80,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
"csl"=>["監修三郎"], | |
"trl"=>["翻訳四郎","翻訳五郎",]}) | |
Dir.mktmpdir do |dir| | |
- authors = @maker.make_authors(@config) | |
+ authors = @maker.make_authors | |
assert_equal("テスト太郎、テスト次郎 著 \\\\\n監修三郎 監修 \\\\\n翻訳四郎、翻訳五郎 訳", | |
authors) | |
end | |
@@ -87,7 +89,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
def test_make_authors_only_aut | |
@config.merge!({"aut"=>"テスト太郎"}) | |
Dir.mktmpdir do |dir| | |
- authors = @maker.make_authors(@config) | |
+ authors = @maker.make_authors | |
assert_equal("テスト太郎 著", authors) | |
end | |
end | |
@@ -104,7 +106,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
"prt"=>"テスト出版", | |
}) | |
Dir.mktmpdir do |dir| | |
- okuduke = @maker.make_colophon(@config) | |
+ okuduke = @maker.make_colophon | |
assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\n翻 訳 & 翻訳四郎、翻訳五郎 \\\\\nデザイン & デザイン六郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n表 紙 & 表紙九郎 \\\\\n編 集 & 編集十郎 \\\\\n発行所 & テスト出版 \\\\\n", | |
okuduke) | |
end | |
@@ -122,7 +124,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
}) | |
Dir.mktmpdir do |dir| | |
I18n.update({"prt" => "印刷所"},"ja") | |
- okuduke = @maker.make_colophon(@config) | |
+ okuduke = @maker.make_colophon | |
assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n発行所 & テスト出版 \\\\\n連絡先 & [email protected] \\\\\n印刷所 & テスト印刷 \\\\\n", | |
okuduke) | |
end | |
@@ -130,7 +132,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
def test_gettemplate | |
Dir.mktmpdir do |dir| | |
- tmpl = @maker.get_template(@config) | |
+ tmpl = @maker.get_template | |
expect = File.read(File.join(assets_dir,"test_template.tex")) | |
assert_equal(expect, tmpl) | |
end | |
@@ -157,8 +159,7 @@ class PDFMakerTest < Test::Unit::TestCase | |
expect = File.read(File.join(assets_dir,"test_template_backmatter.tex")) | |
- maker = ReVIEW::PDFMaker.new | |
- tmpl = maker.get_template(@config) | |
+ tmpl = @maker.get_template | |
tmpl.gsub!(/\A.*%% backmatter begins\n/m,"") | |
assert_equal(expect, tmpl) | |
end | |
diff --git a/test/test_template.rb b/test/test_template.rb | |
new file mode 100644 | |
index 0000000..3dedbfa | |
--- /dev/null | |
+++ b/test/test_template.rb | |
@@ -0,0 +1,26 @@ | |
+# encoding: utf-8 | |
+ | |
+require 'test_helper' | |
+require 'review/template' | |
+ | |
+class TemplateTest < Test::Unit::TestCase | |
+ include ReVIEW | |
+ | |
+ def setup | |
+ end | |
+ | |
+ def test_load | |
+ tmplfile = File.expand_path('./assets/test.xml.erb', File.dirname(__FILE__)) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ assert_equal("<test>\n<name></name>\n</test>\n",tmpl.result) | |
+ end | |
+ | |
+ def test_open_with_value | |
+ tmplfile = File.expand_path('./assets/test.xml.erb', File.dirname(__FILE__)) | |
+ tmpl = ReVIEW::Template.load(tmplfile) | |
+ @name = "test" | |
+ assert_equal("<test>\n<name>test</name>\n</test>\n",tmpl.result(binding)) | |
+ end | |
+end | |
+ | |
+ | |
diff --git a/test/test_topbuilder.rb b/test/test_topbuilder.rb | |
index acc935c..a1c52f7 100644 | |
--- a/test/test_topbuilder.rb | |
+++ b/test/test_topbuilder.rb | |
@@ -14,8 +14,6 @@ class TOPBuidlerTest < Test::Unit::TestCase | |
@config = ReVIEW::Configure.values | |
@config.merge!({ | |
"secnolevel" => 2, | |
- "inencoding" => "UTF-8", | |
- "outencoding" => "UTF-8", | |
"language" => "ja", | |
}) | |
@book = Book::Base.new(nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment