paru 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/paru.rb +1 -0
- data/lib/paru/filter.rb +73 -0
- data/lib/paru/pandoc_options.yaml +78 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53ebb5ef05d8311f13bf03b471607000822e754e
|
4
|
+
data.tar.gz: e5c206fc7f2de955144b75e58a3a2e6b1041ac01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38786b1b92d6f10d09cebc11b9e7b49a97546437c90d1a886e964fbdcee4d3d3867aa781e30b285123921cd9d4380dd0bed7d637c2e228281892a7b14a3538dd
|
7
|
+
data.tar.gz: 890a3b60a25c13932b11c1642ef24c3021a298a91c95febd74aef744d83a08158079fd1bdc483c27e1c6ccd715ab75b8209a2d8c1b9324e819dea8329f922ec1
|
data/lib/paru.rb
CHANGED
data/lib/paru/filter.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
module Paru
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Filter
|
6
|
+
|
7
|
+
def self.ast &filter
|
8
|
+
ast_hash = JSON.parse $stdin.read
|
9
|
+
warn ast_hash
|
10
|
+
ast_tree = yield AST.new ast_hash
|
11
|
+
$stdout.write JSON.generate ast_tree.to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class AST
|
17
|
+
|
18
|
+
def initialize ast_hash
|
19
|
+
@metadata = Meta.new ast_hash.first
|
20
|
+
@content = ast_hash.last.map {|n| Node.new n}
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_h
|
24
|
+
[@metadata.to_h].push @content.map {|n| n.to_h }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# see
|
30
|
+
# http://hackage.haskell.org/package/pandoc-types-1.12.4.1/docs/Text-Pandoc-Definition.html
|
31
|
+
# for spec of different kinds of nodes
|
32
|
+
|
33
|
+
class Meta
|
34
|
+
|
35
|
+
def initialize(hash)
|
36
|
+
hash = hash["unMeta"]
|
37
|
+
@content = {}
|
38
|
+
hash.keys.each {|key| @content[key] = Node.new hash[key]}
|
39
|
+
end
|
40
|
+
|
41
|
+
def [](key)
|
42
|
+
@content[key]
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_h
|
46
|
+
hash = {}
|
47
|
+
@content.keys.each {|key| hash[key] = @content[key].to_h}
|
48
|
+
{"unMeta" => hash}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Node
|
53
|
+
|
54
|
+
attr_reader :type, :contents
|
55
|
+
|
56
|
+
def initialize(ast_hash)
|
57
|
+
@type = ast_hash["t"]
|
58
|
+
@contents = ast_hash["c"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_h
|
62
|
+
{
|
63
|
+
"t" => @type,
|
64
|
+
"c" => @contents
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# See http://pandoc.org/README.html for an overview of all options
|
2
|
+
#
|
3
|
+
# General options
|
4
|
+
from: ""
|
5
|
+
to: ""
|
6
|
+
output: ""
|
7
|
+
data_dir: ""
|
8
|
+
# Reader options
|
9
|
+
parse_raw: true
|
10
|
+
smart: true
|
11
|
+
old_dashes: true
|
12
|
+
base_header_level: 1
|
13
|
+
indented_code_classes: ""
|
14
|
+
default_image_extension: ""
|
15
|
+
filter: [""]
|
16
|
+
metadata: [""]
|
17
|
+
normalize: true
|
18
|
+
preserve_tabls: true
|
19
|
+
tab_stop: 4
|
20
|
+
track_changes: "accept"
|
21
|
+
extract_media: true
|
22
|
+
# General writer options
|
23
|
+
standalone: true
|
24
|
+
template: ""
|
25
|
+
variable: [""]
|
26
|
+
no_wrap: true
|
27
|
+
columns: 78
|
28
|
+
toc: true
|
29
|
+
table_of_contents: true
|
30
|
+
toc_depth: 3
|
31
|
+
no_highlight: true
|
32
|
+
highlight_style: "pygments"
|
33
|
+
include_in_header: [""]
|
34
|
+
include_before_body: [""]
|
35
|
+
include_after_body: [""]
|
36
|
+
# Options affecting specific writers
|
37
|
+
self_contained: true
|
38
|
+
offline: true
|
39
|
+
html5: true
|
40
|
+
html_q_tags: true
|
41
|
+
ascii: true
|
42
|
+
reference_links: true
|
43
|
+
atx_headers: true
|
44
|
+
chapters: true
|
45
|
+
number_sections: true
|
46
|
+
number_offset: "0"
|
47
|
+
no_tex_ligatures: true
|
48
|
+
listings: true
|
49
|
+
incremental: true
|
50
|
+
slide_level: 1
|
51
|
+
section_divs: true
|
52
|
+
email_obfuscation: "none"
|
53
|
+
id_prefix: ""
|
54
|
+
title_prefix: ""
|
55
|
+
css: [""]
|
56
|
+
reference_odt: ""
|
57
|
+
reference_docx: ""
|
58
|
+
epub_stylesheet: "epub.css"
|
59
|
+
epub_metadata: ""
|
60
|
+
epub_embed_font: ""
|
61
|
+
epub_chapter_level: 1
|
62
|
+
latex_engine: "pdflatex"
|
63
|
+
# Citation rendering
|
64
|
+
bibliography: ""
|
65
|
+
csl: ""
|
66
|
+
citation_abbreviations: ""
|
67
|
+
natbib: true
|
68
|
+
biblatex: true
|
69
|
+
# Math rendering in HTML
|
70
|
+
latexmathml: ""
|
71
|
+
mathml: ""
|
72
|
+
jsmath: ""
|
73
|
+
mathjax: ""
|
74
|
+
gladtex: true
|
75
|
+
mimetex: ""
|
76
|
+
webtex: ""
|
77
|
+
katex: ""
|
78
|
+
katex_stylesheet: ""
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huub de Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Use Pandoc (http://www.pandoc.org) with ruby
|
14
14
|
email: Huub@heerdebeer.org
|
@@ -17,8 +17,10 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/paru.rb
|
20
|
+
- lib/paru/filter.rb
|
20
21
|
- lib/paru/pandoc.rb
|
21
|
-
|
22
|
+
- lib/paru/pandoc_options.yaml
|
23
|
+
homepage: https://github.com/htdebeer/paru
|
22
24
|
licenses:
|
23
25
|
- GPL3
|
24
26
|
metadata: {}
|