Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start wrapping C in Ruby #1

Merged
merged 74 commits into from
May 13, 2015
Merged
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
cd7da61
Add cmark submodule
gjtorikian May 7, 2015
a9e113c
Add script to update gems + submodule
gjtorikian May 7, 2015
944a8b6
Ignore things that need ignoring
gjtorikian May 7, 2015
b7dcd32
Ignore modifications to submodule
gjtorikian May 7, 2015
358f4ef
Produce a C bundle for the Ruby gem
gjtorikian May 7, 2015
dfeb041
Indicate extension in gemspec
gjtorikian May 7, 2015
7f8d244
Bring all the files over into the gemspec
gjtorikian May 7, 2015
eedac36
Define VERSION in a separate location
gjtorikian May 7, 2015
c1f3aa3
Trash lib-ffi
gjtorikian May 7, 2015
a4e0e12
Add script to run a single test
gjtorikian May 7, 2015
e2e5902
Simplify test setup
gjtorikian May 7, 2015
1858c19
Start creating nodes and documents
gjtorikian May 7, 2015
89c3606
Clean up node types in Ruby
gjtorikian May 8, 2015
d2ff420
Uncomment compilation in single test
gjtorikian May 8, 2015
a6fbd23
Support walking down the document
gjtorikian May 9, 2015
a4554d1
Finish all the basic tests
gjtorikian May 10, 2015
089e8f0
Add good ol' Travis file
gjtorikian May 10, 2015
a51ca31
Somehow, I'm in control now
gjtorikian May 10, 2015
d3c081c
typo
gjtorikian May 10, 2015
ba3f222
Remove this line
gjtorikian May 10, 2015
9445691
come on, travis
gjtorikian May 10, 2015
af8d3fc
This line is not needed here
gjtorikian May 10, 2015
2fb7218
We need a newer cmake
gjtorikian May 10, 2015
40d351c
Updates here and there
gjtorikian May 10, 2015
b2c54bb
Flippin' YAML
gjtorikian May 10, 2015
b4b42bd
Update spec test update
gjtorikian May 10, 2015
3289df7
Split out files
gjtorikian May 10, 2015
c580693
Fix several style issues
gjtorikian May 10, 2015
ea12974
Simplify if statement
gjtorikian May 10, 2015
d692e64
omg sudo
gjtorikian May 10, 2015
6ae90bf
Add a bunch of missing methods
gjtorikian May 10, 2015
ca40f90
Try -fPIC for Travis
gjtorikian May 10, 2015
e736b19
Use proper .so extension for Linux
gjtorikian May 10, 2015
4f48429
Include `LDFLAGS` for Linux
gjtorikian May 11, 2015
17b73f3
Export `LD_LIBRARY_PATH` for Linux
gjtorikian May 11, 2015
7907490
`LDFLAG` simplification for Linux
gjtorikian May 11, 2015
9a79fc8
Add minitest dependency
gjtorikian May 11, 2015
54b69d3
Add awesome_print
gjtorikian May 11, 2015
ab43241
Style changes
gjtorikian May 11, 2015
1c16fc8
no magic strings
gjtorikian May 11, 2015
d3dd72e
Rename spec test generator
gjtorikian May 11, 2015
e4cf4e5
Regenerate spec_tests.json
gjtorikian May 11, 2015
008c0ba
Minor test updates
gjtorikian May 11, 2015
6afa02c
Match cmark's settings
gjtorikian May 11, 2015
b6a75fa
Fix `markdown_to_html`
gjtorikian May 11, 2015
fb0cdbb
Ignore my test output
gjtorikian May 11, 2015
f91616c
Ignore HTML renderer for now
gjtorikian May 11, 2015
89659a6
Add CIBuild script
gjtorikian May 11, 2015
9358667
Fix test inheritance
gjtorikian May 11, 2015
14ebf61
Open up HTML renderer for Travis
gjtorikian May 11, 2015
8fe4704
Fix benchmark suite run
gjtorikian May 11, 2015
5a5be04
Update cmark to bc5f16f146558a1faf9be6abe034755421f6ecce
gjtorikian May 11, 2015
7cdbb2e
Add separate update script
gjtorikian May 11, 2015
3c9af75
Take HTMLRenderer back out for now
gjtorikian May 11, 2015
b748a40
Enhance `clean` with `make clean`
gjtorikian May 11, 2015
793f491
Remove temp build dir
gjtorikian May 12, 2015
c72ec93
Single quotes when able
gjtorikian May 12, 2015
a1bce42
Uncomment HTML Renderer now
gjtorikian May 12, 2015
46d3d64
Catch false attributes
gjtorikian May 12, 2015
9620927
Rewrite some HTML output
gjtorikian May 12, 2015
9822f3d
Clean up benchmark script
gjtorikian May 12, 2015
cddf986
Add node_parent
gjtorikian May 12, 2015
f81b954
Add `node_previous`
gjtorikian May 12, 2015
ff9dcc3
Clean up if/elsif
gjtorikian May 12, 2015
1072369
Use new Ruby 2.0 %i syntax
gjtorikian May 12, 2015
ec1a3bf
Add `next` call
gjtorikian May 13, 2015
40bf72e
Let's call this half-baked shit good enough for now
gjtorikian May 13, 2015
ea6158a
Parse the string once
gjtorikian May 13, 2015
4a2b0e3
Full disclosure, normal renderer cleanup
gjtorikian May 13, 2015
457448e
Store buffer
gjtorikian May 13, 2015
49aff2e
Get all the beautiful tests to pass
gjtorikian May 13, 2015
34a7784
A lot of style updates
gjtorikian May 13, 2015
8be1237
Update README
gjtorikian May 13, 2015
82283bb
Update README.md
gjtorikian May 13, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Style changes
  • Loading branch information
gjtorikian committed May 11, 2015
commit ab432410ca33da66532903e22c1dd016e8672905
50 changes: 11 additions & 39 deletions lib/commonmarker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ def prepend_child(child)
fail NodeError, 'could not prepend child' if res == 0
end

# Append a child to this Node.
# Params:
# +child+:: Child Node to append.
def prepend_child(child)
res = CMark.node_append_child(@pointer, child.pointer)
fail NodeError, 'could not append child' if res == 0
end

# Returns string content of this Node.
def string_content
CMark.node_get_string_content(@pointer)
Expand Down Expand Up @@ -148,7 +140,7 @@ def header_level=(level)
if self.type != :header
fail NodeError, 'can\'t set header_level for non-header'
end
if !level.is_a?a?(Integer) || level < 0 || level > 6
if !level.is_a?(Integer) || level < 0 || level > 6
fail NodeError, 'level must be between 1-6'
end
res = CMark.node_set_header_level(@pointer, level)
Expand All @@ -157,9 +149,7 @@ def header_level=(level)

# Returns list type of this Node (must be a :list).
def list_type
if self.type != :list
fail NodeError, 'can\'t get list_type for non-list'
end
fail NodeError, 'can\'t get list_type for non-list' unless self.type == :list
LIST_TYPES[CMark.node_get_list_type(@pointer)]
end

Expand All @@ -168,9 +158,7 @@ def list_type
# +list_type+:: New list type (+:list_type+), either
# :ordered_list or :bullet_list.
def list_type=(list_type)
if self.type != :list
fail NodeError, 'can\'t set list_type for non-list'
end
fail NodeError, 'can\'t set list_type for non-list' unless self.type == :list
res = CMark.node_set_list_type(@pointer, list_type)
fail NodeError, 'could not set list_type' if res == 0
end
Expand Down Expand Up @@ -199,38 +187,30 @@ def list_start=(start)

# Returns tight status of this Node (must be a :list).
def list_tight
if self.type != :list
fail NodeError, 'can\'t get list_tight for non-list'
end
fail NodeError, 'can\'t get list_tight for non-list' unless self.type == :list
CMark.node_get_list_tight(@pointer)
end

# Sets tight status of this Node (must be a :list).
# Params:
# +tight+:: New tight status (boolean).
def list_tight=(tight)
if self.type != :list
fail NodeError, 'can\'t set list_tight for non-list'
end
fail NodeError, 'can\'t set list_tight for non-list' unless self.type == :list
res = CMark.node_set_list_tight(@pointer, tight)
fail NodeError, 'could not set list_tight' if res == 0
end

# Returns URL of this Node (must be a :link or :image).
def url
if not (self.type == :link || self.type == :image)
fail NodeError, 'can\'t get URL for non-link or image'
end
fail NodeError, 'can\'t get URL for non-link or image' if !(self.type == :link || self.type == :image)
CMark.node_get_url(@pointer)
end

# Sets URL of this Node (must be a :link or :image).
# Params:
# +URL+:: New URL (+String+).
def url=(url)
if not (self.type == :link || self.type == :image)
fail NodeError, 'can\'t set URL for non-link or image'
end
fail NodeError, 'can\'t set URL for non-link or image' if !(self.type == :link || self.type == :image)
fail NodeError, 'url must be a String' unless url.is_a?(String)
# Make our own copy so ruby won't garbage-collect it:
c_url = FFI::MemoryPointer.from_string(url)
Expand All @@ -240,19 +220,15 @@ def url=(url)

# Returns title of this Node (must be a :link or :image).
def title
if not (self.type == :link || self.type == :image)
fail NodeError, 'can\'t get title for non-link or image'
end
fail NodeError, 'can\'t get title for non-link or image' if !(self.type == :link || self.type == :image)
CMark.node_get_title(@pointer)
end

# Sets title of this Node (must be a :link or :image).
# Params:
# +title+:: New title (+String+).
def title=(title)
if not (self.type == :link || self.type == :image)
fail NodeError, 'can\'t set title for non-link or image'
end
fail NodeError, 'can\'t set title for non-link or image' if !(self.type == :link || self.type == :image)
fail NodeError, 'title must be a String' unless title.is_a?(String)
# Make our own copy so ruby won't garbage-collect it:
c_title = FFI::MemoryPointer.from_string(title)
Expand All @@ -262,19 +238,15 @@ def title=(title)

# Returns fence info of this Node (must be a :code_block).
def fence_info
if not (self.type == :code_block)
fail NodeError, "can\'t get fence_info for non code_block"
end
fail NodeError, 'can\'t get fence_info for non code_block' unless self.type == :code_block
CMark.node_get_fence_info(@pointer)
end

# Sets fence_info of this Node (must be a :code_block).
# Params:
# +info+:: New info (+String+).
def fence_info=(info)
if self.type != :code_block
fail NodeError, 'can\'t set fence_info for non code_block'
end
fail NodeError, 'can\'t set fence_info for non code_block' unless self.type == :code_block
fail NodeError, 'info must be a String' unless info.is_a?(String)
# Make our own copy so ruby won't garbage-collect it:
c_info = FFI::MemoryPointer.from_string(info)
Expand Down