riven 1.0.5 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49db77b6056da944f983b5eb47a5c80712d06c38
4
- data.tar.gz: 6bf4f0531cf396c65d863260c86f8f4b937d1348
3
+ metadata.gz: 831577b3a79f946e421a4710dfe66a73dd6b2afd
4
+ data.tar.gz: b4f642c8fc4bc5b83927798ef4603bb95e26108e
5
5
  SHA512:
6
- metadata.gz: 65acb17d1e06ab9bb28f1593eb2098e13bc25edf961e630dee0141fb61f657f12b74f968acfacf4239f0d4d8feacaf6823b55135f3c2153e47e2ba82b18d0763
7
- data.tar.gz: e05c2d0a43166056203c068728be31222b723d8e0eba99b9d88e353c27e0d23f441f06adcc8afba7f107282f6f2c73de4c699806892833713547e994099b2172
6
+ metadata.gz: b49782dbf7139d91c61e55996bf75eaa02df06c196ef22096606852d93f73f505774ecbddf05d66a91397f5a360ce278c2c5dd201fd3ee1001ffb0bc44a7a8a4
7
+ data.tar.gz: 6becb3aa12e1f2e1fd90d297a0f8536081cfeea329ee6d89668068cf25e476e5080ffdc10f358e46638075d7491849223d790f63fb3e5b3f531dd56d0ece1f13
data/.gitignore CHANGED
@@ -17,7 +17,6 @@ build/
17
17
  ## Documentation cache and generated files:
18
18
  /.yardoc/
19
19
  /_yardoc/
20
- /doc/
21
20
  /rdoc/
22
21
 
23
22
  ## Environment normalisation:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- riven (1.0.2)
4
+ riven (1.1.1)
5
5
  coderay (~> 1.1)
6
6
  redcarpet (~> 3.2)
7
7
 
data/README.md CHANGED
@@ -1,38 +1,46 @@
1
1
  # Riven
2
2
 
3
- Converts GitHub Flavored Markdown files to PDFs! Feature highlights:
3
+ Riven converts Markdown files to PDFs! Write documentations, books, reports and documents with your editor.
4
+ Publish them as PDF! It's that simple and even more powerful.
4
5
 
5
- - Highly readable PDFs with GitHub like theme
6
+
7
+ Feature highlights:
8
+
9
+ - Riven Extended Markdown (it's GitHub Flavored Markdown but with more features!)
10
+ - Includes: Structure you work!
11
+ - Generates well readable, optimized, beautiful looking PDFs
12
+ - Style your PDF via CSS
13
+ - Define a special and nice looking cover page
14
+ - Auto generated table of contents
6
15
  - Syntax Highlighting with GitHub like theme
7
- - Smart page breaks
8
- - Smart directory based file merging
9
- - Smart output file naming
10
- - Page numbers (see *Prerequisites* section)
11
- - Custom CSS
12
- - Covers (see *Prerequisites* section)
13
- - Table of Contents (see *Prerequisites* section)
16
+ - Page numbers
17
+ - Smart directory based file merging and output file naming
14
18
 
15
19
 
16
20
  ## Prerequisites
17
21
 
18
- You need `wkhtmltopdf` in order to generate PDFs, since that's the PDF generator backend for riven. You should use the QT patched version of `wkhtmltopdf`. You may also use the version without patched qt, but that will disable the following features of riven: Page numbers, table of contents, covers.
22
+ You need `wkhtmltopdf` in order to generate PDFs, since that's the PDF generator backend for riven. You should use the
23
+ QT patched version of `wkhtmltopdf` to get all the features of riven. You may also use the version without patched qt,
24
+ but that will disable the following features of riven: Page numbers, table of contents, covers.
19
25
 
20
26
  - If you got Arch Linux, you can just install the packages `wkhtmltopdf-static`and `icu48` from the AUR.
21
27
 
22
- - If you got another Linux Distribution (like Ubuntu) or OSX you have compile `wkhtmltopdf` from the sources. See http://natepinchot.com/2014/01/31/building-static-wkhtmltopdf/. This may take some time: On my i7, 16GB RAM, SSD Notebook it took about 20 minutes.
28
+ - If you got another Linux Distribution (like Ubuntu) or OSX you have compile `wkhtmltopdf` from the sources. See http://natepinchot.com/2014/01/31/building-static-wkhtmltopdf/. This may take some time: On my i7, 16GB RAM, SSD
29
+ Notebook it took about 20 minutes.
23
30
 
24
31
  - Otherwise, you should download `wkhtmltopdf` from the [official website](http://wkhtmltopdf.org/downloads.html).
25
32
 
26
33
  After that, make sure you can execute the `wkhtmltopdf` command in your shell:
27
34
 
28
35
  ```bash
29
- $ wkhtmltopdf -v
36
+ $ wkhtmltopdf -V
30
37
  ```
31
38
 
32
- If it works, everything is nice and you may proceed with the next step. If not, please make sure, `wkhtmltopdf` is correctly installed and the executable is within your `PATH`.
39
+ If it works, everything is nice and you may proceed with the next step. If not, please make sure, `wkhtmltopdf` is
40
+ correctly installed and the executable is within your `PATH`.
33
41
 
34
42
 
35
- ## Installation
43
+ ## Getting started right now
36
44
 
37
45
  Simple as usual:
38
46
 
@@ -41,19 +49,33 @@ $ gem install riven
41
49
  ```
42
50
 
43
51
 
44
- ## Usage
45
-
46
- Riven is designed to create documents out of a bunch of markdown files. So it may take a single markdown file or a directory with some markdown files inside. Consider that the files are merged in alphabetical order if you provide a folder. Just take a look at the following examples.
47
-
52
+ ## How to use it?
48
53
 
49
- ### Single file to PDF
54
+ Riven is designed to create documents out of a bunch of markdown files. So it may take a single markdown file or a
55
+ directory with some markdown files inside.
50
56
 
51
- This will take your `example.md` and generate a `example.pdf` in the same directory:
57
+ However the basic usage is very simple. This example will take your `example.md` and generate a `example.pdf` in the
58
+ same directory:
52
59
 
53
60
  ```bash
54
61
  $ riven example.md
55
62
  ```
56
63
 
64
+ Couldn't be easier!
65
+
66
+
67
+ ## Looking for an example?
68
+
69
+ You'll find a considerable example of a markdown based documentation in the doc directory of riven itself. And **here**
70
+ you finde the resulting PDF with the documentation of riven.
71
+
72
+
73
+
74
+
75
+ ### Single file to PDF
76
+
77
+
78
+
57
79
 
58
80
  ### Multiple files
59
81
 
@@ -66,7 +88,9 @@ $ riven -o awesome.pdf example-1.md example-2.pdf
66
88
 
67
89
  ### A directory
68
90
 
69
- This will take your `documentation` directory with all it's files and generate a `documentation.pdf` (the name is guessed from the directory name, but you may also specify a output file name via the `-o` param) in the same directory:
91
+ This will take your `documentation` directory with all it's files and generate a `documentation.pdf` (the name is
92
+ guessed from the directory name, but you may also specify a output file name via the `-o` param) in the same
93
+ directory:
70
94
 
71
95
  ```bash
72
96
  $ ls
@@ -87,6 +111,34 @@ documentation/
87
111
  ```
88
112
 
89
113
 
114
+ ### Structure via includes
115
+
116
+ You may also structure your document via includes. Just define a main file and you may define as many include directives
117
+ within that file and any other files (even in subdirectories) as you want.
118
+
119
+ **index.md**
120
+
121
+ ```md
122
+ ## Just a example
123
+
124
+ This is a include:
125
+
126
+ <<[ another_file.md ]
127
+ ```
128
+
129
+ **another_file.md**
130
+
131
+ ```md
132
+ More **content** in this file.
133
+ ```
134
+
135
+ Generate the PDF via:
136
+
137
+ ```bash
138
+ $ riven -o awesome.pdf index.md
139
+ ```
140
+
141
+
90
142
  ## Additional Features
91
143
 
92
144
  ### Custom CSS
@@ -0,0 +1,15 @@
1
+ ## 1. What is Riven?
2
+
3
+ In one sentence: Riven is a command line tool, which converts a bunch of markdown files into a PDF file.
4
+
5
+ **The question is: Why would you do that?**
6
+
7
+ There are several scenarios where the usage off a tool like riven would make a lot of sense for you. Let's take a look
8
+ at some of them:
9
+
10
+ <<[ 1-scenario-a.md ]
11
+ <<[ 2-scenario-b.md ]
12
+
13
+ <<[ 3-what-is-riven-not.md ]
14
+ <<[ 4-why-was-riven-created.md ]
15
+ <<[ 5-how-can-i-support-riven.md ]
File without changes
File without changes
File without changes
data/doc/cover.md ADDED
@@ -0,0 +1,39 @@
1
+ <br />
2
+ <br />
3
+ <br />
4
+ <br />
5
+ <br />
6
+ <br />
7
+
8
+ ![riven](img/cover.png)
9
+
10
+ <br />
11
+ <br />
12
+ <br />
13
+ <br />
14
+ <br />
15
+ <br />
16
+ <br />
17
+ <br />
18
+
19
+ # Official Riven Manual
20
+ ## Write Markdown. Get a nice PDF. Have fun.
21
+
22
+
23
+ <br />
24
+ <br />
25
+ <br />
26
+ <br />
27
+ <br />
28
+ <br />
29
+ <br />
30
+ <br />
31
+ <br />
32
+ <br />
33
+ <br />
34
+ <br />
35
+
36
+
37
+ -----
38
+
39
+ powered by Benjamin Kammerl | visit *[github.com/phortx/riven](https://github.com/phortx/riven)* | MIT license
data/doc/img/cover.png ADDED
Binary file
data/doc/index.md ADDED
@@ -0,0 +1,4 @@
1
+ <<[ chapters/1-what-is-riven/index.md ]
2
+ <<[ chapters/2-setup/index.md ]
3
+ <<[ chapters/3-basics/index.md ]
4
+ <<[ chapters/4-advanced-usage/index.md ]
data/doc/riven.pdf ADDED
Binary file
@@ -1,10 +1,12 @@
1
+ require 'pathname'
2
+
1
3
  module Riven
2
4
  #
3
5
  # Represents a MD File
4
6
  #
5
7
 
6
8
  class MarkupFile
7
- attr_accessor :path
9
+ attr_reader :path, :dirname, :markup
8
10
 
9
11
 
10
12
  #
@@ -14,6 +16,7 @@ module Riven
14
16
 
15
17
  public def initialize(path)
16
18
  @path = File.expand_path(path)
19
+ @dirname = Pathname.new(path).dirname
17
20
 
18
21
  unless File.exists?(@path)
19
22
  raise "File '#{path}' doesn't exist"
@@ -22,6 +25,49 @@ module Riven
22
25
  if File.directory?(@path)
23
26
  raise "Mixing files and directories is not allowed, sorry"
24
27
  end
28
+
29
+ puts "Loading file: " + path
30
+ @markup = "\n" + File.read(@path)
31
+ rewrite_paths
32
+ resolve_includes
33
+ end
34
+
35
+
36
+ #
37
+ # Recursive replace all includes with their respective file content
38
+ #
39
+
40
+ public def resolve_includes
41
+ loop do
42
+ non_found = true
43
+
44
+ @markup.gsub!(/<<\[\s*([^\]\s]+)\s*\]/) do |inc|
45
+ non_found = false
46
+ MarkupFile.new(@dirname.to_s + '/' + $1).markup
47
+ end
48
+
49
+ break if non_found
50
+ end
51
+ end
52
+
53
+
54
+ #
55
+ # Prefixes all paths with the file basedir in order to make everything working across includes over different
56
+ # directories
57
+ #
58
+
59
+ public def rewrite_paths
60
+ @markup.gsub!(/\[([^\]]+)\]\(([^\)]+)\)/) do |ref|
61
+ label = $1
62
+ ref = $2
63
+
64
+ if $2 =~ /^http(s)?/
65
+ "[#{label}](#{ref})"
66
+ else
67
+ puts " - Rewriting ref '#{ref}' to '#{@dirname}/#{ref}'"
68
+ "[#{label}](#{@dirname}/#{ref})"
69
+ end
70
+ end
25
71
  end
26
72
 
27
73
 
@@ -33,7 +79,9 @@ module Riven
33
79
  except = [except] unless except.respond_to?(:each)
34
80
 
35
81
  markup_files.each do |file|
36
- markup << "\n\n" + File.read(file.path) unless exclude?(except, file)
82
+ unless exclude?(except, file)
83
+ markup << "\n" + file.markup
84
+ end
37
85
  end
38
86
 
39
87
  return markup
@@ -50,4 +98,4 @@ module Riven
50
98
  end
51
99
  end
52
100
  end
53
- end
101
+ end
data/lib/riven/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Riven
2
- VERSION = '1.0.5'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riven
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Kammerl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,14 @@ files:
81
81
  - README.md
82
82
  - bin/riven
83
83
  - css/style.css
84
+ - doc/chapters/1-what-is-riven/index.md
85
+ - doc/chapters/2-setup/index.md
86
+ - doc/chapters/3-basics/index.md
87
+ - doc/chapters/4-advanced-usage/index.md
88
+ - doc/cover.md
89
+ - doc/img/cover.png
90
+ - doc/index.md
91
+ - doc/riven.pdf
84
92
  - lib/riven.rb
85
93
  - lib/riven/html_file.rb
86
94
  - lib/riven/html_generator.rb