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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edsl
jekyll-pandoc-multiple-formats
Commits
0e4749d7
Commit
0e4749d7
authored
Apr 10, 2022
by
fauno
Browse files
Options
Downloads
Patches
Plain Diff
convert from other formats
parent
28167871
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
lib/jekyll-pandoc-multiple-formats.rb
+1
-0
1 addition, 0 deletions
lib/jekyll-pandoc-multiple-formats.rb
lib/jekyll/pandoc/converter.rb
+58
-0
58 additions, 0 deletions
lib/jekyll/pandoc/converter.rb
lib/jekyll/pandoc/renderer.rb
+3
-2
3 additions, 2 deletions
lib/jekyll/pandoc/renderer.rb
with
62 additions
and
2 deletions
lib/jekyll-pandoc-multiple-formats.rb
+
1
−
0
View file @
0e4749d7
...
...
@@ -7,6 +7,7 @@ require_relative 'jekyll/pandoc/generators/category'
require_relative
'jekyll/pandoc/generators/site'
require_relative
'jekyll/pandoc/generators/imposition'
require_relative
'jekyll/pandoc/generators/binder'
require_relative
'jekyll/pandoc/converter'
# We modify the configuration post read, and not after init, because
# Jekyll resets twice and any modification to config will invalidate the
...
...
This diff is collapsed.
Click to expand it.
lib/jekyll/pandoc/converter.rb
0 → 100644
+
58
−
0
View file @
0e4749d7
# frozen_string_literal: true
require
'jekyll/converter'
require_relative
'paru_helper'
module
Jekyll
module
Pandoc
module
Converter
# Input formats supported by Pandoc that make sense to convert
# into HTML.
#
# @return [Array]
# @param ext [String]
# @return [Boolean]
def
matches
(
ext
)
".
#{
self
.
class
::
EXT
}
"
==
ext
.
downcase
end
# Convert into HTML
#
# @return [String]
def
output_ext
(
_
)
'.html'
end
# @param content [String]
# @return [String]
def
convert
(
content
)
parser
<<
content
end
private
# Generates a parser from config
#
# @return [Paru::Pandoc]
def
parser
@parser
||=
ParuHelper
.
from
(
from:
self
.
class
::
EXT
,
to:
'html5'
,
metadata:
'title=Jekyll'
,
**
@config
[
'pandoc'
].
options
[
:html5
])
end
end
end
end
%w[creole docbook docx dokuwiki haddock ipnyb jira mediawiki man muse odt org rst t2t textile tikiwiki twiki
vimwiki]
.
each
do
|
format
|
converter
=
Class
.
new
(
Jekyll
::
Converter
)
converter
.
class_exec
(
format
)
do
|
f
|
const_set
:EXT
,
f
include
Jekyll
::
Pandoc
::
Converter
safe
true
end
Object
.
const_set
format
.
capitalize
,
converter
end
This diff is collapsed.
Click to expand it.
lib/jekyll/pandoc/renderer.rb
+
3
−
2
View file @
0e4749d7
...
...
@@ -36,7 +36,8 @@ module Jekyll
f
.
write
content
end
ParuHelper
.
from
(
from:
'markdown'
,
to:
type
,
**
site
.
config
[
'pandoc'
].
options
[
type
],
**
extra
)
<<
content
ParuHelper
.
from
(
from:
document
.
extname
.
sub
(
'.'
,
''
),
to:
type
,
**
site
.
config
[
'pandoc'
].
options
[
type
],
**
extra
)
<<
content
end
# Don't convert Markdown to HTML, but do convert everything else
...
...
@@ -44,7 +45,7 @@ module Jekyll
# @return [array]
def
converters
@converters
||=
super
.
reject
do
|
c
|
c
.
instance_of?
Jekyll
::
Converters
::
Markdown
c
.
instance_of?
(
Jekyll
::
Converters
::
Markdown
)
||
c
.
instance_of?
(
Jekyll
::
Pandoc
::
Converter
)
end
end
...
...
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