Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jekyll-pandoc-multiple-formats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edsl
jekyll-pandoc-multiple-formats
Commits
8e3dd169
Unverified
Commit
8e3dd169
authored
7 years ago
by
fauno
Browse files
Options
Downloads
Patches
Plain Diff
allow to skip some of the generation process
parent
1c063103
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+8
-3
8 additions, 3 deletions
README.md
lib/jekyll-pandoc-multiple-formats/config.rb
+18
-6
18 additions, 6 deletions
lib/jekyll-pandoc-multiple-formats/config.rb
lib/jekyll-pandoc-multiple-formats/generator.rb
+57
-43
57 additions, 43 deletions
lib/jekyll-pandoc-multiple-formats/generator.rb
with
83 additions
and
52 deletions
README.md
+
8
−
3
View file @
8e3dd169
...
@@ -34,7 +34,10 @@ Add to `_config.yml`:
...
@@ -34,7 +34,10 @@ Add to `_config.yml`:
markdown
:
pandoc
markdown
:
pandoc
pandoc
:
pandoc
:
skip
:
false
skip
:
full
:
false
posts
:
false
categories
:
false
bundle_permalink
:
'
:output_ext/:slug.:output_ext'
bundle_permalink
:
'
:output_ext/:slug.:output_ext'
papersize
:
'
a5paper'
papersize
:
'
a5paper'
sheetsize
:
'
a4paper'
sheetsize
:
'
a4paper'
...
@@ -59,8 +62,10 @@ pandoc:
...
@@ -59,8 +62,10 @@ pandoc:
*
`markdown: pandoc`
will instruct jekyll to use the pandoc html
*
`markdown: pandoc`
will instruct jekyll to use the pandoc html
converter.
converter.
*
`skip`
allows you to skip the other formats generation and proceed with the
*
`skip`
allows you to skip the other formats generation and proceed
regular jekyll site build.
with the regular jekyll site build. You can skip some of the
generation process or all of it. Older versions of this plugin
required
`true`
or
`false`
to skip the process altogether.
*
`full_flags`
if
`full_file`
is defined, these flags are used on it.
*
`full_flags`
if
`full_file`
is defined, these flags are used on it.
By default are set to
`--top-level-division=part`
so each category is
By default are set to
`--top-level-division=part`
so each category is
...
...
This diff is collapsed.
Click to expand it.
lib/jekyll-pandoc-multiple-formats/config.rb
+
18
−
6
View file @
8e3dd169
module
JekyllPandocMultipleFormats
module
JekyllPandocMultipleFormats
class
Config
class
Config
DEFAULTS
=
{
DEFAULTS
=
{
'skip'
=>
false
,
'skip'
=>
{
'posts'
=>
false
,
'categories'
=>
false
,
'full'
=>
false
},
'bundle_permalink'
=>
':output_ext/:slug.:output_ext'
,
'bundle_permalink'
=>
':output_ext/:slug.:output_ext'
,
'papersize'
=>
'a5paper'
,
'papersize'
=>
'a5paper'
,
'sheetsize'
=>
'a4paper'
,
'sheetsize'
=>
'a4paper'
,
...
@@ -23,7 +27,7 @@ module JekyllPandocMultipleFormats
...
@@ -23,7 +27,7 @@ module JekyllPandocMultipleFormats
end
end
def
skip?
def
skip?
@config
[
'skip'
]
@config
[
'skip'
]
.
values
.
all?
end
end
def
imposition?
def
imposition?
...
@@ -34,13 +38,21 @@ module JekyllPandocMultipleFormats
...
@@ -34,13 +38,21 @@ module JekyllPandocMultipleFormats
@config
[
'binder'
]
@config
[
'binder'
]
end
end
def
full_file?
@config
[
'full_file'
]
end
# TODO magic
# TODO magic
def
outputs
def
outputs
@config
[
'outputs'
]
@config
[
'outputs'
]
end
end
def
generate_posts?
!
@config
.
dig
(
'skip'
,
'posts'
)
end
def
generate_categories?
!
@config
.
dig
(
'skip'
,
'categories'
)
end
def
generate_full_file?
!
@config
.
dig
(
'skip'
,
'full'
)
end
end
end
end
end
This diff is collapsed.
Click to expand it.
lib/jekyll-pandoc-multiple-formats/generator.rb
+
57
−
43
View file @
8e3dd169
...
@@ -28,23 +28,12 @@ class PandocGenerator < Generator
...
@@ -28,23 +28,12 @@ class PandocGenerator < Generator
attr_accessor
:site
,
:config
attr_accessor
:site
,
:config
def
generate
(
site
)
def
generate_post_for_output
(
post
,
output
)
@site
||=
site
@config
||=
JekyllPandocMultipleFormats
::
Config
.
new
(
@site
.
config
[
'pandoc'
])
return
if
@config
.
skip?
# we create a single array of files
@pandoc_files
=
[]
@config
.
outputs
.
each_pair
do
|
output
,
_
|
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating
#{
output
}
"
@site
.
posts
.
docs
.
each
do
|
post
|
Jekyll
.
logger
.
debug
'Pandoc:'
,
post
.
data
[
'title'
]
Jekyll
.
logger
.
debug
'Pandoc:'
,
post
.
data
[
'title'
]
Jekyll
::
Hooks
.
trigger
:posts
,
:pre_render
,
post
,
{
format:
output
}
Jekyll
::
Hooks
.
trigger
:posts
,
:pre_render
,
post
,
{
format:
output
}
pandoc_file
=
PandocFile
.
new
(
@site
,
output
,
post
)
pandoc_file
=
PandocFile
.
new
(
@site
,
output
,
post
)
next
unless
pandoc_file
.
write
return
unless
pandoc_file
.
write
Jekyll
::
Hooks
.
trigger
:posts
,
:post_render
,
post
,
{
format:
output
}
Jekyll
::
Hooks
.
trigger
:posts
,
:post_render
,
post
,
{
format:
output
}
...
@@ -52,24 +41,24 @@ class PandocGenerator < Generator
...
@@ -52,24 +41,24 @@ class PandocGenerator < Generator
@pandoc_files
<<
pandoc_file
@pandoc_files
<<
pandoc_file
end
end
@site
.
post_attr_hash
(
'categories'
).
each_pair
do
|
title
,
posts
|
def
generate_category_for_output
(
category
,
posts
,
output
)
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating category
#{
title
}
"
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating category
#{
category
}
"
posts
.
sort!
posts
.
sort!
pandoc_file
=
PandocFile
.
new
(
@site
,
output
,
posts
,
title
)
pandoc_file
=
PandocFile
.
new
(
@site
,
output
,
posts
,
category
)
if
@site
.
keep_files
.
include?
pandoc_file
.
relative_path
if
@site
.
keep_files
.
include?
pandoc_file
.
relative_path
puts
"
#{
pandoc_file
.
relative_path
}
is a category file AND a post file"
Jekyll
.
logger
.
warn
'Pandoc:'
,
puts
'c
hange the category name to fix this
'
"
#{
pandoc_file
.
relative_path
}
is a category file AND a post file. C
hange the category name to fix this
"
next
return
end
end
next
unless
pandoc_file
.
write
return
unless
pandoc_file
.
write
@site
.
keep_files
<<
pandoc_file
.
relative_path
@site
.
keep_files
<<
pandoc_file
.
relative_path
@pandoc_files
<<
pandoc_file
@pandoc_files
<<
pandoc_file
end
end
if
@config
.
full_file?
def
general_full_for_output
(
output
)
title
=
@site
.
config
.
dig
(
'title'
)
title
=
@site
.
config
.
dig
(
'title'
)
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating full file
#{
title
}
"
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating full file
#{
title
}
"
# For parts to make sense, we order articles by date and then by
# For parts to make sense, we order articles by date and then by
...
@@ -87,6 +76,31 @@ class PandocGenerator < Generator
...
@@ -87,6 +76,31 @@ class PandocGenerator < Generator
@site
.
keep_files
<<
full_file
.
relative_path
@site
.
keep_files
<<
full_file
.
relative_path
@pandoc_files
<<
full_file
@pandoc_files
<<
full_file
end
end
def
generate
(
site
)
@site
||=
site
@config
||=
JekyllPandocMultipleFormats
::
Config
.
new
(
@site
.
config
[
'pandoc'
])
return
if
@config
.
skip?
# we create a single array of files
@pandoc_files
=
[]
@config
.
outputs
.
each_pair
do
|
output
,
_
|
Jekyll
.
logger
.
info
'Pandoc:'
,
"Generating
#{
output
}
"
if
@config
.
generate_posts?
@site
.
posts
.
docs
.
each
do
|
post
|
generate_post_for_output
post
,
output
end
end
if
@config
.
generate_categories?
@site
.
post_attr_hash
(
'categories'
).
each_pair
do
|
title
,
posts
|
generate_category_for_output
title
,
posts
,
output
end
end
general_full_for_output
(
output
)
if
@config
.
generate_full_file?
end
end
@pandoc_files
.
each
do
|
pandoc_file
|
@pandoc_files
.
each
do
|
pandoc_file
|
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment