gitlab-glfm-markdown 0.0.7-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2011-present GitLab B.V.
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ * All content residing under the "doc/" directory of this repository is licensed under "Creative Commons: CC BY-SA 4.0 license".
6
+ * All content that resides under the "ee/" directory of this repository, if that directory exists, is licensed under the license defined in "ee/LICENSE".
7
+ * All content that resides under the "jh/" directory of this repository, if that directory exists, is licensed under the license defined in "jh/LICENSE".
8
+ * All client-side JavaScript (when served directly or after being compiled, arranged, augmented, or combined), is licensed under the "MIT Expat" license.
9
+ * All third party components incorporated into the GitLab Software are licensed under the original license provided by the owner of the applicable component.
10
+ * Content outside of the above mentioned directories or restrictions above is available under the "MIT Expat" license as defined below.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # GitLab Flavored Markdown
2
+
3
+ [![Pipeline status](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/badges/main/pipeline.svg)](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/commits/main)
4
+ [![Latest Release](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/badges/release.svg)](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/releases)
5
+
6
+ Implements GLFM (as used by GitLab) using a Rust-based markdown parser.
7
+
8
+ This project is currently EXPLORATORY, so anything and everything will change.
9
+
10
+ ## Installation
11
+
12
+ Install the gem and add to the application's Gemfile by executing:
13
+
14
+ $ bundle add gitlab-glfm-markdown
15
+
16
+ If bundler is not being used to manage dependencies, install the gem by executing:
17
+
18
+ $ gem install gitlab-glfm-markdown
19
+
20
+ ## Usage
21
+
22
+ Try on command line:
23
+
24
+ ```
25
+ rake compile
26
+ bin/console
27
+
28
+ GLFMMarkdown.to_html('# header', options: {sourcepos: true})
29
+ ```
30
+
31
+ ## Development
32
+
33
+ A command line executable can be built for debugging.
34
+
35
+ ```
36
+ cd ext/glfm_markdown
37
+ cargo run --bin glfm_markdown -- --sourcepos
38
+ ```
39
+
40
+ There is a VSCode workspace that allows you to `Debug executable`
41
+
42
+ When developing another project locally and using `gitlab-glfm-markdown` by linking
43
+ directly to the gem's source directory, make sure that you're using the same version
44
+ of Ruby for the project and the gem. Otherwise you can see unexplained errors when
45
+ calling into the gem.
46
+
47
+ ### Releasing a new version
48
+
49
+ To release a new version:
50
+
51
+ 1. Update `lib/glfm_markdown/version.rb` with the version number.
52
+ 1. Update `CHANGELOG.md` with the changes in the release.
53
+ 1. Create a merge request and merge it to `master`.
54
+ 1. Push a new tag to the repository.
55
+
56
+ The new version with precompiled, native gems will automatically be
57
+ published to [RubyGems](https://rubygems.org/gems/gitlab-glfm-markdown) when the
58
+ pipeline for the tag completes.
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and merge requests are welcome on GitLab at https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown.
63
+
64
+ Please refer to [CONTRIBUTING](CONTRIBUTING.md) for more details.
@@ -0,0 +1,19 @@
1
+ [package]
2
+ name = "glfm_markdown"
3
+ version = "0.0.3"
4
+ edition = "2021"
5
+ authors = ["digitalmoksha <bwalker@gitlab.com>"]
6
+ publish = false
7
+
8
+ [lib]
9
+ crate-type = ["cdylib"]
10
+
11
+ [[bin]]
12
+ name = "glfm_markdown"
13
+
14
+ [dependencies]
15
+ magnus = { version = "0.5" }
16
+ rb-sys = { version = "0.9.82", default-features = false, features = ["stable-api-compiled-fallback"] }
17
+ argparse = { version = ">= 0.2.1" }
18
+ comrak = { version = "0.19.0" }
19
+ anstream = { version = "0.4" } # TODO keep until we upgrade to rustc 1.70.0 or newer
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+ require 'rb_sys/mkmf'
5
+
6
+ create_rust_makefile('glfm_markdown')
@@ -0,0 +1,30 @@
1
+ #[derive(Debug)]
2
+ pub struct RenderOptions {
3
+ pub sourcepos: bool,
4
+ pub debug: bool,
5
+ }
6
+
7
+ pub fn render(text: String, options: RenderOptions) -> String {
8
+ render_comrak(text, options)
9
+ }
10
+
11
+ fn render_comrak(text: String, options: RenderOptions) -> String {
12
+ let mut comrak_options = comrak::ComrakOptions::default();
13
+
14
+ comrak_options.extension.strikethrough = true;
15
+ comrak_options.extension.table = true;
16
+ comrak_options.extension.autolink = true;
17
+ comrak_options.extension.tasklist = false;
18
+ comrak_options.extension.footnotes = true;
19
+
20
+ comrak_options.render.unsafe_ = true;
21
+ comrak_options.render.github_pre_lang = true;
22
+ comrak_options.render.full_info_string = true;
23
+ comrak_options.render.hardbreaks = false;
24
+ comrak_options.render.sourcepos = options.sourcepos;
25
+
26
+ comrak_options.parse.smart = false;
27
+ comrak_options.parse.relaxed_autolinks = false;
28
+
29
+ comrak::markdown_to_html(&text, &comrak_options)
30
+ }
@@ -0,0 +1,21 @@
1
+ use magnus::{define_module, function, prelude::*, Error, RHash, Symbol};
2
+
3
+ mod glfm;
4
+ use glfm::{render, RenderOptions};
5
+
6
+ pub fn render_to_html_rs(text: String, options: RHash) -> String {
7
+ let sourcepos: bool = options.lookup::<_, bool>(Symbol::new("sourcepos")).unwrap();
8
+ let debug: bool = options.lookup::<_, bool>(Symbol::new("debug")).unwrap();
9
+ let render_options = RenderOptions { sourcepos, debug };
10
+
11
+ render(text, render_options)
12
+ }
13
+
14
+ #[magnus::init]
15
+ fn init() -> Result<(), Error> {
16
+ let module = define_module("GLFMMarkdown")?;
17
+
18
+ module.define_singleton_method("render_to_html_rs", function!(render_to_html_rs, 2))?;
19
+
20
+ Ok(())
21
+ }
@@ -0,0 +1,54 @@
1
+ mod glfm;
2
+ use glfm::{render, RenderOptions};
3
+ use std::io::Read;
4
+ use std::io::Write;
5
+
6
+ fn main() {
7
+ let mut input = "-".to_owned();
8
+ let mut output = "-".to_owned();
9
+ let mut sourcepos = false;
10
+ let mut debug = false;
11
+
12
+ {
13
+ // this block limits scope of borrows by cli.refer() method
14
+ let mut cli = argparse::ArgumentParser::new();
15
+
16
+ cli.set_description("Gitlab Flavored Markdown. Experimental.");
17
+
18
+ cli.refer(&mut input)
19
+ .add_argument("file", argparse::Store, "File to read");
20
+ cli.refer(&mut output)
21
+ .add_option(&["-o", "--output"], argparse::Store, "File to write");
22
+ cli.refer(&mut sourcepos).add_option(
23
+ &["--sourcepos"],
24
+ argparse::StoreTrue,
25
+ "Include source mappings in HTML attributes.",
26
+ );
27
+ cli.refer(&mut debug).add_option(
28
+ &["--debug"],
29
+ argparse::StoreTrue,
30
+ "Show debug information",
31
+ );
32
+
33
+ cli.parse_args_or_exit();
34
+ }
35
+
36
+ let vec = if input == "-" {
37
+ let mut vec = Vec::new();
38
+ std::io::stdin().read_to_end(&mut vec).unwrap();
39
+ vec
40
+ } else {
41
+ std::fs::read(input).unwrap()
42
+ };
43
+
44
+ let source = String::from_utf8_lossy(&vec);
45
+ let options = RenderOptions { sourcepos, debug };
46
+
47
+ let result = render(source.to_string(), options);
48
+
49
+ if output == "-" {
50
+ std::io::stdout().write_all(result.as_bytes()).unwrap();
51
+ } else {
52
+ std::fs::write(output, &result).unwrap();
53
+ }
54
+ }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ def load_rust_extension
4
+ ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
5
+ require_relative "./#{ruby_version}/glfm_markdown"
6
+ rescue LoadError
7
+ require 'glfm_markdown/glfm_markdown'
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GLFMMarkdown
4
+ VERSION = '0.0.7'
5
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'glfm_markdown/version'
4
+ require_relative 'glfm_markdown/loader'
5
+
6
+ load_rust_extension
7
+
8
+ DEFAULT_OPTIONS = { sourcepos: true, debug: false }.freeze
9
+
10
+ module GLFMMarkdown
11
+ class << self
12
+ def to_html(markdown, options: {})
13
+ raise TypeError, 'markdown must be a String' unless markdown.is_a?(String)
14
+ raise TypeError, 'markdown must be UTF-8 encoded' unless markdown.encoding.name == "UTF-8"
15
+ raise TypeError, 'options must be a Hash' unless options.is_a?(Hash)
16
+
17
+ render_to_html_rs(markdown, DEFAULT_OPTIONS.merge(options))
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab-glfm-markdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: aarch64-linux
6
+ authors:
7
+ - Brett Walker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rb_sys
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-compiler-dock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ description: Markdown processing for GitLab Flavored Markdown
84
+ email:
85
+ - bwalker@gitlab.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Cargo.lock
91
+ - LICENSE
92
+ - README.md
93
+ - ext/glfm_markdown/Cargo.toml
94
+ - ext/glfm_markdown/extconf.rb
95
+ - ext/glfm_markdown/src/glfm.rs
96
+ - ext/glfm_markdown/src/lib.rs
97
+ - ext/glfm_markdown/src/main.rs
98
+ - lib/glfm_markdown.rb
99
+ - lib/glfm_markdown/2.7/glfm_markdown.so
100
+ - lib/glfm_markdown/3.0/glfm_markdown.so
101
+ - lib/glfm_markdown/3.1/glfm_markdown.so
102
+ - lib/glfm_markdown/3.2/glfm_markdown.so
103
+ - lib/glfm_markdown/loader.rb
104
+ - lib/glfm_markdown/version.rb
105
+ homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown
106
+ licenses:
107
+ - MIT
108
+ metadata:
109
+ homepage_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown
110
+ source_code_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown
111
+ changelog_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/releases
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '2.7'
121
+ - - "<"
122
+ - !ruby/object:Gem::Version
123
+ version: 3.3.dev
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.4.4
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: GLFM Markdown
134
+ test_files: []