markly 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/conduct.md +133 -0
  4. data/ext/markly/arena.c +9 -8
  5. data/ext/markly/autolink.c +217 -134
  6. data/ext/markly/blocks.c +27 -2
  7. data/ext/markly/cmark-gfm-core-extensions.h +11 -11
  8. data/ext/markly/cmark-gfm-extension_api.h +1 -0
  9. data/ext/markly/cmark-gfm.h +18 -2
  10. data/ext/markly/cmark.c +3 -3
  11. data/ext/markly/commonmark.c +19 -34
  12. data/ext/markly/extconf.rb +8 -1
  13. data/ext/markly/html.c +22 -6
  14. data/ext/markly/inlines.c +148 -51
  15. data/ext/markly/latex.c +6 -4
  16. data/ext/markly/man.c +7 -11
  17. data/ext/markly/map.c +11 -4
  18. data/ext/markly/map.h +5 -2
  19. data/ext/markly/markly.c +582 -586
  20. data/ext/markly/markly.h +1 -1
  21. data/ext/markly/node.c +76 -10
  22. data/ext/markly/node.h +42 -1
  23. data/ext/markly/parser.h +1 -0
  24. data/ext/markly/plaintext.c +12 -29
  25. data/ext/markly/references.c +1 -0
  26. data/ext/markly/render.c +15 -7
  27. data/ext/markly/scanners.c +13916 -10380
  28. data/ext/markly/scanners.h +8 -0
  29. data/ext/markly/scanners.re +47 -8
  30. data/ext/markly/strikethrough.c +1 -1
  31. data/ext/markly/table.c +81 -31
  32. data/ext/markly/xml.c +2 -1
  33. data/lib/markly/flags.rb +16 -0
  34. data/lib/markly/node/inspect.rb +59 -53
  35. data/lib/markly/node.rb +125 -58
  36. data/lib/markly/renderer/generic.rb +129 -124
  37. data/lib/markly/renderer/html.rb +294 -275
  38. data/lib/markly/version.rb +7 -1
  39. data/lib/markly.rb +36 -30
  40. data/license.md +39 -0
  41. data/readme.md +36 -0
  42. data.tar.gz.sig +0 -0
  43. metadata +61 -29
  44. metadata.gz.sig +0 -0
  45. data/bin/markly +0 -94
  46. data/lib/markly/markly.bundle +0 -0
data/lib/markly.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # The compiled library.
4
+ # Released under the MIT License.
5
+ # Copyright, 2014, by John MacFarlane.
6
+ # Copyright, 2015-2019, by Garen Torikian.
7
+ # Copyright, 2015, by Nick Wellnhofer.
8
+ # Copyright, 2016-2017, by Yuki Izumi.
9
+ # Copyright, 2020-2023, by Samuel Williams.
10
+
5
11
  require 'markly/markly'
6
12
 
7
13
  require_relative 'markly/flags'
@@ -11,33 +17,33 @@ require_relative 'markly/renderer/html'
11
17
  require_relative 'markly/version'
12
18
 
13
19
  module Markly
14
- # Public: Parses a Markdown string into a `document` node.
15
- #
16
- # string - {String} to be parsed
17
- # option - A {Symbol} or {Array of Symbol}s indicating the parse options
18
- # extensions - An {Array of Symbol}s indicating the extensions to use
19
- #
20
- # Returns the `parser` node.
21
- def self.parse(text, flags: DEFAULT, extensions: nil)
22
- parser = Parser.new(flags)
23
-
24
- extensions&.each do |extension|
25
- parser.enable(extension)
26
- end
27
-
28
- return parser.parse(text.encode(Encoding::UTF_8))
29
- end
30
-
31
- # Public: Parses a Markdown string into an HTML string.
32
- #
33
- # text - A {String} of text
34
- # option - Either a {Symbol} or {Array of Symbol}s indicating the render options
35
- # extensions - An {Array of Symbol}s indicating the extensions to use
36
- #
37
- # Returns a {String} of converted HTML.
38
- def self.render_html(text, flags: DEFAULT, parse_flags: flags, render_flags: flags, extensions: [])
39
- root = self.parse(text, flags: parse_flags, extensions: extensions)
40
-
41
- return root.to_html(flags: render_flags, extensions: extensions)
42
- end
20
+ # Public: Parses a Markdown string into a `document` node.
21
+ #
22
+ # string - {String} to be parsed
23
+ # option - A {Symbol} or {Array of Symbol}s indicating the parse options
24
+ # extensions - An {Array of Symbol}s indicating the extensions to use
25
+ #
26
+ # Returns the `parser` node.
27
+ def self.parse(text, flags: DEFAULT, extensions: nil)
28
+ parser = Parser.new(flags)
29
+
30
+ extensions&.each do |extension|
31
+ parser.enable(extension)
32
+ end
33
+
34
+ return parser.parse(text.encode(Encoding::UTF_8))
35
+ end
36
+
37
+ # Public: Parses a Markdown string into an HTML string.
38
+ #
39
+ # text - A {String} of text
40
+ # option - Either a {Symbol} or {Array of Symbol}s indicating the render options
41
+ # extensions - An {Array of Symbol}s indicating the extensions to use
42
+ #
43
+ # Returns a {String} of converted HTML.
44
+ def self.render_html(text, flags: DEFAULT, parse_flags: flags, render_flags: flags, extensions: [])
45
+ root = self.parse(text, flags: parse_flags, extensions: extensions)
46
+
47
+ return root.to_html(flags: render_flags, extensions: extensions)
48
+ end
43
49
  end
data/license.md ADDED
@@ -0,0 +1,39 @@
1
+ # MIT License
2
+
3
+ Copyright, 2014, by John MacFarlane.
4
+ Copyright, 2015-2020, by Garen Torikian.
5
+ Copyright, 2015, by Nick Wellnhofer.
6
+ Copyright, 2015-2017, by Andrew Anderson.
7
+ Copyright, 2016-2017, by Yuki Izumi.
8
+ Copyright, 2017, by Mu-An Chiou.
9
+ Copyright, 2017-2018, by Goro Fuji.
10
+ Copyright, 2017, by Ben Woosley.
11
+ Copyright, 2017, by Roberto Hidalgo.
12
+ Copyright, 2017-2020, by Ashe Connor.
13
+ Copyright, 2018, by Jerry van Leeuwen.
14
+ Copyright, 2018, by Vitaliy Klachkov.
15
+ Copyright, 2018, by Michael Camilleri.
16
+ Copyright, 2018, by Akira Matsuda.
17
+ Copyright, 2018, by Danny Iachini.
18
+ Copyright, 2019-2020, by Tomoya Chiba.
19
+ Copyright, 2019, by Brett Walker.
20
+ Copyright, 2020, by Olle Jonsson.
21
+ Copyright, 2020-2023, by Samuel Williams.
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,36 @@
1
+ # Markly
2
+
3
+ A parser and abstract syntax tree for Markdown documents (CommonMark compatible) in Ruby. Originally forked from
4
+ [CommonMarker](https://github.com/gjtorikian/commonmarker). It also includes extensions to the CommonMark spec as
5
+ documented in the [GitHub Flavored Markdown spec](http://github.github.com/gfm/), such as support for tables,
6
+ strikethroughs, and autolinking.
7
+
8
+ [![Development
9
+ Status](https://github.com/ioquatix/markly/workflows/Test/badge.svg)](https://github.com/ioquatix/markly/actions?workflow=Test)
10
+
11
+ ## Motivation
12
+
13
+ This code base was originally forked from [Commonmarker](https://github.com/gjtorikian/commonmarker) before they
14
+ switched from `cmark-gfm` (C) to `comrak` (Rust). The original implementation provided access to the abstract syntax
15
+ tree (AST), which is useful for building tools on top of Markdown. The Rust implementation does not provide this
16
+ functionality, and so this fork was created to continue to provide these (and more) features.
17
+
18
+ ## Usage
19
+
20
+ Please see the [project documentation](https://ioquatix.github.io/markly/) for more details.
21
+
22
+ - [Getting Started](https://ioquatix.github.io/markly/guides/getting-started/index) - This guide explains now to
23
+ install and use Markly.
24
+
25
+ - [Abstract Syntax Tree](https://ioquatix.github.io/markly/guides/abstract-syntax-tree/index) - This guide explains
26
+ how to use Markly's abstract syntax tree (AST) to parse and manipulate Markdown documents.
27
+
28
+ ## Contributing
29
+
30
+ We welcome contributions to this project.
31
+
32
+ 1. Fork it.
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
35
+ 4. Push to the branch (`git push origin my-new-feature`).
36
+ 5. Create new Pull Request.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,16 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
- - Ashe Connor
8
+ - Yuki Izumi
9
9
  - Samuel Williams
10
+ - John MacFarlane
11
+ - Ashe Connor
12
+ - Nick Wellnhofer
13
+ - Brett Walker
14
+ - Andrew Anderson
15
+ - Ben Woosley
16
+ - Goro Fuji
17
+ - Tomoya Chiba
18
+ - Akira Matsuda
19
+ - Danny Iachini
20
+ - Jerry van Leeuwen
21
+ - Michael Camilleri
22
+ - Mu-An Chiou
23
+ - Olle Jonsson
24
+ - Roberto Hidalgo
25
+ - Vitaliy Klachkov
10
26
  autorequire:
11
27
  bindir: bin
12
- cert_chain: []
13
- date: 2022-01-17 00:00:00.000000000 Z
28
+ cert_chain:
29
+ - |
30
+ -----BEGIN CERTIFICATE-----
31
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
32
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
33
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
34
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
35
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/I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hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
52
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
53
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
54
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
55
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
56
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
57
+ -----END CERTIFICATE-----
58
+ date: 2023-06-17 00:00:00.000000000 Z
14
59
  dependencies:
15
60
  - !ruby/object:Gem::Dependency
16
61
  name: bake
@@ -27,21 +72,7 @@ dependencies:
27
72
  - !ruby/object:Gem::Version
28
73
  version: '0'
29
74
  - !ruby/object:Gem::Dependency
30
- name: minitest
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '5.6'
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '5.6'
43
- - !ruby/object:Gem::Dependency
44
- name: rake
75
+ name: covered
45
76
  requirement: !ruby/object:Gem::Requirement
46
77
  requirements:
47
78
  - - ">="
@@ -55,28 +86,27 @@ dependencies:
55
86
  - !ruby/object:Gem::Version
56
87
  version: '0'
57
88
  - !ruby/object:Gem::Dependency
58
- name: rake-compiler
89
+ name: sus
59
90
  requirement: !ruby/object:Gem::Requirement
60
91
  requirements:
61
- - - "~>"
92
+ - - ">="
62
93
  - !ruby/object:Gem::Version
63
- version: '0.9'
94
+ version: '0'
64
95
  type: :development
65
96
  prerelease: false
66
97
  version_requirements: !ruby/object:Gem::Requirement
67
98
  requirements:
68
- - - "~>"
99
+ - - ">="
69
100
  - !ruby/object:Gem::Version
70
- version: '0.9'
101
+ version: '0'
71
102
  description:
72
103
  email:
73
- executables:
74
- - markly
104
+ executables: []
75
105
  extensions:
76
106
  - ext/markly/extconf.rb
77
107
  extra_rdoc_files: []
78
108
  files:
79
- - bin/markly
109
+ - conduct.md
80
110
  - ext/markly/arena.c
81
111
  - ext/markly/autolink.c
82
112
  - ext/markly/autolink.h
@@ -150,17 +180,19 @@ files:
150
180
  - ext/markly/xml.c
151
181
  - lib/markly.rb
152
182
  - lib/markly/flags.rb
153
- - lib/markly/markly.bundle
154
183
  - lib/markly/node.rb
155
184
  - lib/markly/node/inspect.rb
156
185
  - lib/markly/renderer/generic.rb
157
186
  - lib/markly/renderer/html.rb
158
187
  - lib/markly/version.rb
188
+ - license.md
189
+ - readme.md
159
190
  homepage: https://github.com/ioquatix/markly
160
191
  licenses:
161
192
  - MIT
162
193
  metadata:
163
194
  funding_uri: https://github.com/sponsors/ioquatix/
195
+ documentation_uri: https://ioquatix.github.io/markly/
164
196
  post_install_message:
165
197
  rdoc_options: []
166
198
  require_paths:
@@ -176,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
208
  - !ruby/object:Gem::Version
177
209
  version: '0'
178
210
  requirements: []
179
- rubygems_version: 3.2.32
211
+ rubygems_version: 3.4.7
180
212
  signing_key:
181
213
  specification_version: 4
182
214
  summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
metadata.gz.sig ADDED
Binary file
data/bin/markly DELETED
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'optparse'
5
- require 'ostruct'
6
-
7
- require_relative '../lib/markly'
8
-
9
- def parse_options
10
- options = OpenStruct.new
11
- extensions = Markly.extensions
12
- parse_flags = Markly::PARSE_FLAGS
13
- render_flags = Markly::RENDER_FLAGS
14
-
15
- options.active_extensions = []
16
- options.active_parse_flags = Markly::DEFAULT
17
- options.active_render_flags = Markly::DEFAULT
18
-
19
- option_parser = OptionParser.new do |opts|
20
- opts.banner = 'Usage: markly [--html-renderer] [--extension=EXTENSION]'
21
- opts.separator ' [--parse-option=OPTION]'
22
- opts.separator ' [--render-option=OPTION]'
23
- opts.separator ' [FILE..]'
24
- opts.separator ''
25
- opts.separator 'Convert one or more CommonMark files to HTML and write to standard output.'
26
- opts.separator 'If no FILE argument is provided, text will be read from STDIN.'
27
- opts.separator ''
28
-
29
- opts.on('--extension=EXTENSION', Array, 'Use EXTENSION for parsing and HTML output (unless --html-renderer is specified)') do |values|
30
- values.each do |value|
31
- if extensions.include?(value)
32
- options.active_extensions << value.to_sym
33
- else
34
- abort("extension '#{value}' not found")
35
- end
36
- end
37
- end
38
-
39
- opts.on('-h', '--help', 'Prints this help') do
40
- puts opts
41
- puts
42
- puts "Available extentions: #{extensions.join(', ')}"
43
- puts "Available parse flags: #{parser_flags.keys.join(', ')}"
44
- puts "Available render flags: #{render_flags.keys.join(', ')}"
45
- puts
46
- puts 'See the README for more information on these.'
47
- exit
48
- end
49
-
50
- opts.on('--html-renderer', 'Use the HtmlRenderer renderer rather than the native C renderer') do
51
- options.renderer = true
52
- end
53
-
54
- opts.on('--parse-option=OPTION', Array, 'OPTION passed during parsing') do |values|
55
- values.each do |value|active_parser_flags
56
- if parser_flags.key?(value.to_sym)
57
- options.active_parser_flags << value.to_sym
58
- else
59
- abort("parse-option '#{value}' not found")
60
- end
61
- end
62
- end
63
-
64
- opts.on('--render-option=OPTION', Array, 'OPTION passed during rendering') do |values|
65
- values.each do |value|
66
- if render_flags.key?(value.to_sym)
67
- options.active_render_flags << value.to_sym
68
- else
69
- abort("render-option '#{value}' not found")
70
- end
71
- end
72
- end
73
-
74
- opts.on('-v', '--version', 'Version information') do
75
- puts "markly #{Markly::VERSION}"
76
- exit
77
- end
78
- end
79
-
80
- option_parser.parse!
81
-
82
- options
83
- end
84
-
85
- options = parse_options
86
-
87
- doc = Markly.parse(ARGF.read, flags: options.active_parse_flags, extensions: options.active_extensions)
88
-
89
- if options.renderer
90
- renderer = Markly::HtmlRenderer.new(extensions: options.active_extensions)
91
- STDOUT.write(renderer.render(doc))
92
- else
93
- STDOUT.write(doc.to_html(flags: options.active_render_flags, extensions: options.active_extensions))
94
- end
Binary file