markleft 0.1.2 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c0c05582686415cb88d442076b8e894b8354b8b09044f797f37f70d12914c30
4
- data.tar.gz: c5629cfea579afa7bae6477dc3c9202dcf643a14259c564f18a075cd077047bc
3
+ metadata.gz: 0e39397435aa49f700beb715c4b6217b05d91e2e07285f47ea3975a6a0ff9b42
4
+ data.tar.gz: 601e1056c30ae08ea786e1ca7b16a68855ee3cc0084bcdbc9361cf52b4ffabf9
5
5
  SHA512:
6
- metadata.gz: c8c584cd46c4a9d5f3e880295aac8e010e2d3f964109e1e88c78bdd4ebb95f018bc139018b96ac4ad99659d2f05c83c7ddaf3802bf25a1194f5a16040d2c957d
7
- data.tar.gz: fc98229f257308acf4d19f1c9f9e2d1ec05f865403c9f2550cac4b9a505774396ad815425133b16ed2f9df987bd29a12c2f029a49d00d0b60cd1613beb7e964a
6
+ metadata.gz: 4fbd7f19a38d74ed7d26149504ab8c0ef3f24ca23d5ae24d5f3e71673b31477a89eec037bc4d601a76d5dc171ed157a0bc61e960b46ebf13fd9ff475a27d4058
7
+ data.tar.gz: 57026972645b913bc6814f2d061434d0c392a8728d8f0dbf86a8f554230ece2b4c94315d6866ef49f49bae33e2cd58c3dd455b872447b47c60a443af49f4510a
data/.idea/markleft.iml CHANGED
@@ -12,10 +12,70 @@
12
12
  <orderEntry type="jdk" jdkName="ruby-3.2.4-p170" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-3.2.4-p170) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.3, ruby-3.2.4-p170) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="cli-ui (v2.3.0, ruby-3.2.4-p170) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.10.1, ruby-3.2.4-p170) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.4, ruby-3.2.4-p170) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.25.4, ruby-3.2.4-p170) [gem]" level="application" />
15
20
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.26.3, ruby-3.2.4-p170) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.7.1, ruby-3.2.4-p170) [gem]" level="application" />
16
22
  <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, ruby-3.2.4-p170) [gem]" level="application" />
17
23
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, ruby-3.2.4-p170) [gem]" level="application" />
18
24
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.2.1, ruby-3.2.4-p170) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.10.0, ruby-3.2.4-p170) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.71.2, ruby-3.2.4-p170) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.38.0, ruby-3.2.4-p170) [gem]" level="application" />
19
28
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, ruby-3.2.4-p170) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.4, ruby-3.2.4-p170) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4, ruby-3.2.4-p170) [gem]" level="application" />
31
+ </component>
32
+ <component name="RakeTasksCache-v2">
33
+ <option name="myRootTask">
34
+ <RakeTaskImpl id="rake">
35
+ <subtasks>
36
+ <RakeTaskImpl description="Build markleft-0.1.5.gem into the pkg directory" fullCommand="build" id="build" />
37
+ <RakeTaskImpl id="build">
38
+ <subtasks>
39
+ <RakeTaskImpl description="Generate SHA512 checksum of markleft-0.1.5.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
40
+ </subtasks>
41
+ </RakeTaskImpl>
42
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
43
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
44
+ <RakeTaskImpl description="Build and install markleft-0.1.5.gem into system gems" fullCommand="install" id="install" />
45
+ <RakeTaskImpl id="install">
46
+ <subtasks>
47
+ <RakeTaskImpl description="Build and install markleft-0.1.5.gem into system gems without network access" fullCommand="install:local" id="local" />
48
+ </subtasks>
49
+ </RakeTaskImpl>
50
+ <RakeTaskImpl description="Create tag v0.1.5 and build and push markleft-0.1.5.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
51
+ <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
52
+ <RakeTaskImpl id="rubocop">
53
+ <subtasks>
54
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
55
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
56
+ <RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
57
+ </subtasks>
58
+ </RakeTaskImpl>
59
+ <RakeTaskImpl description="Run the test suite" fullCommand="test" id="test" />
60
+ <RakeTaskImpl id="test">
61
+ <subtasks>
62
+ <RakeTaskImpl description="Print out the test command" fullCommand="test:cmd" id="cmd" />
63
+ <RakeTaskImpl description="Show which test files fail when run in isolation" fullCommand="test:isolated" id="isolated" />
64
+ <RakeTaskImpl description="Run the test suite and report the slowest 25 tests" fullCommand="test:slow" id="slow" />
65
+ <RakeTaskImpl description="" fullCommand="test:deps" id="deps" />
66
+ </subtasks>
67
+ </RakeTaskImpl>
68
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
69
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
70
+ <RakeTaskImpl id="release">
71
+ <subtasks>
72
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
73
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
74
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
75
+ </subtasks>
76
+ </RakeTaskImpl>
77
+ </subtasks>
78
+ </RakeTaskImpl>
79
+ </option>
20
80
  </component>
21
81
  </module>
data/README.md CHANGED
@@ -7,19 +7,16 @@
7
7
 
8
8
  MarkLeft is a powerful and flexible tool designed to extend the capabilities of traditional Markdown-to-HTML compilers. It introduces additional syntax and features to enhance the expressiveness and functionality of Markdown documents.
9
9
 
10
- ## Project Structure
10
+ > [!TIP]
11
+ > MarkLeft is a work in progress and is currently under development. Please check back for updates and new features.
12
+ > You are still free to use it and contribute to it.
11
13
 
12
- - `Gemfile` and `Gemfile.lock`: Manage gem dependencies.
13
- - `markleft-main.rb`: Script for converting Markdown to HTML.
14
- - `terminal.rb`: TUI for converting Markdown to HTML.
15
- - `lib/`: Contains the tokenizer, parser, and generator classes.
16
14
 
17
15
  ## Features
18
16
 
19
- - **Extended Syntax**: Supports additional formatting options such as bold, italics, and more.
20
- - **Custom Nodes**: Allows the creation of custom nodes to represent different types of content.
21
- - **Tokenization and Parsing**: Efficiently tokenizes and parses Markdown content into a structured node tree.
22
- - **Easy Integration**: Can be easily integrated into existing projects and workflows.
17
+ - **Superfast**: MarkLeft is designed to be fast and efficient, processing Markdown files quickly and generating HTML output in an instant.
18
+ - **Extensible**: MarkLeft is highly extensible, allowing users to define custom syntax and features to suit their needs.
19
+ - **Customizable**: MarkLeft provides a range of options and settings to customize the output, including themes, styles, and more.(coming soon)
23
20
 
24
21
  ## Prerequisites
25
22
 
@@ -30,43 +27,44 @@ MarkLeft is a powerful and flexible tool designed to extend the capabilities of
30
27
 
31
28
  To install MarkLeft, clone the repository and navigate to the project directory:
32
29
 
33
- 1. Clone the repository:
34
- ```sh
35
- git clone https://github.com/yourusername/markdown-to-html.git
36
- cd markdown-to-html
37
- ```
30
+ #### Gem
38
31
 
39
- 2. Install the dependencies:
40
- ```sh
41
- bundle install
42
- ```
32
+ ```sh
33
+ gem install markleft
34
+ ```
35
+
36
+ #### Repository
37
+
38
+ ```sh
39
+ git clone git@github.com:greeenboi/markdown-superset-compiler.git
40
+ cd markdown-superset-compiler
41
+ ```
43
42
 
44
43
  ## Running the Converter
45
44
 
46
- ### Using `markleft-main.rb`
45
+ #### Using Gem
47
46
 
48
- The `markleft-main.rb` file is a simple script that reads a Markdown file, tokenizes it, parses it, and generates HTML output.
47
+ ```shell
48
+ markleft
49
+ ```
49
50
 
50
- 1. Run the script:
51
- ```sh
52
- ruby markleft-main.rb
53
- ```
51
+ 0r
54
52
 
55
- 2. Enter the name of the Markdown file when prompted.
53
+ ```shell
54
+ markleft --file <filename>
55
+ ```
56
56
 
57
- ### Using `terminal.rb` (TUI)
57
+ #### Using `markleft-main.rb`
58
58
 
59
- The `terminal.rb` file provides a Text User Interface (TUI) for selecting and processing Markdown files.
59
+ The `markleft-main.rb` file is a simple script that reads a Markdown file, tokenizes it, parses it, and generates HTML output.
60
60
 
61
61
  1. Run the script:
62
62
  ```sh
63
- ruby terminal.rb
63
+ ruby lib/markleft.rb
64
64
  ```
65
-
65
+
66
66
  2. Follow the prompts to select a Markdown file and process it.
67
67
 
68
-
69
-
70
68
  ## Example
71
69
 
72
70
  Given a sample Markdown file `sample.md`:
data/Rakefile CHANGED
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "minitest/markleft_task"
4
+ require "minitest/test_task"
5
5
 
6
- Minitest::MarkleftTask.create
6
+ Minitest::TestTask.create(:test) do |t|
7
+ t.test_globs = FileList["test/**/*_test.rb"]
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ end
7
11
 
8
12
  require "rubocop/rake_task"
9
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markleft
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/markleft.rb CHANGED
@@ -3,11 +3,19 @@
3
3
  require "cli/ui"
4
4
  require "fileutils"
5
5
  require_relative "markleft/version"
6
+ require 'optparse'
6
7
 
7
8
  module Markleft
8
9
  # ----------------- Tokenizer Module ----------------- #
9
10
  class Tokenizer
10
11
  TOKEN_TYPES = [
12
+ [:heading1, /^# .+/],
13
+ [:heading2, /^## .+/],
14
+ [:heading3, /^### .+/],
15
+ [:heading4, /^#### .+/],
16
+ [:heading5, /^##### .+/],
17
+ [:heading6, /^###### .+/],
18
+ [:strikethrough, /((?<!\s)~~(?!\s)(?:[^~]+?|(?:[^~]*(?:(?:~[^~]*){2})+?)+?)(?<!\s)~~)/],
11
19
  [:bold, /((?<!\s)\*\*(?!\s)(?:[^*]+?|(?:[^*]*(?:(?:\*[^*]*){2})+?)+?)(?<!\s)\*\*)/],
12
20
  [:italics, /((?<!\s)\*(?!\s)(?:(?:[^**]*(?:(?:\*\*[^**]*){2})+?)+?|[^**]+?)(?<!\s)\*)/],
13
21
  [:newline, /(\r\n|\r|\n)/],
@@ -63,6 +71,20 @@ module Markleft
63
71
  parse_newline
64
72
  when :text
65
73
  parse_text
74
+ when :heading1
75
+ parse_heading(1)
76
+ when :heading2
77
+ parse_heading(2)
78
+ when :heading3
79
+ parse_heading(3)
80
+ when :heading4
81
+ parse_heading(4)
82
+ when :heading5
83
+ parse_heading(5)
84
+ when :heading6
85
+ parse_heading(6)
86
+ when :strikethrough
87
+ parse_strikethrough
66
88
  else
67
89
  raise "Unexpected token type: #{@tokens.first.type}"
68
90
  end
@@ -83,6 +105,16 @@ module Markleft
83
105
  NewlineNode.new
84
106
  end
85
107
 
108
+ def parse_heading(level)
109
+ consume(:"heading#{level}")
110
+ HeadingNode.new("Heading", level)
111
+ end
112
+
113
+ def parse_strikethrough
114
+ value = consume(:strikethrough).value
115
+ StrikethroughNode.new(value)
116
+ end
117
+
86
118
  def parse_text
87
119
  value = consume(:text).value
88
120
  TextNode.new(value)
@@ -111,6 +143,10 @@ module Markleft
111
143
  generate_newline(node)
112
144
  when TextNode
113
145
  generate_text(node)
146
+ when HeadingNode
147
+ generate_heading(node)
148
+ when StrikethroughNode
149
+ generate_strikethrough(node)
114
150
  else
115
151
  raise "Unexpected node type: #{node.class}"
116
152
  end
@@ -128,6 +164,14 @@ module Markleft
128
164
  "<br>"
129
165
  end
130
166
 
167
+ def generate_heading(node)
168
+ "<h#{node.level}>#{node.value}</h#{node.level}>"
169
+ end
170
+
171
+ def generate_strikethrough(node)
172
+ "<del>#{node.value}</del>"
173
+ end
174
+
131
175
  def generate_text(node)
132
176
  node.value
133
177
  end
@@ -146,6 +190,8 @@ module Markleft
146
190
  ItalicsNode = Struct.new(:value)
147
191
  NewlineNode = Struct.new(:value)
148
192
  TextNode = Struct.new(:value)
193
+ HeadingNode = Struct.new(:value, :level)
194
+ StrikethroughNode = Struct.new(:value)
149
195
 
150
196
  # ----------------- Main Block ----------------- #
151
197
 
@@ -196,12 +242,41 @@ module Markleft
196
242
  html_file_name
197
243
  end
198
244
 
199
- CLI::UI::Frame.open("Markdown to HTML Converter") do
245
+ CLI::UI::Frame.open("Markleft") do
246
+ puts "Markleft version: #{Markleft::VERSION}"
247
+ puts "Ruby version: #{RUBY_VERSION}"
248
+ puts "Developer: Suvan Gowri Shanker"
249
+ puts "GitHub: https://github.com/greeenboi"
250
+
251
+ options = {}
252
+ OptionParser.new do |opts|
253
+ opts.banner = <<~BANNER
254
+ Usage: markleft [options]
255
+
256
+ This utility converts Markdown files in the current directory to HTML.
257
+ It provides an interactive UI to select files unless a file is specified.
258
+ Use the following flags for quick access:
259
+
260
+ BANNER
261
+ opts.separator ""
262
+ opts.separator "Examples:"
263
+ opts.separator " markleft --file example.md"
264
+ opts.separator " markleft --help"
265
+ opts.separator ""
266
+ opts.on("--help", "Show help information") do
267
+ puts opts
268
+ exit
269
+ end
270
+ opts.on("--file FILE", "Specify a markdown file") do |filename|
271
+ options[:file] = filename
272
+ end
273
+ end.parse!
274
+
200
275
  files = list_md_files
201
276
  if files.empty?
202
277
  puts "No markdown files found in the current directory."
203
278
  else
204
- selected_file = select_md_file(files)
279
+ selected_file = options[:file] || select_md_file(files)
205
280
  puts "Processing file: #{selected_file}"
206
281
  html_content = process_file(selected_file)
207
282
  puts "Generated HTML content:"
data/sample.html CHANGED
@@ -1 +1 @@
1
- # Heading 1## Heading 2### Heading 3#### Heading 4##### Heading 5###### Heading 6---<b>**Bold text**</b><i>*Italic text*</i><b>***Bold and italic text***</b>~~Strikethrough text~~> Blockquote- Unordered list item 1- Unordered list item 2- Nested unordered list item1. Ordered list item 12. Ordered list item 21. Nested ordered list item`Inline code````ruby# Code block with syntax highlightingdef hello_worldputs "Hello, world!"end```[Link to GitHub](https://github.com)![Image alt text](https://via.placeholder.com/150)| Header 1 | Header 2 || -------- | -------- || Cell 1 | Cell 2 || Cell 3 | Cell 4 |---- [ ] Task list item 1- [x] Task list item 2---Footnote reference[^1].[^1]: Footnote text.---This is a sample text with a [^2] superscript.[^2]: Superscript text.---<details><summary>Expandable section</summary>This is the content of the expandable section.</details>---
1
+ <h1>Heading</h1><h2>Heading</h2><h3>Heading</h3><h4>Heading</h4><h5>Heading</h5><h6>Heading</h6>---<b>**Bold text**</b><i>*Italic text*</i><b>***Bold and italic text***</b><del>~~Strikethrough text~~</del> > Blockquote- Unordered list item 1- Unordered list item 2- Nested unordered list item1. Ordered list item 12. Ordered list item 21. Nested ordered list item`Inline code````ruby<h1>Heading</h1>def hello_worldputs "Hello, world!"end```[Link to GitHub](https://github.com)![Image alt text](https://via.placeholder.com/150)| Header 1 | Header 2 || -------- | -------- || Cell 1 | Cell 2 || Cell 3 | Cell 4 |---- [ ] Task list item 1- [x] Task list item 2---Footnote reference[^1].[^1]: Footnote text.---This is a sample text with a [^2] superscript.[^2]: Superscript text.---<details><summary>Expandable section</summary>This is the content of the expandable section.</details>---
@@ -3,8 +3,11 @@ module Markleft
3
3
  def generate: (untyped) -> String
4
4
  def generate_all: (Array[untyped]) -> String
5
5
  def generate_bold: (untyped) -> String
6
+
7
+ def generate_heading: (untyped) -> String
6
8
  def generate_italics: (untyped) -> String
7
9
  def generate_newline: (untyped) -> String
10
+ def generate_strikethrough: (untyped) -> String
8
11
  def generate_text: (untyped) -> String
9
12
  end
10
13
  end
@@ -6,9 +6,12 @@ module Markleft
6
6
  def consume: (Symbol) -> untyped
7
7
  def parse: -> Array[untyped]
8
8
  def parse_bold: -> untyped
9
+
10
+ def parse_heading: -> untyped
9
11
  def parse_italics: -> untyped
10
12
  def parse_newline: -> untyped
11
13
  def parse_node: -> untyped
14
+ def parse_strikethrough: -> untyped
12
15
  def parse_text: -> untyped
13
16
  end
14
17
  end
data/sig/markleft.rbs CHANGED
@@ -1,7 +1,9 @@
1
1
  module Markleft
2
2
  BoldNode: untyped
3
+ HeadingNode: untyped
3
4
  ItalicsNode: untyped
4
5
  NewlineNode: untyped
6
+ StrikethroughNode: untyped
5
7
  TextNode: untyped
6
8
  Token: untyped
7
9
  VERSION: String
@@ -10,7 +12,7 @@ module Markleft
10
12
  @node_tree: untyped
11
13
 
12
14
  def self.list_md_files: -> Array[String]
13
- def self.select_md_file: (Array[String]) -> String
15
+ def self.select_md_file: (Array[String]) -> (String | Array[String])
14
16
  def self.process_file: (String) -> String
15
17
  def self.save_html: (String, String) -> String
16
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markleft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeenboi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-02-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: MarkLeft is a powerful and flexible tool designed to extend the capabilities
14
14
  of traditional Markdown-to-HTML compilers. It introduces additional syntax and features
@@ -34,7 +34,6 @@ files:
34
34
  - exe/markleft
35
35
  - lib/markleft.rb
36
36
  - lib/markleft/version.rb
37
- - markleft-0.1.1.gem
38
37
  - sample.html
39
38
  - sample.md
40
39
  - sig/markleft.rbs
data/markleft-0.1.1.gem DELETED
Binary file