asciidoctor-legal 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa2f6d9c8e29ab26480a0eb453198ef14c99e796
4
+ data.tar.gz: 5264c7c21b94caaba4bcb62618de7f8242dec12e
5
+ SHA512:
6
+ metadata.gz: caa3dcba2b5f5e951c7484ffc27074dfa0296e9ab563504d916920310c317ac171fe748dcb0bf3c1952331c0662c8c85285f93cc8b9a88020adc423b84efe01c
7
+ data.tar.gz: 4754982ae7d9f46f8edb553eb55dd6cd4b86b9a9aac4e07b787caab979cfdde65bf6d246bbdda540d24fd823bc473c1e6140d59795c3d98f8e06e0af23c3e411
@@ -0,0 +1,7 @@
1
+ require 'asciidoctor'
2
+ require 'asciidoctor/extensions'
3
+ require_relative 'asciidoctor-legal/legal'
4
+
5
+ Asciidoctor::Extensions.register do
6
+ inline_macro Asciidoctor::Legal::InlineMacro
7
+ end
@@ -0,0 +1,23 @@
1
+ require "nokogiri"
2
+
3
+ module Asciidoctor
4
+ module Legal
5
+
6
+ class InlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
7
+
8
+ use_dsl
9
+ named :legal
10
+ content_model :simple
11
+
12
+ def process(parent, target, attrs)
13
+ counter_name = "legalparagraphcounter"
14
+ counter_format = attrs['text'].empty? ? "%04d" : attrs['text']
15
+ counter = counter_format%parent.document.counter(counter_name)
16
+ parent.document.register(:ids, [target, "[#{counter}]"])
17
+ %(<span id="#{target}"><b>[#{counter}]</b></span>)
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Asciidoctor
2
+ module Legal
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ require "test/unit"
2
+ require "asciidoctor"
3
+ require "stringio"
4
+ require "nokogiri"
5
+ require "asciidoctor-legal"
6
+
7
+ DOC_BASIC = <<-eos
8
+ = Hello PlantUML!
9
+
10
+ This is a test paragraph without anchor.
11
+
12
+ legal:s1p1[sec1-p1%05d] This is a test paragraph with anchor.
13
+
14
+ legal:s2p2[] This is a test paragraph with anchor.
15
+
16
+ legal:p3[] This is a test paragraph with anchor.
17
+
18
+ this is a link to the p1 <<s1p1>> paragraph.
19
+ eos
20
+
21
+ DOC_RESULT = <<-EOS
22
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
23
+ <html><body>
24
+ <div class="paragraph">
25
+ <p>This is a test paragraph without anchor.</p>
26
+ </div>
27
+ <div class="paragraph">
28
+ <p><span id="s1p1"><b>[sec1-p100001]</b></span> This is a test paragraph with anchor.</p>
29
+ </div>
30
+ <div class="paragraph">
31
+ <p><span id="s2p2"><b>[0002]</b></span> This is a test paragraph with anchor.</p>
32
+ </div>
33
+ <div class="paragraph">
34
+ <p><span id="p3"><b>[0003]</b></span> This is a test paragraph with anchor.</p>
35
+ </div>
36
+ <div class="paragraph">
37
+ <p>this is a link to the p1 <a href="#s1p1">[sec1-p100001]</a> paragraph.</p>
38
+ </div>
39
+ </body></html>
40
+ EOS
41
+
42
+ class LegalTest < Test::Unit::TestCase
43
+
44
+ def test_paragraph_anchors_inline_processor
45
+ html = ::Asciidoctor.convert(StringIO.new(DOC_BASIC), backend: "html5")
46
+ page = Nokogiri::HTML(html)
47
+ assert_equal page.to_s, DOC_RESULT
48
+ end
49
+
50
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-legal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Horacio Sanson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: asciidoctor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ description: Asciidoctor legal extension
70
+ email:
71
+ - hsanson@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/asciidoctor-legal.rb
77
+ - lib/asciidoctor-legal/legal.rb
78
+ - lib/asciidoctor-legal/version.rb
79
+ - test/test_legal.rb
80
+ homepage: https://github.com/hsanson/asciidoctor-legal
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.5.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Extensions and features tailred at writing legal documents like patents and
104
+ contracts.
105
+ test_files:
106
+ - test/test_legal.rb